List of utility methods to do JPanel Child
void | addTwoCheckBoxes(JPanel panel, JCheckBox first, boolean firstChecked, JCheckBox second, boolean secondChecked) add Two Check Boxes first.setSelected(firstChecked);
panel.add(first);
if (second != null) {
second.setSelected(secondChecked);
panel.add(second);
|
void | addUIComponent(JPanel jp, JComponent jc, int loc, int type, int[] decart, Insets insets) add UI Component GridBagConstraints c = new GridBagConstraints(); c.anchor = loc; c.fill = type; c.gridx = decart[0]; c.gridy = decart[1]; c.gridwidth = decart[2]; c.gridheight = decart[3]; c.weightx = (double) (((4 - type) & 2) >> 1); ... |
void | addWidth(JPanel panel, int width) add Width panel.add(Box.createRigidArea(new Dimension(width, 0)));
|
void | addWithPadding(JPanel parentPanel, JPanel panelToBeAdded) add With Padding JPanel spaceContainer = new JPanel(); spaceContainer.setBorder(new EmptyBorder(3, 3, 3, 3)); spaceContainer.add(panelToBeAdded); parentPanel.add(spaceContainer); |
void | fillPanel(final JPanel panel, final GridBagConstraints gbc) fill Panel gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
panel.add(new JPanel(), gbc);
|
JPanel | fillPanel(JPanel panel, Component... components) fill Panel for (Component component : components) { panel.add(component); return panel; |
WindowConstants | getOutermostContainer(JPanel container) get Outermost Container Container pnl = container; while (pnl.getParent() != null) { if (pnl.getParent() instanceof JInternalFrame) { return (JInternalFrame) pnl.getParent(); if (pnl.getParent() instanceof JDialog) { return (JDialog) pnl.getParent(); if (pnl.getParent() instanceof JFrame) { return (JFrame) pnl.getParent(); pnl = pnl.getParent(); return null; |
void | packPanel(JPanel p, int width) pack Panel int minh = 0; for (Component c : p.getComponents()) { minh += c.getMinimumSize().getHeight(); p.setMinimumSize(new Dimension(width, minh)); p.setMaximumSize(new Dimension(width, minh)); |
void | padPanel(Object innerPanel, JPanel outerPanel, int pad) pad Panel final GridBagConstraints c; c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(pad, pad, pad, pad); c.fill = GridBagConstraints.BOTH; c.weightx = 1; ... |
void | removeComponentFromPanel(Component removeComponent, JPanel fromPanel) removePanelFromPanel removes a specific Component from another panel fromPanel.remove(removeComponent); fromPanel.revalidate(); fromPanel.repaint(); |