All Methods
zio package

context

zio
Class ZButton


java.lang.Object

  extended byzio.ZObject

      extended byzio.ZButton


public class ZButton
extends ZObject

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

ZButton


public ZButton(java.lang.String label)
Creates a ZButton.

Parameters:
label - the button's label;
Method Detail

background


public final ZButton background(java.awt.Color c)
Suffix that determines the background color.

Parameters:
c - the desired color

foreground


public final ZButton foreground(java.awt.Color c)
Suffix that sets the foreground color. The foreground color is the color of the text.

Parameters:
c - the desired color

debug


public final ZButton debug(java.lang.String debugId)
Suffix that creates debug output.

Parameters:
debugId - a string to identify this component in the debug output

setFont


public final ZButton setFont(java.awt.Font f)
Suffix which sets the font the label will appear in.

Parameters:
f - the desired font

pointSize


public final ZButton pointSize(int pointSize)
Suffix which alters the point size of the font.

Parameters:
pointSize - the desired point size

minSize


public final ZButton minSize(java.awt.Dimension minSize)
Suffix that sets the minimum size. This suffix adjusts the amount of screen real estate that the 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.

Parameters:
minSize - the desired minimum size

enable


public final void enable()
Enables the button. By default button is enabled. If disable() has executed, this sets things back to normal.


disable


public final void disable()
Disables the button. By default button is enabled. This will cause button to appear inactive and also refuse to be clicked. Use enable() to put button back in its original state.


action


protected void action()
This action is invoked whenever an enabled button is clicked. In this base class it does nothing. Create a subclass and override this method to makey a kind of button that respond to the user in a whatever particular way you have in mind.


author
context