|
All Methods zio package context |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object zio.ZWindow
ZWindow
s are top level windows known to the
operating system. Here is an example program that creates and displays
a window containing a red square.
public static void main( String [] junk) { ZWindow g = new ZWindow( "Red Box", new ZBox() .color(Color.RED).size(new Dimension(100,100)) ); }
Here is an example with two squares appearing in a row.
public static void main( String [] junk) { Dimension d = new Dimension(100,100); ZWindow g = new ZWindow( "Red Box", new ZRow( new ZBox().color(Color.RED).size(d), new ZBox().color(Color.BLUE).size(d) ) ); }
Replace ZRow
with ZCol
to get a column of squares.
ZRow
s and ZCol
s are called slices. Layout management
is handled by placing slices within slices.
When there are multiple windows on the screen they will be placed at
different locations. When a single window works out to be too big
for the screen, all its components are downsized. This downsizing
is seldom pretty but it will let you see relative sizes. To see
the exact calculated size (that is before any downsizing) of
any component ZObject
, use a debug()
suffix on that
ZObject
. (See
the "about slices" reference below for an explanation of what
suffixes are.)
Unless a program does something to explicitly
cease execution, it will run until the user closes the last visible
window. The preferred way of stopping your program is to invoke
Zio.stop()
.
Imports for Both Examples:
import java.awt.*; // for the Color and Dimension classes
import zio.*;
Fine Print for the First Example:
The red square is created as a ZBox
whose
width and height are both 100 pixels. The window
shows "Red Box" in the title bar. The window (and all windows created
with the zio package), will have expanding margins on all sides. These
margins start out at zero width so you won't see them unless you
expand the window. You will see the red square because all zio windows
rigidly enforce a minimum size.
Fine Print for the Second Example:
Here, the zero sized horizontal margins are replaced with the
One Gotcha: Do not put the same
ZRow
's margins. The minimum
size of white space in a ZRow
is not 0 but can
be adjusted.
ZObject
two
places in a window or windows.
Licensed under the Open Software License version 2.1
Constructor Summary
ZWindow(java.lang.String title,
ZObject gui)
In cooperation with operating system, creates a top level window.
ZWindow(java.lang.String title,
ZObject gui,
boolean visible)
In cooperation with operating system, creates a top level window.
Method Summary
void
closeWindow()
Closes window.
protected void
epilog()
This is invoked when a window closes (by the user or thru
closeWindow()
).
void
fullScreen()
Makes window's minimum size full_screen.
void
hide()
Makes the window invisible so
a user will see no trace of it.
static void
setBackgroundColor(java.awt.Color bg)
Defunct.
static void
setForegroundColor(java.awt.Color fg)
Defunct.
void
setLocation(int x,
int y)
Moves the window.
void
setMenuBar(javax.swing.JMenuBar menuBar)
Sets the window's menubar.
void
show()
Makes the window visible.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ZWindow
public ZWindow(java.lang.String title,
ZObject gui)
ZObject
. Use ZRow
and ZCol
to populate windows with multiple objects.
title
- the window's titlegui
- any ZObject
ZWindow
public ZWindow(java.lang.String title,
ZObject gui,
boolean visible)
ZObject
. Use ZRow
and ZCol
to populate windows with multiple objects.
title
- the window's titlegui
- any ZObjectvisible
- true iff the window is to be visible when created
Method Detail
closeWindow
public final void closeWindow()
setForegroundColor
public static final void setForegroundColor(java.awt.Color fg)
Zio.setForegroundColor()
setBackgroundColor
public static final void setBackgroundColor(java.awt.Color bg)
Zio.setBackgroundColor()
.
hide
public final void hide()
show()
.
hide()
has no effect if only one
window is visible. We keep one window
on the screen (perhaps buried by other
windows) to give the user the
ability to stop the program by
closing the last window.
show
public final void show()
hide()
.
setLocation
public final void setLocation(int x,
int y)
setLocation(0,0)
would put
the window in upper left of the screen.
x
- horizontal coordinate, positive direction is to lefty
- vertical coordinate, positive direction is downward
fullScreen
public final void fullScreen()
setMenuBar
public final void setMenuBar(javax.swing.JMenuBar menuBar)
epilog
protected void epilog()
closeWindow()
).
Override it in a subclass if you want anything to happen.
Package
Class
Tree
Deprecated
Index
Help
author
context
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD