Example usage for javax.swing Box createVerticalBox

List of usage examples for javax.swing Box createVerticalBox

Introduction

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

Prototype

public static Box createVerticalBox() 

Source Link

Document

Creates a Box that displays its components from top to bottom.

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:Main.java

public Main() {
    Box box1 = Box.createVerticalBox();
    for (int i = 1; i <= 100; i++) {
        box1.add(new JLabel("This is Label #" + i));
    }//from  ww  w .j a v  a 2s. c o  m

    Box box2 = Box.createVerticalBox();
    for (int i = 1; i <= 100; i++) {
        box2.add(new JLabel("This is Label #" + i));
    }

    JPanel boxPanel1 = new JPanel();
    JPanel boxPanel2 = new JPanel();
    boxPanel1.add(box1);
    boxPanel2.add(box2);
    JScrollPane panel1Scroll = new JScrollPane(boxPanel1);
    JScrollPane panel2Scroll = new JScrollPane(boxPanel2);

    panelTab1 = new JPanel(new BorderLayout());
    panelTab2 = new JPanel(new BorderLayout());
    panelTab1.add(panel1Scroll);
    panelTab2.add(panel2Scroll);

    tabbedPane = new JTabbedPane();
    tabbedPane.add(panelTab1, "Panel 1");
    tabbedPane.add(panelTab2, "Panel 2");

    JFrame frame = new JFrame();
    frame.add(tabbedPane);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

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);/*w  w w. j  ava  2s. c om*/
    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());//w ww. j a v  a  2s .com
    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());
    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:Main.java

public Main() {
    super(BoxLayout.Y_AXIS);

    Box info = Box.createVerticalBox();
    info.add(new Label("Please wait 3 seconds"));
    final JButton continueButton = new JButton("Continue");
    info.add(continueButton);//from  w  w w. j  av  a 2  s .  c  om

    JDialog d = new JDialog();
    d.setModalityType(ModalityType.APPLICATION_MODAL);
    d.setContentPane(info);
    d.pack();

    continueButton.addActionListener(e -> d.dispose());
    continueButton.setVisible(false);

    SwingWorker sw = new SwingWorker<Integer, Integer>() {
        protected Integer doInBackground() throws Exception {
            int i = 0;
            while (i++ < 30) {
                System.out.println(i);
                Thread.sleep(100);
            }
            return null;
        }

        @Override
        protected void done() {
            continueButton.setVisible(true);
        }

    };
    JButton button = new JButton("Click Me");
    button.addActionListener(e -> {
        sw.execute();
        d.setVisible(true);
    });
    add(button);
}

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 w ww  .  ja  v  a2s.  co  m
    getContentPane().add(bv);
}

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));
    }// w ww. j  a  v  a  2 s. c o 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);
}

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:Main.java

public Main() {
    super("Demostrating BoxLayout");
    final int SIZE = 3;
    Container c = getContentPane();
    c.setLayout(new BorderLayout(30, 30));

    Box boxes[] = new Box[4];

    boxes[0] = Box.createHorizontalBox();
    boxes[1] = Box.createVerticalBox();
    boxes[2] = Box.createHorizontalBox();
    boxes[3] = Box.createVerticalBox();

    for (int i = 0; i < SIZE; i++)
        boxes[0].add(new JButton("boxes[0]: " + i));

    for (int i = 0; i < SIZE; i++) {
        boxes[1].add(Box.createVerticalStrut(25));
        boxes[1].add(new JButton("boxes[1]: " + i));
    }/*from w w  w  .j  a  v  a2 s .  c  om*/

    for (int i = 0; i < SIZE; i++) {
        boxes[2].add(Box.createHorizontalGlue());
        boxes[2].add(new JButton("boxes[2]: " + i));
    }

    for (int i = 0; i < SIZE; i++) {
        boxes[3].add(Box.createRigidArea(new Dimension(12, 8)));
        boxes[3].add(new JButton("boxes[3]: " + i));
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    for (int i = 0; i < SIZE; i++) {
        panel.add(Box.createGlue());
        panel.add(new JButton("panel: " + i));
    }

    c.add(boxes[0], BorderLayout.NORTH);
    c.add(boxes[1], BorderLayout.EAST);
    c.add(boxes[2], BorderLayout.SOUTH);
    c.add(boxes[3], BorderLayout.WEST);
    c.add(panel, BorderLayout.CENTER);

    setSize(350, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

}

From source file:Main.java

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

    genderGroup.add(genderMale);/*from  w  ww  .  ja v a2 s  .co 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);
}