Example usage for javax.swing Box add

List of usage examples for javax.swing Box add

Introduction

In this page you can find the example usage for javax.swing Box add.

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:Main.java

public Main() {
    Box box = Box.createVerticalBox();
    box.add(jbt1);
    box.add(jbt2);
    box.add(jbt3);
    box.add(jbt4);

    add(box);
}

From source file:MainClass.java

public MainClass() {
    Box box = new Box(BoxLayout.Y_AXIS);
    box.add(new JButton("Test button"));
    box.add(new JSlider());
    box.add(new JTextField("Text field with some text", 20));
    box.add(new JButton("Another, bigger button"));

    getContentPane().add(box);//from   w  w w  .  j  av  a  2  s .co m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
}

From source file:Main.java

public Main() {
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);

    genderGroup.add(genderMale);//from  w  ww .  j a v a  2  s  .c  o  m
    genderGroup.add(genderFemale);
    genderGroup.add(genderUnknown);

    Box b1 = Box.createVerticalBox();
    b1.add(genderMale);
    b1.add(genderFemale);
    b1.add(genderUnknown);

    Container contentPane = this.getContentPane();
    contentPane.add(b1, BorderLayout.CENTER);
}

From source file:Main.java

public void init() {
    Box bv = Box.createVerticalBox();
    bv.add(new JButton("Top"));
    bv.add(Box.createRigidArea(new Dimension(120, 90)));
    bv.add(new JButton("Bottom"));
    Box bh = Box.createHorizontalBox();
    bh.add(new JButton("Left"));
    bh.add(Box.createRigidArea(new Dimension(160, 80)));
    bh.add(new JButton("Right"));
    bv.add(bh);//from www. jav  a  2s.c o m
    getContentPane().add(bv);
}

From source file:Main.java

public Main() {
    Box b = Box.createHorizontalBox();
    b.add(new JScrollPane(t1));
    copy.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            t2.setText(t1.getSelectedText());
        }// w  w  w .ja va2 s .c  o m
    });
    b.add(copy);

    t2 = new JTextArea(10, 15);
    t2.setEditable(false);
    b.add(new JScrollPane(t2));

    add(b);
    setSize(425, 200);
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:Main.java

public void init() {
    Box bv = Box.createVerticalBox();
    bv.add(new JLabel("Hello"));
    bv.add(Box.createVerticalGlue());
    bv.add(new JLabel("Applet"));
    bv.add(Box.createVerticalGlue());
    bv.add(new JLabel("World"));
    Box bh = Box.createHorizontalBox();
    bh.add(new JLabel("Hello"));
    bh.add(Box.createHorizontalGlue());
    bh.add(new JLabel("Applet"));
    bh.add(Box.createHorizontalGlue());
    bh.add(new JLabel("World"));
    bv.add(Box.createVerticalGlue());
    bv.add(bh);/*ww  w  . j a  va2  s .co  m*/
    bv.add(Box.createVerticalGlue());
    getContentPane().add(bv);
}

From source file:SimpleAboutDialog.java

public SimpleAboutDialog(JFrame parent) {
    super(parent, "About Dialog", true);

    Box b = Box.createVerticalBox();
    b.add(Box.createGlue());
    b.add(new JLabel("Java source code, product and article"));
    b.add(new JLabel("By Java source and support"));
    b.add(new JLabel("At www.java2s.com"));
    b.add(Box.createGlue());//from w w  w.ja va  2s.c o m
    getContentPane().add(b, "Center");

    JPanel p2 = new JPanel();
    JButton ok = new JButton("Ok");
    p2.add(ok);
    getContentPane().add(p2, "South");

    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            setVisible(false);
        }
    });

    setSize(250, 150);
}

From source file:HBoxWithGlue.java

public HBoxWithGlue() {
    super("Box & Glue Frame");
    setSize(350, 100);/*w  ww  .  ja va  2s  . c o m*/
    Box box = Box.createHorizontalBox();
    setContentPane(box);
    box.add(Box.createHorizontalGlue());
    for (int i = 0; i < 3; i++) {
        Button b = new Button("B" + i);
        box.add(b);
    }
    box.add(Box.createHorizontalGlue());
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);
}

From source file:Box1.java

public void init() {
    Box bv = Box.createVerticalBox();
    for (int i = 0; i < 5; i++)
        bv.add(new JButton("bv " + i));
    Box bh = Box.createHorizontalBox();
    for (int i = 0; i < 5; i++)
        bh.add(new JButton("bh " + i));
    Container cp = getContentPane();
    cp.add(BorderLayout.EAST, bv);
    cp.add(BorderLayout.SOUTH, bh);
}

From source file:Box2.java

public void init() {
    Box bv = Box.createVerticalBox();
    for (int i = 0; i < 5; i++) {
        bv.add(new JButton("bv " + i));
        bv.add(Box.createVerticalStrut(i * 10));
    }//from  ww w  . j ava  2 s.co m
    Box bh = Box.createHorizontalBox();
    for (int i = 0; i < 5; i++) {
        bh.add(new JButton("bh " + i));
        bh.add(Box.createHorizontalStrut(i * 10));
    }
    Container cp = getContentPane();
    cp.add(BorderLayout.EAST, bv);
    cp.add(BorderLayout.SOUTH, bh);
}