Without layout manager, we position components using absolute values. : No Layout « Swing « Java Tutorial






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

public class Absolute {
  public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setLayout(null);

    JButton ok = new JButton("OK");
    ok.setBounds(50, 150, 80, 25);

    JButton close = new JButton("Close");
    close.setBounds(150, 150, 80, 25);

    f.add(ok);
    f.add(close);

    f.setSize(300, 250);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }
}








14.98.No Layout
14.98.1.No LayoutManager: Absolute positioningNo LayoutManager: Absolute positioning
14.98.2.Z OrderZ Order
14.98.3.Without layout manager, we position components using absolute values.
14.98.4.Laying Out Components Using Absolute Coordinates