All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.bwt.JCButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----jclass.bwt.JCComponent
                           |
                           +----jclass.bwt.JCLabel
                                   |
                                   +----jclass.bwt.JCButton

public class JCButton
extends JCLabel
A component that displays a button with multiple lines of read-only text and/or images.

Behavior

Properties

Name Method
Alignment setAlignment
ArmLabel setArmLabel
Background setBackground
DoubleBuffer setDoubleBuffer
Font setFont
Foreground setForeground
HighlightColor setHighlightColor
HighlightThickness setHighlightThickness
Insets setInsets
Label setLabel
PreferredSize setPreferredSize
ShadowThickness setShadowThickness
Traversable setTraversable
UserData setUserData

Events

Class Listener Description
JCActionEvent addActionListener Posted when the button is pressed and then released
JCButtonEvent addButtonListener Posted when the button is pressed and released


Variable Index

 o actionListeners
List of action listeners
 o arm_offset
Amount that the label is drawn offset when the button is pressed.
 o buttonListeners
List of JCButtonEvent listeners
 o old_shadowtype

Constructor Index

 o JCButton()
Creates an empty button.
 o JCButton(Object)
Creates a button with the specified label.
 o JCButton(Object, Applet, String)
Creates a button which reads parameters from the applet's HTML file.
 o JCButton(String, Image, int)
Creates a button with a label constructed from a String and an Image.
 o JCButton(String, String, Applet, int)
Creates a button with a label constructed from a String and an Image file.

Method Index

 o addActionListener(JCActionListener)
Adds the specified action listener to receive action events from this button.
 o addButtonListener(JCButtonListener)
Adds the specified JCButtonEvent listener to receive arm/disarm events.
 o armAction(Event)
Displays the button as armed (reversed top and bottom shadow colors), and posts a JCButtonEvent.
 o clickAction(Event)
Posts an JCActionEvent.
 o disarmAction(Event)
Paints the button with its normal appearance, and posts a JCButtonEvent
 o drawHighlight(Graphics, boolean)
Draws or clears the highlight rectangle (called by paint).
 o drawValue(Graphics, Object)
Draws the button's label or arm label (if it is pressed).
 o getActionCommand()
Returns the command name of the action event fired by this button.
 o getArmLabel()
Gets the button's ArmLabel.
 o getParameters()
Reads the parameter values from the HTML page using the component's applet.
 o keyDown(Event, int)
If key is space or RETURN, calls armAction, disarmAction, clickAction.
 o layout()
Lays out the label's internal elements.
 o mouseDown(Event, int, int)
Calls armAction if btn1 was pressed.
 o mouseEnter(Event, int, int)
If the mouse was pressed and is moved back inside the button, armAction is called.
 o mouseExit(Event, int, int)
If the mouse was pressed and is moved outside the button, disarmAction is called.
 o mouseUp(Event, int, int)
If the cursor is within the button, calls disarmAction, clickAction.
 o preferredHeight()
Returns the label or arm label's height, whichever is larger.
 o preferredWidth()
Returns the label or arm label's width, whichever is larger.
 o removeActionListener(JCActionListener)
Removes the specified action listener so it no longer receives action events from this button.
 o removeButtonListener(JCButtonListener)
Removes the specified listener so it no longer receives JCButtonEvents from this button.
 o setActionCommand(String)
Sets the command name of the action event fired by this button.
 o setArmLabel(Object)
Sets the label that is displayed when the button is pressed.

Variables

 o old_shadowtype
 protected int old_shadowtype
 o actionListeners
 protected JCVector actionListeners
List of action listeners

 o buttonListeners
 protected JCVector buttonListeners
List of JCButtonEvent listeners

 o arm_offset
 protected int arm_offset
Amount that the label is drawn offset when the button is pressed.

Constructors

 o JCButton
 public JCButton()
Creates an empty button. No parameters are read from an HTML file.

 o JCButton
 public JCButton(Object label)
Creates a button with the specified label. No parameters are read from an HTML file.

 o JCButton
 public JCButton(String s,
                 Image image,
                 int layout)
Creates a button with a label constructed from a String and an Image. The label's name is set to the string.

Parameters:
layout - the relative position of the string with respect to the image: BWTEnum.STRING_LEFT, STRING_RIGHT, STRING_TOP or STRING_BOTTOM
 o JCButton
 public JCButton(String s,
                 String image,
                 Applet applet,
                 int layout)
Creates a button with a label constructed from a String and an Image file.

