|
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.ZObject zio.ZButton
Implements a onscreen clickable button. To use this
class effectively, you must subclass it and override
the action()
method. Here is an example with
two buttons whose sole function is to disable themselves
while enabling the other.
import zio.*; public class TwoButtons { public static void main( String [] ignore ) { PassTheBuck b1 = new PassTheBuck("not me"); PassTheBuck b2 = new PassTheBuck("me either"); b1.introduce(b2); b2.introduce(b1); b2.disable(); new ZWindow( "Pass the Buck", new ZCol( b1, b2 ).uniform() ); } } class PassTheBuck extends ZButton { private ZButton theOtherGuy; public PassTheBuck( String label ) { super(label); } public void introduce( ZButton other ) { theOtherGuy = other; } protected void action() { theOtherGuy.enable(); disable(); } }
This example is a bit unusual. In practice you probably will
want a separate subclass for every button. The use of
the uniform()
suffix on the column, however, is not
unusual. This is the way to get all the buttons in a column
(or in a row) to be a uniform size.
Constructor Summary | |
ZButton(java.lang.String label)
Creates a ZButton . |
Method Summary | |
protected void |
action()
This action is invoked whenever an enabled button is clicked. |
ZButton |
background(java.awt.Color c)
Suffix that determines the background color. |
ZButton |
debug(java.lang.String debugId)
Suffix that creates debug output. |
void |
disable()
Disables the button. |
void |
enable()
Enables the button. |
ZButton |
foreground(java.awt.Color c)
Suffix that sets the foreground color. |
ZButton |
minSize(java.awt.Dimension minSize)
Suffix that sets the minimum size. |
ZButton |
pointSize(int pointSize)
Suffix which alters the point size of the font. |
ZButton |
setFont(java.awt.Font f)
Suffix which sets the font the label will appear in. |
Methods inherited from class zio.ZObject |
getSize |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ZButton(java.lang.String label)
ZButton
.
label
- the button's label;Method Detail |
public final ZButton background(java.awt.Color c)
c
- the desired colorpublic final ZButton foreground(java.awt.Color c)
c
- the desired colorpublic final ZButton debug(java.lang.String debugId)
debugId
- a string to identify this component
in the debug outputpublic final ZButton setFont(java.awt.Font f)
f
- the desired fontpublic final ZButton pointSize(int pointSize)
pointSize
- the desired point sizepublic final ZButton minSize(java.awt.Dimension minSize)
ZButton
object will fill. The actual Dimension
allowed
is obtained by taking the largest width and height
found the initial text or the minimum size, if any.
minSize
- the desired minimum sizepublic final void enable()
disable()
has executed,
this sets things back to normal.
public final void disable()
enable()
to put button back
in its original state.
protected void action()
|
author context |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |