List of utility methods to do Swing BorderLayout
Component | addBorders(Component content) add Borders JPanel panel = new JPanel(); BoxLayout boxLayout1 = new BoxLayout(panel, BoxLayout.Y_AXIS); panel.setLayout(boxLayout1); panel.setBackground(CYAN); JPanel topPanel = new JPanel(); topPanel.setPreferredSize(new Dimension((int) content.getPreferredSize().getWidth() + 5, 5)); topPanel.setLayout(new BorderLayout()); topPanel.setBackground(BLUE); ... |
JPanel | addToPanel(JPanel panel, JComponent centerComponent, JComponent arrangedComponent, String borderLayoutConstraint) add To Panel panel.add(centerComponent, BorderLayout.CENTER);
panel.add(arrangedComponent, borderLayoutConstraint);
return panel;
|
JPanel | addToVerticalBorderLayout(JComponent north, JComponent center, JComponent south) add To Vertical Border Layout JPanel panel = new JPanel(new BorderLayout()); if (north != null) { panel.add(north, BorderLayout.NORTH); if (center != null) { panel.add(center, BorderLayout.CENTER); if (south != null) { ... |
JPanel | createBorderLayoutPane(Object... args) create Border Layout Pane if (args.length % 2 != 0) { throw new IllegalArgumentException("Illegal Arguments"); BorderLayout layout = new BorderLayout(); Object maybeHgap = args[args.length - 2]; Object maybeVgap = args[args.length - 1]; boolean hasGap = false; if (maybeHgap instanceof Integer && maybeVgap instanceof Integer) { ... |
JPanel | createBox(Border border, Component center, Component north) create Box return createBox(border, center, north, null, null, null);
|
JPanel | createPanel(Component comp, boolean setBorder, int borderType) create Panel JPanel panel = new JPanel(new BorderLayout()); panel.add(comp, BorderLayout.CENTER); if (setBorder) setBorder(panel, borderType); return panel; |
JPanel | createPanel(JComponent centerComponent, JComponent placedComponent, String borderLayoutConstraint) create Panel JPanel panel = createPanel();
return addToPanel(panel, centerComponent, placedComponent, borderLayoutConstraint);
|
JComponent | layoutCompactHorizontal(JComponent... list) Compact horizontal layout. JComponent last = list[list.length - 1]; for (int i = list.length - 2; i >= 0; i--) { JPanel p = new JPanel(new BorderLayout()); p.add(list[i], BorderLayout.WEST); p.add(last, BorderLayout.EAST); last = p; return last; ... |
JComponent | layoutCompactVertical(JComponent... list) layout Compact Vertical JComponent last = list[list.length - 1]; for (int i = list.length - 2; i >= 0; i--) { JPanel p = new JPanel(new BorderLayout()); p.add(list[i], BorderLayout.NORTH); p.add(last, BorderLayout.SOUTH); last = p; return last; ... |
JPanel | makeBorderPanel(int topMargin, int leftMargin, int bottomMargin, int rightMargin) Make a JPanel with a BorderLayout ; set the border to the given margins. JPanel result = makeBorderPanel();
result.setBorder(BorderFactory.createEmptyBorder(topMargin, leftMargin, bottomMargin, rightMargin));
return result;
|