Parameters:
applet - the applet that is loading the image. If the applet is in a browser, Applet.getImage() is used in order to take advantage of Applet.getDocumentBase()
image - the file containing the image to be loaded; if an http protocol is not specified (a ":" is not present), the current document base or working directory is prepended to the file name
layout - the relative position of the string with respect to the image: BWTEnum.STRING_LEFT, STRING_RIGHT, STRING_TOP or STRING_BOTTOM
 o JCButton
 public JCButton(Object label,
                 Applet applet,
                 String name)
Creates a button which reads parameters from the applet's HTML file.

Parameters:
label - the button's label
applet - the applet whose PARAM tags are to be read
name - if this is not null, only parameters preceded by this name are read
See Also:
setLabel, getParameter

Methods

 o getParameters
 protected void getParameters()
Reads the parameter values from the HTML page using the component's applet. The values will override those previously set.

Overrides:
getParameters in class JCLabel
 o getArmLabel
 public Object getArmLabel()
Gets the button's ArmLabel.

See Also:
setArmLabel
 o setArmLabel
 public void setArmLabel(Object v)
Sets the label that is displayed when the button is pressed. This may be a String, JCString, or any object (in which case the object's toString() method is called to obtain a string). If this value is not set, the displayed label is not changed.

HTML param name/value: "ArmLabel"/string

See Also:
JCString, toJCString
 o setActionCommand
 public void setActionCommand(String command)
Sets the command name of the action event fired by this button. By default this will be set to the label of the button.

 o getActionCommand
 public String getActionCommand()
Returns the command name of the action event fired by this button.

See Also:
setActionCommand
 o addActionListener
 public void addActionListener(JCActionListener l)
Adds the specified action listener to receive action events from this button.

See Also:
JCActionEvent
 o removeActionListener
 public void removeActionListener(JCActionListener l)
Removes the specified action listener so it no longer receives action events from this button.

See Also:
addActionListener
 o addButtonListener
 public void addButtonListener(JCButtonListener l)
Adds the specified JCButtonEvent listener to receive arm/disarm events.

See Also:
JCButtonEvent
 o removeButtonListener
 public void removeButtonListener(JCButtonListener l)
Removes the specified listener so it no longer receives JCButtonEvents from this button.

See Also:
addButtonListener
 o armAction
 public void armAction(Event ev)
Displays the button as armed (reversed top and bottom shadow colors), and posts a JCButtonEvent.

See Also:
addButtonListener
 o disarmAction
 public void disarmAction(Event ev)
Paints the button with its normal appearance, and posts a JCButtonEvent

See Also:
@addButtonListener
 o clickAction
 public void clickAction(Event ev)
Posts an JCActionEvent.

See Also:
addActionListener, JCActionEvent
 o layout
 public synchronized void layout()
Lays out the label's internal elements.

Overrides:
layout in class JCLabel
 o drawValue
 protected void drawValue(Graphics gc,
                          Object value)
Draws the button's label or arm label (if it is pressed).

Overrides:
drawValue in class JCLabel
 o drawHighlight
 protected void drawHighlight(Graphics gc,
                              boolean on)
Draws or clears the highlight rectangle (called by paint).

Parameters:
on - if true, draws the highlight rectangle and a dashed rectangle around the label; otherwise clears the rect
Overrides:
drawHighlight in class JCComponent
 o mouseEnter
 public boolean mouseEnter(Event ev,
                           int x,
                           int y)
If the mouse was pressed and is moved back inside the button, armAction is called.

Overrides:
mouseEnter in class Component
See Also:
armAction
 o mouseExit
 public boolean mouseExit(Event ev,
                          int x,
                          int y)
If the mouse was pressed and is moved outside the button, disarmAction is called.

Overrides:
mouseExit in class Component
See Also:
disarmAction
 o mouseDown
 public boolean mouseDown(Event ev,
                          int x,
                          int y)
Calls armAction if btn1 was pressed.

Overrides:
mouseDown in class JCComponent
See Also:
armAction
 o mouseUp
 public boolean mouseUp(Event ev,
                        int x,
                        int y)
If the cursor is within the button, calls disarmAction, clickAction.

Overrides:
mouseUp in class JCLabel
See Also:
clickAction, disarmAction
 o keyDown
 public boolean keyDown(Event ev,
                        int key)
If key is space or RETURN, calls armAction, disarmAction, clickAction.

Overrides:
keyDown in class Component
See Also:
armAction, clickAction, disarmAction
 o preferredWidth
 protected int preferredWidth()
Returns the label or arm label's width, whichever is larger. 1 pixel is added to allow for the label's being drawn offset when the button is armed.

Overrides:
preferredWidth in class JCLabel
 o preferredHeight
 protected int preferredHeight()
Returns the label or arm label's height, whichever is larger. 1 pixel is added to allow for the label's being drawn offset when the button is armed.

Overrides:
preferredHeight in class JCLabel

All Packages  Class Hierarchy  This Package  Previous  Next  Index