List of usage examples for javax.swing JPanel JPanel
public JPanel(boolean isDoubleBuffered)
JPanel
with FlowLayout
and the specified buffering strategy. From source file:Main.java
private static JPanel createPanel(LayoutManager layout) { return new JPanel(layout); }
From source file:Main.java
public static JPanel newPane(String labelText) { JPanel pane = new JPanel(new BorderLayout()); pane.add(newLabel(labelText));/* w w w. j a v a 2s. c o m*/ pane.add(newButton("Open dialog"), BorderLayout.SOUTH); return pane; }
From source file:Main.java
public static JPanel createVertical(final Component... components) { final JPanel jp = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0;/* w w w. j a v a2 s. co m*/ gbc.gridy = 0; gbc.insets = new Insets(0, 5, 4, 5); gbc.anchor = GridBagConstraints.NORTH; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; for (final Component component : components) { if (gbc.gridy == components.length - 1) { gbc.weighty = 1.0; } jp.add(component, gbc); gbc.gridy++; } return jp; }
From source file:Main.java
public static JPanel makeButtonBar(int align, Component... comps) { JPanel pan = new JPanel(new FlowLayout(align)); for (Component component : comps) { pan.add(component);//ww w . j a v a 2s . c om } return pan; }
From source file:Main.java
public static JPanel createVerticalPanel(Component[] cms, int vgap) { JPanel pane = new JPanel(new GridLayout(cms.length, 1, 0, vgap)); for (Component c : cms) { pane.add(c);/* w w w . j a va 2 s . c om*/ } return pane; }
From source file:Main.java
public static JPanel placeInTitledEtchedJPanel(Component c, String title, Color titleColor) { JPanel parent = new JPanel(new BorderLayout()); parent.add(c, BorderLayout.CENTER); TitledBorder tb = new TitledBorder(title); tb.setBorder(BorderFactory.createEtchedBorder()); tb.setTitleColor(titleColor);//from w w w. j av a2s . com parent.setBorder(tb); return parent; }
From source file:MainClass.java
public static JPanel demo1() { JPanel pan = new JPanel(new BorderLayout()); pan.setBorder(new TitledBorder("Demo 1: format toggles with focus")); MaskFormatter withFocus = null, withoutFocus = null; try {/*w ww . j ava 2 s . co m*/ withFocus = new MaskFormatter("LLLL"); withoutFocus = new MaskFormatter("UUUU"); } catch (ParseException pe) { } DefaultFormatterFactory factory = new DefaultFormatterFactory(withoutFocus, null, withFocus); JFormattedTextField field = new JFormattedTextField(factory); field.setValue("Four"); pan.add(field, BorderLayout.CENTER); return pan; }
From source file:RadioButtonUtils.java
public static Container createRadioButtonGrouping(String elements[], String title) { JPanel panel = new JPanel(new GridLayout(0, 1)); if (title != null) { Border border = BorderFactory.createTitledBorder(title); panel.setBorder(border);//from www . ja v a2s . com } ButtonGroup group = new ButtonGroup(); JRadioButton aRadioButton; for (int i = 0, n = elements.length; i < n; i++) { aRadioButton = new JRadioButton(elements[i]); panel.add(aRadioButton); group.add(aRadioButton); } return panel; }
From source file:Main.java
private static JPanel getPanel() { JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("Top"), BorderLayout.NORTH); panel.add(new JLabel("Center"), BorderLayout.CENTER); panel.add(new JLabel("Bottom"), BorderLayout.SOUTH); panel.setPreferredSize(new Dimension(400, 300)); return panel; }
From source file:Main.java
/** * Creates a JPanel containing the component hugging the top side * @param component the component to wrap * @return a JPanel containing the component hugging the top side *//*from w w w.j a v a2s .c o m*/ public static JPanel hugNorth(JComponent component) { final JPanel result = new JPanel(new BorderLayout()); result.add(component, BorderLayout.NORTH); return result; }