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.2 23 June 1998
- Author:
- Leemon Baird
-
applet
- the applet holding every embedded GWin
-
EMBED_MENU_ITEM
-
-
embedPanel
- the panel containing this GWin and the menu bar
-
menubar
- the menus that should attach to a window containing this GWin
-
menuBarPanel
- the panel acting like a menubar at the top
-
PANE_MENU
-
-
preferredSize
- The size to make this window when layout() is called
-
SAVE_GIF_MENU_ITEM
-
-
SAVE_PS_BITMAP_MENU_ITEM
-
-
SAVE_PS_MENU_ITEM
-
-
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
-
UNEMBED_MENU_ITEM
-
-
WATCH_MENU_ITEM
-
-
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)
-
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)
PANE_MENU
public static final String PANE_MENU
WATCH_MENU_ITEM
public static final String WATCH_MENU_ITEM
EMBED_MENU_ITEM
public static final String EMBED_MENU_ITEM
UNEMBED_MENU_ITEM
public static final String UNEMBED_MENU_ITEM
SAVE_GIF_MENU_ITEM
public static final String SAVE_GIF_MENU_ITEM
SAVE_PS_MENU_ITEM
public static final String SAVE_PS_MENU_ITEM
SAVE_PS_BITMAP_MENU_ITEM
public static final String SAVE_PS_BITMAP_MENU_ITEM
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 GWin and the menu bar
applet
public Applet applet
- the applet holding every embedded GWin
menuBarPanel
public Panel menuBarPanel
- the panel acting like a menubar at the top
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. 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().
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)