Java examples for Swing:BoxLayout
Box class can create invisible components and add them to a box to adjust spacing between two components.
Box class provides four types of invisible components:
A glue is an invisible, expandable component.
import javax.swing.Box; import javax.swing.JButton; public class Main { public static void main(String[] argv) throws Exception { Box hBox = Box.createHorizontalBox(); hBox.add(new JButton("First")); hBox.add(Box.createHorizontalGlue()); hBox.add(new JButton("Last")); } }