List of usage examples for javax.swing JPanel add
public Component add(Component comp)
From source file:Main.java
public static JComponent makeUI() { JPanel p = new JPanel(); p.setBackground(new Color(.5f, .5f, .5f, .5f)); p.add(new JComboBox<String>(new String[] { "aaa", "bb", "c" })); JComboBox c = new JComboBox<String>(new String[] { "aaa", "bb", "c" }); p.add(c);/*from w ww . j a v a 2 s.c om*/ return p; }
From source file:Main.java
public static JPanel addToFlowLayout(JComponent comp, int flowLayoutAlignment) { JPanel panel = new JPanel(new FlowLayout(flowLayoutAlignment)); panel.add(comp); return panel; }
From source file:DialogBlockingExample.java
public static JPanel createPanel() { JPanel panel = new JPanel(); JButton button = new JButton(new DialogAction(panel)); panel.add(button); return panel; }
From source file:QandE.Layout2.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread./*from ww w . ja v a 2 s . c om*/ */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("Layout2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Add the innards. JPanel p = new JPanel(new GridLayout(1, 0)); p.add(createComponent("Component 1")); p.add(createComponent("Component 2")); p.add(createComponent("Component 3")); p.add(createComponent("Component 4")); //p.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); frame.setContentPane(p); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void addTo(JPanel panel, JComponent lhs, JComponent rhs) { panel.add(lhs); panel.add(rhs); }
From source file:Main.java
private static JPanel createPanel() { JPanel panel = new JPanel(); final JLabel label = new JLabel(new Date().toString()); panel.add(label); panel.addAncestorListener(new AncestorListener() { @Override/*from w w w .j a v a2s . com*/ public void ancestorAdded(AncestorEvent event) { // start animation label.setText(new Date().toString()); } @Override public void ancestorRemoved(AncestorEvent event) { // stop animation } @Override public void ancestorMoved(AncestorEvent event) { } }); return panel; }
From source file:Main.java
/** * Creates a <code>JTextField</code> with the specified text as a label * appearing before the text field.//from w ww . j a va 2 s.co m * @param label - the text to appear in front of the text field * @param length - the length in columns of the text field * @return a <code>JPanel</code> with the labeled text field as the only element */ public static JPanel createLabeledTextField(String label, int length) { JPanel labeledTextBox = new JPanel(); JLabel l = new JLabel(label); labeledTextBox.add(l); JTextField text = new JTextField(length); labeledTextBox.add(text); return labeledTextBox; }
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); }/*w w w . j a v a 2 s .c o m*/ return pan; }
From source file:QandE.Layout3.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread.// ww w .j a v a2 s . c o m */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("Layout3"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Add the innards. JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); p.add(createComponent("Component 1")); p.add(Box.createVerticalGlue()); p.add(createComponent("Component 2")); p.add(createComponent("Component 3")); p.add(createComponent("Component 4")); frame.setContentPane(p); //Display the window. frame.pack(); frame.setVisible(true); }
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); }/*from w ww . ja va 2 s . c om*/ return pane; }