blob: c2ab1a9033c66a25213f4592e2f4f2d0385c36af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package gjt;
import java.awt.*;
/**
* CardPanel employs a BorderLayout to lay out North and Center
* panels; extensions of CardPanel must implement
* Component viewSelector(). The component returned from
* Component viewSelector() is centered in the North panel, and
* should contain UI controls that allow selection of the
* component to be displayed in the Center panel.<p>
*
* @version 1.0, Apr 1 1996
* @author David Geary
* @see IconCardPanel
* @see ChoiceCardPanel
* @see gjt.test.ChoiceCardPanelTest
* @see gjt.test.IconCardPanelTest
*/
public abstract class CardPanel extends Panel {
private Panel north, center;
private CardLayout cards;
abstract public Component viewSelector();
public CardPanel() {
center = new Panel();
north = new Panel();
setLayout(new BorderLayout());
center.setLayout(cards = new CardLayout());
north.setLayout (new BorderLayout());
add("North", north);
add("Center", center);
}
public void addNotify() {
super.addNotify();
north.add("Center", viewSelector());
north.add("South", new Separator());
}
protected void addView(String name, Component component) {
center.add(name, component);
}
protected void showView(String name) {
cards.show(center, name);
}
}
|