public class LayoutDemo extends JFrame
1: import javax.swing.*;
2: import java.awt.*;
3:
4: public class LayoutDemo extends JFrame
5: {
6: public static final int WIDTH = 300;
7: public static final int HEIGHT = 200;
8:
9: public LayoutDemo()
10: {
11: setSize(WIDTH, HEIGHT);
12: addWindowListener(new WindowDestroyer());
13: setTitle("Layout Demonstration");
14: Container contentPane = getContentPane();
15:
16: contentPane.setLayout(new FlowLayout());
17:
18: JLabel label1 = new JLabel("This is label one.");
19: contentPane.add(label1);
20:
21: JLabel label2 = new JLabel("This is label two.");
22: contentPane.add(label2);
23:
24: JLabel label3 = new JLabel("This is label three.");
25: contentPane.add(label3);
26: }
27:
28: public static void main(String[] args)
29: {
30: LayoutDemo gui = new LayoutDemo();
31: gui.setVisible(true);
32: }
33: }