01: package net.xoetrope.xui;
02:
03: import java.awt.Container;
04: import java.awt.Dimension;
05: import java.awt.BorderLayout;
06: import java.awt.Graphics;
07:
08: /**
09: * When using framesets the 'screen' is devided up into a number of different
10: * target areas. Each target area may contain a page. The content for each
11: * target area is set by naming the target area when calling displayPage. This
12: * class provides support for this behaviour by wrapping the Container class to
13: * ensure the target area is properly sized. How the target areas are actually
14: * laid out depends on the layout manager being used.
15: * <p>Copyright: Copyright (c) Xoetrope Ltd., 2002-2003</p>
16: * $Revision: 1.17 $
17: */
18: public class XTarget extends Container {
19: private Dimension prefSize, minSize;
20: private Object currentScreen;
21:
22: /**
23: * Setup a new target area and set its size
24: * @param width the width
25: * @param height the height
26: */
27: public XTarget(String name, int width, int height) {
28: setName(name);
29: setSize(width, height);
30: if ((width != 0) && (height != 0)) {
31: prefSize = new Dimension(width, height);
32: minSize = new Dimension(width, height);
33: } else {
34: prefSize = null;
35: minSize = null;
36: }
37: setLayout(new BorderLayout());
38: }
39:
40: /**
41: * Get the preferred size of the target area. If zero width and height were
42: * specified this method returns the default size, otherwise it returns a
43: * dimension with the specified width and height.
44: * @return the size
45: */
46: public Dimension getPreferredSize() {
47: return (prefSize != null ? prefSize : super .getPreferredSize());
48: }
49:
50: /**
51: * Set the preferred size for this target area
52: * @param d the new size
53: */
54: public void setPreferredSize(Dimension d) {
55: prefSize = d;
56: }
57:
58: /**
59: * Get the minimum size of the target area. If zero width and height were
60: * specified this method returns the default size, otherwise it returns a
61: * dimension with the specified width and height.
62: * @return the size
63: */
64: public Dimension getMinimumSize() {
65: return (minSize != null ? minSize : super .getMinimumSize());
66: }
67:
68: /**
69: * Update the target by repainting
70: * @param g the graphics context
71: */
72: public void update(Graphics g) {
73: paint(g);
74: }
75: }
|