    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

- When the button is pressed, its shadows are reversed to display a "pushed" appearance.
- If the button is pressed and the mouse is dragged outside the button, the button will be displayed as normal, ie the press is cancelled.
- If the mouse is pressed and then released within the button, the button is activated (ie an event is generated).
- If the RETURN or space key is hit, the button is momentarily displayed as pressed. This is equivalent to clicking it.

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

##

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

##

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

##

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

##

old_shadowtype

      protected int old_shadowtype

actionListeners

      protected JCVector actionListeners

  List of action listeners

buttonListeners

      protected JCVector buttonListeners

  List of JCButtonEvent listeners

arm_offset

      protected int arm_offset

  Amount that the label is drawn offset when the button is pressed.

##

JCButton

      public JCButton()

  Creates an empty button. No parameters are read from an HTML file.

JCButton

      public JCButton(Object label)

  Creates a button with the specified label. No parameters are read from an HTML file.

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

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

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

##

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

getArmLabel

      public Object getArmLabel()

  Gets the button's ArmLabel.

  See Also:
    setArmLabel

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

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.

getActionCommand

      public String getActionCommand()

  Returns the command name of the action event fired by this button.

  See Also:
    setActionCommand

addActionListener

      public void addActionListener(JCActionListener l)

  Adds the specified action listener to receive action events from this button.

  See Also:
    JCActionEvent

removeActionListener

      public void removeActionListener(JCActionListener l)

  Removes the specified action listener so it no longer receives action events from this button.

  See Also:
    addActionListener

addButtonListener

      public void addButtonListener(JCButtonListener l)

  Adds the specified JCButtonEvent listener to receive arm/disarm events.

  See Also:
    JCButtonEvent

removeButtonListener

      public void removeButtonListener(JCButtonListener l)

  Removes the specified listener so it no longer receives JCButtonEvents from this button.

  See Also:
    addButtonListener

armAction

      public void armAction(Event ev)

  Displays the button as armed (reversed top and bottom shadow colors), and posts a JCButtonEvent.

  See Also:
    addButtonListener

disarmAction

      public void disarmAction(Event ev)

  Paints the button with its normal appearance, and posts a JCButtonEvent

  See Also:
    @addButtonListener

clickAction

      public void clickAction(Event ev)

  Posts an JCActionEvent.

  See Also:
    addActionListener, JCActionEvent

layout

      public synchronized void layout()

  Lays out the label's internal elements.

  Overrides:
    layout in class JCLabel

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

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

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

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

mouseDown

      public boolean mouseDown(Event ev,
                               int x,
                               int y)

  Calls armAction if btn1 was pressed.

  Overrides:
    mouseDown in class JCComponent
  See Also:
    armAction

mouseUp

      public boolean mouseUp(Event ev,
                             int x,
                             int y)

  If the cursor is within the button, calls clickAction, disarmAction.

  Overrides:
    mouseUp in class JCLabel
  See Also:
    clickAction, disarmAction

keyDown

      public boolean keyDown(Event ev,
                             int key)

  If key is space or RETURN, calls armAction, clickAction, disarmAction.

  Overrides:
    keyDown in class Component
  See Also:
    armAction, clickAction, disarmAction

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

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