com.jmex.bui
Class BButton

java.lang.Object
  extended by com.jmex.bui.BComponent
      extended by com.jmex.bui.BTextComponent
          extended by com.jmex.bui.BLabel
              extended by com.jmex.bui.BButton
All Implemented Interfaces:
BConstants
Direct Known Subclasses:
BToggleButton

public class BButton
extends BLabel
implements BConstants

Displays a simple button that can be depressed and which generates an action event when pressed and released.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jmex.bui.BLabel
BLabel.Fit
 
Field Summary
protected  String _action
           
protected  boolean _armed
           
protected  boolean _pressed
           
static int DOWN
          Indicates that this button is in the down state.
protected static int STATE_COUNT
           
protected static String[] STATE_PCLASSES
           
 
Fields inherited from class com.jmex.bui.BLabel
_label
 
Fields inherited from class com.jmex.bui.BTextComponent
_effcols, _effsizes, _haligns, _lineSpacings, _teffects, _textfacts, _valigns
 
Fields inherited from class com.jmex.bui.BComponent
_alpha, _backgrounds, _bbuf, _borders, _colors, _cursor, _enabled, _height, _hover, _insets, _listeners, _parent, _preferredSize, _properties, _styleClass, _tipmouse, _tipStyle, _tiptext, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER
 
Fields inherited from interface com.jmex.bui.BConstants
BOTTOM, CENTER, DEFAULT_SIZE, DEFAULT_SPACING, GLOW, HORIZONTAL, LEFT, NORMAL, OUTLINE, OVERLAPPING, PLAIN, RIGHT, SHADOW, TOP, VERTICAL
 
Constructor Summary
BButton(BIcon icon, ActionListener listener, String action)
          Creates a button with the specified icon and action.
BButton(BIcon icon, String action)
          Creates a button with the specified icon and action.
BButton(String text)
          Creates a button with the specified textual label.
BButton(String text, ActionListener listener, String action)
          Creates a button with the specified label and action.
BButton(String text, String action)
          Creates a button with the specified label and action.
 
Method Summary
protected  void configureStyle(BStyleSheet style)
          Instructs this component to fetch its style configuration from the supplied style sheet.
 boolean dispatchEvent(BEvent event)
          Instructs this component to process the supplied event.
protected  void fireAction(long when, int modifiers)
          Called when the button is "clicked" which may due to the mouse being pressed and released while over the button or due to keyboard manipulation while the button has focus.
 String getAction()
          Returns the action generated when this button is clicked.
protected  String getDefaultStyleClass()
          Returns the default stylesheet class to be used for all instances of this component.
 int getState()
          Returns the state of this component, either BComponent.DEFAULT or BComponent.DISABLED.
protected  int getStateCount()
          Returns the number of different states that this component can take.
protected  String getStatePseudoClass(int state)
          Returns the pseudoclass identifier for the specified component state.
 void setAction(String action)
          Configures the action to be generated when this button is clicked.
 
Methods inherited from class com.jmex.bui.BLabel
computePreferredSize, getFit, getIcon, getIconTextGap, getText, layout, renderComponent, setFit, setIcon, setIconTextGap, setOrientation, setText, wasAdded, wasRemoved
 
Methods inherited from class com.jmex.bui.BTextComponent
checkNonDefault, checkNonDefaultInt, checkNonDefaultVal, getEffectColor, getEffectSize, getHorizontalAlignment, getLabelConfig, getLineSpacing, getTextEffect, getTextFactory, getTextFactory, getVerticalAlignment
 
Methods inherited from class com.jmex.bui.BComponent
acceptsFocus, addListener, applyDefaultStates, boundsToString, changeCursor, createTooltipComponent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getCursor, getFocusTarget, getHeight, getHitComponent, getInsets, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getStyleClass, getTooltipText, getWidth, getWindow, getX, getY, hasFocus, intersectScissorBox, invalidate, isAdded, isEnabled, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, restoreScissorState, setAlpha, setBackground, setBounds, setCursor, setEnabled, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleClass, setTooltipRelativeToMouse, setTooltipText, setVisible, stateDidChange, updateCursor, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOWN

public static final int DOWN
Indicates that this button is in the down state.

See Also:
Constant Field Values

_armed

protected boolean _armed

_pressed

protected boolean _pressed

_action

protected String _action

STATE_COUNT

protected static final int STATE_COUNT
See Also:
Constant Field Values

STATE_PCLASSES

protected static final String[] STATE_PCLASSES
Constructor Detail

BButton

public BButton(String text)
Creates a button with the specified textual label.


BButton

public BButton(String text,
               String action)
Creates a button with the specified label and action. The action will be dispatched via an ActionEvent when the button is clicked.


BButton

public BButton(String text,
               ActionListener listener,
               String action)
Creates a button with the specified label and action. The action will be dispatched via an ActionEvent to the specified ActionListener when the button is clicked.


BButton

public BButton(BIcon icon,
               String action)
Creates a button with the specified icon and action. The action will be dispatched via an ActionEvent when the button is clicked.


BButton

public BButton(BIcon icon,
               ActionListener listener,
               String action)
Creates a button with the specified icon and action. The action will be dispatched via an ActionEvent to the specified ActionListener when the button is clicked.

Method Detail

setAction

public void setAction(String action)
Configures the action to be generated when this button is clicked.


getAction

public String getAction()
Returns the action generated when this button is clicked.


getState

public int getState()
Description copied from class: BComponent
Returns the state of this component, either BComponent.DEFAULT or BComponent.DISABLED.

Overrides:
getState in class BComponent

dispatchEvent

public boolean dispatchEvent(BEvent event)
Description copied from class: BComponent
Instructs this component to process the supplied event. If the event is not processed, it will be passed up to its parent component for processing. Derived classes should thus only call super.dispatchEvent for events that they did not "consume".

Overrides:
dispatchEvent in class BComponent
Returns:
true if this event was consumed, false if not.

getDefaultStyleClass

protected String getDefaultStyleClass()
Description copied from class: BComponent
Returns the default stylesheet class to be used for all instances of this component. Derived classes will likely want to override this method and set up a default class for their type of component.

Overrides:
getDefaultStyleClass in class BLabel

getStateCount

protected int getStateCount()
Description copied from class: BComponent
Returns the number of different states that this component can take. These states correspond to stylesheet pseudoclasses that allow components to customize their configuration based on whether they are enabled or disabled, or pressed if they are a button, etc.

Overrides:
getStateCount in class BComponent

getStatePseudoClass

protected String getStatePseudoClass(int state)
Description copied from class: BComponent
Returns the pseudoclass identifier for the specified component state. This string will be the way that the state is identified in the associated stylesheet. For example, the BComponent.DISABLED state maps to disabled and is configured like so:
 component:disabled {
    color: #CCCCCC; // etc.
 }
 

Overrides:
getStatePseudoClass in class BComponent

configureStyle

protected void configureStyle(BStyleSheet style)
Description copied from class: BComponent
Instructs this component to fetch its style configuration from the supplied style sheet. This method is called when a component is added to the interface hierarchy.

Overrides:
configureStyle in class BTextComponent

fireAction

protected void fireAction(long when,
                          int modifiers)
Called when the button is "clicked" which may due to the mouse being pressed and released while over the button or due to keyboard manipulation while the button has focus.



Copyright © 2008 Michael Bayne. All Rights Reserved.