The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing  [141 examples] > Layout  [5 examples]

e851. Separating Components in a Row or Column

    Box box = new Box(BoxLayout.X_AXIS);
    
    // Glue spreads the components as far apart as possible.
    box.add(component1);
    box.add(Box.createGlue());
    box.add(component2);
    
    // Strut spreads the components apart by a fixed distance.
    int width = 10;
    box.add(Box.createHorizontalStrut(width));
    box.add(component3);

 Related Examples
e850. Laying Out Components in a Row or Column
e852. Laying Out Components in a Flow (Left-to-Right, Top-to-Bottom)
e853. Laying Out Components in a Grid
e854. Laying Out Components Using Absolute Coordinates

See also: Actions    JButton    JCheckBox    JComboBox    JDesktop and JInternalFrame    JFrame, JWindow, JDialog    JLabel    JList    JProgressBar    JRadioButton    JScrollPane    JSlider    JSpinner    JSplitPane    JTabbedPane    JToolBar    Keystrokes and Input Maps    Look and Feel    Menus    Progress Monitor    The Screen    Tool Tips    UI Default Values   


© 2002 Addison-Wesley.