Style.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.ur.urcap.examples.pickorplaceswing.pickorplace;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. public abstract class Style {
  5. protected abstract int getHorizontalSpacing();
  6. protected abstract int getVerticalSpacing();
  7. protected abstract int getHorizontalIndent();
  8. public Box createInfo(String text) {
  9. Box infoBox = Box.createHorizontalBox();
  10. infoBox.setAlignmentX(Component.LEFT_ALIGNMENT);
  11. infoBox.add(new JLabel(text));
  12. return infoBox;
  13. }
  14. public Component createHorizontalSpacing() {
  15. return Box.createRigidArea(new Dimension(getHorizontalSpacing(), 0));
  16. }
  17. public Component createHorizontalIndent() {
  18. return Box.createRigidArea(new Dimension(getHorizontalIndent(), 0));
  19. }
  20. public Component createVerticalSpacing() {
  21. return Box.createRigidArea(new Dimension(0, getVerticalSpacing()));
  22. }
  23. public JButton createButton(String text) {
  24. return new JButton(text);
  25. }
  26. public Box createSection(int axis) {
  27. Box panel = new Box(axis);
  28. panel.setAlignmentX(Component.LEFT_ALIGNMENT);
  29. panel.setAlignmentY(Component.TOP_ALIGNMENT);
  30. return panel;
  31. }
  32. }