Class GWin
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----GWin
- public class GWin
- extends Panel
This creates a window with one component, a Panel (this object),
and resizes and shows it. The close box works, and keypresses
on the title bar are passed through to the Panel. The paint()
and handleEvent() methods should be overridden. The overridden
paint() method should start with a call to super.paint(). To resize the
window, set preferredSize, then call layout().
This code contains numerous hacks to overcome Java bugs.
The goal was to ensure that on multiple platforms (or
at least for both JDK1.0-Win95 and Netscape NN30b5a), the Panel
would automatically expand to fill at least most of
the window when the user resized the window, the setSize()
method would resize the window such that the best-fitting
Panel would be EXACTLY the requested size, and every paint
would match the Panel size exactly.
This code is (c) 1996 Leemon Baird
<leemon@cs.cmu.edu>,
http://www.cs.cmu.edu/~baird
The source and object code may be redistributed freely.
If the code is modified, please state so in the comments.
- Version:
- 1.1 13 Feb 97
- Author:
- Leemon Baird
-
applet
- the applet holding every embedded GWin
-
buttonPanel
- the panel holding the button that toggles embedding
-
buttons
- a panel holding the button panel
-
embedButton
- the button toggling embedding on the Web page vs.
-
embedPanel
- the panel containing this Panel and the embed button, # button, and menus
-
menubar
- the menus that should attach to a window containing this GWin
-
preferredSize
- The size to make this window when layout() is called
-
startHeight
- the starting Height of the window
-
startSize
- The original size of this Panel at the start
-
startWidth
- the starting width of the window
-
startX
- the starting column of the window
-
startY
- the starting row of the window
-
watchButton
- the button that brings up a window of everything watched here
-
window
- the actual window holding this Panel object
-
GWin()
-
-
addMenus(MenuBar)
- Override this to give a GWin menus.
-
closeWindow()
- close the window and destroy all threads, Graphics contexts, etc.
-
createWin(int, int, int, int, Applet, boolean)
- create a graphics window with upper-left corner at (x,y),
and the graphics area of size (width,height).
-
destroy()
- This is called when the user closes the window.
-
fHeight()
- Return the font height
-
height()
- height of graphics area in the window (not including title bar)
-
menuToChoice(MenuBar)
- convert a menubar into an equivalent Panel filled with
a Choice corresponding to each menu.
-
MinimumSize()
- return the size this window prefers
-
paint(Graphics)
- Paint the region of size (bounds().width,bounds().height),
and corner at (0,0).
-
preferredSize()
- return the size this window prefers
-
width()
- width of graphics area in the window (not including title bar)
-
x()
- x coordinate of upper-left corner of whole window (including title)
-
y()
- y coordinate of upper-left corner of whole window (including title)
preferredSize
protected Dimension preferredSize
- The size to make this window when layout() is called
startSize
protected Dimension startSize
- The original size of this Panel at the start
window
public ClosableWin window
- the actual window holding this Panel object
embedPanel
public EmbedPanel embedPanel
- the panel containing this Panel and the embed button, # button, and menus
embedButton
public Button embedButton
- the button toggling embedding on the Web page vs. separate window
watchButton
public Button watchButton
- the button that brings up a window of everything watched here
applet
public Applet applet
- the applet holding every embedded GWin
buttonPanel
public Panel buttonPanel
- the panel holding the button that toggles embedding
buttons
public Panel buttons
- a panel holding the button panel
startX
public int startX
- the starting column of the window
startY
public int startY
- the starting row of the window
startWidth
public int startWidth
- the starting width of the window
startHeight
public int startHeight
- the starting Height of the window
menubar
public MenuBar menubar
- the menus that should attach to a window containing this GWin
GWin
public GWin()
paint
public void paint(Graphics g)
- Paint the region of size (bounds().width,bounds().height),
and corner at (0,0). This method should be overridden,
but the new method should still call window.layout() first,
and should assume the region to draw starts at (0,0) and
is of size (width(),height()).
- Overrides:
- paint in class Container
closeWindow
public void closeWindow()
- close the window and destroy all threads, Graphics contexts, etc.
fHeight
public int fHeight()
- Return the font height
addMenus
public void addMenus(MenuBar mb)
- Override this to give a GWin menus. Menus are only visible
when it's a separate window, not when embedded in the
Web page. The menus should be added to mb.
createWin
public void createWin(int x,
int y,
int width,
int height,
Applet app,
boolean embed)
- create a graphics window with upper-left corner at (x,y),
and the graphics area of size (width,height). If embed==true,
meaning the GWin should be embedded in the web page,
then it sets the preferred size of this Panel, but doesn't
actually create a new window. To add menus to a GWin window,
override addMenus().
menuToChoice
public Panel menuToChoice(MenuBar mb)
- convert a menubar into an equivalent Panel filled with
a Choice corresponding to each menu.
destroy
public void destroy()
- This is called when the user closes the window. Override it
to react to that event (e.g. kill threads, dispose of Graphics, unregister watches)
preferredSize
public Dimension preferredSize()
- return the size this window prefers
- Overrides:
- preferredSize in class Container
MinimumSize
public Dimension MinimumSize()
- return the size this window prefers
x
public int x()
- x coordinate of upper-left corner of whole window (including title)
y
public int y()
- y coordinate of upper-left corner of whole window (including title)
width
public int width()
- width of graphics area in the window (not including title bar)
height
public int height()
- height of graphics area in the window (not including title bar)