Glue spreads the components as far apart as possible. : BoxLayout « Swing JFC « Java






Glue spreads the components as far apart as possible.

  

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;

public class Main {
  public static void main(String[] argv) throws Exception {
    JButton component1 = new JButton();
    JButton component2 = new JButton();
    Box box = new Box(BoxLayout.X_AXIS);

    
    box.add(component1);
    box.add(Box.createGlue());
    box.add(component2);
  }
}

   
    
  








Related examples in the same category

1.Separating Components in a Row or Column
2.Strut spreads the components apart by a fixed distance
3.Laying Out Components in a Row or Column
4.A vertical box container arranges the components top-to-bottom aligned in their preferred sizes.
5.BoxLayout puts components into a row or into a column
6.BoxLayout: set a rigid area among our components.
7.Align your components in horizontal or vertical layout