Java Box create vertical glue

Description

Java Box create vertical glue

import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame("BoxLayout with Glue");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Container contentPane = frame.getContentPane();
        Box hBox = Box.createVerticalBox();
        hBox.add(new JButton("<<First"));
        hBox.add(new JButton("<Previous"));
        hBox.add(Box.createVerticalGlue());
        hBox.add(new JButton("Next>"));
        hBox.add(new JButton("Last>>"));

        contentPane.add(hBox, BorderLayout.SOUTH);
        frame.pack();//from   w  w w .java  2 s.com
        frame.setVisible(true);
    }
}



PreviousNext

Related