public class FlowLayoutDemo extends JFrame
1:
2: import javax.swing.JFrame;
3: import javax.swing.JLabel;
4: import java.awt.Container;
5: import java.awt.FlowLayout;
6:
7: /**
8: Simple demonstration of using a layout manager to arrange labels.
9: */
10: public class FlowLayoutDemo extends JFrame
11: {
12: public static final int WIDTH = 300;
13: public static final int HEIGHT = 200;
14:
15: /**
16: Creates and displays a window of the class FlowLayoutDemo.
17: */
18: public static void main(String[] args)
19: {
20: FlowLayoutDemo gui = new FlowLayoutDemo();
21: gui.setVisible(true);
22: }
23:
24: public FlowLayoutDemo()
25: {
26: setSize(WIDTH, HEIGHT);
27: addWindowListener(new WindowDestroyer());
28: setTitle("Layout Demonstration");
29: Container content = getContentPane();
30: content.setLayout(new FlowLayout());
31:
32: JLabel label1 = new JLabel("First label here.");
33: content.add(label1);
34:
35: JLabel label2 = new JLabel("Second label there.");
36: content.add(label2);
37:
38: JLabel label3 = new JLabel("Third label anywhere.");
39: content.add(label3);
40: }
41: }
42:
43:
44:
45: