home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.CardLayout;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.FlowLayout;
- import java.awt.GridLayout;
- import java.awt.LayoutManager;
- import java.awt.Panel;
-
- class CardPanel extends Panel {
- public Dimension preferredSize() {
- return new Dimension(200, 100);
- }
-
- CardPanel() {
- ((Container)this).setLayout(new CardLayout());
- ((Container)this).add("one", this.create(new FlowLayout()));
- ((Container)this).add("two", this.create(new BorderLayout()));
- ((Container)this).add("three", this.create(new GridLayout(2, 2)));
- ((Container)this).add("four", this.create(new BorderLayout(10, 10)));
- ((Container)this).add("five", this.create(new FlowLayout(0, 10, 10)));
- ((Container)this).add("six", this.create(new GridLayout(2, 2, 10, 10)));
- }
-
- Panel create(LayoutManager layout) {
- Panel p = new Panel();
- ((Container)p).setLayout(layout);
- ((Container)p).add("North", new Button("one"));
- ((Container)p).add("West", new Button("two"));
- ((Container)p).add("South", new Button("three"));
- ((Container)p).add("East", new Button("four"));
- ((Container)p).add("Center", new Button("five"));
- return p;
- }
- }
-