| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--java.awt.Panel
|
+--ncsa.horizon.awt.SingleComponentPanel
|
+--ncsa.horizon.awt.PanelButton
Though not a subclass of the AWT's Button, it can behave as one. It also can behave like an AWT Choice--either as a simple on/off switch or as a radio button. Its raised border gives it the look of a button, yet the interior can contain any other component such a Label to hold simple text or a canvas with an image painted on it. The preferred size of the button is determined by the preferred size of the component it contains.
By default, a PanelButton operates like a simple button: clicking it causes the button to depress and pop-up again, and an action event is sent to listeners. The action command string associated with the event is set to "on".
The PanelButton can be set to behave as an on/off switch by passing a true value to the setSticky() method. A sticky button will remain pressed in until it is pushed again. When the button is pressed in, the resulting ActionEvent will have an action command string set to "on"; when the button is raised, the command string is equal to "off".
The set of PanelButtons is made to act as radio buttons by passing the same PanelButton.RadioGroup object to each PanelButton. For example,
PanelButton.RadioGroup rg = new PanelButton.RadioGroup();
PanelButton pb1 = new PanelButton(4, rg, new Label("Choice 1"));
PanelButton pb2 = new PanelButton(4, rg, new Label("Choice 2"));
When in radio mode, the button is sticky by default. Thus, when you
turn one button on, the previous engaged button will turn off. In this
case, two ActionEvents are fired: one from the clicked button indicating
it has been turned on, and one from the other button indicating it was
turned off. In general, the off signal is sent first, but listeners
should probably not assume this. Note that while this button can contain any component, most components that respond to mouse clicks can prevent such events from getting to the enclosing PanelButton. If one overrides the mouse event methods of this class to handle this problem, one should be sure to call the appropriate method of the superclass somewhere in the overriding versions.
| Inner Class Summary | |
| static | PanelButton.RadioGroup
a manager of a group of Panel buttons that ensures that only one of them is pressed at a time. |
| Fields inherited from class ncsa.horizon.awt.SingleComponentPanel | |
| bgap, item, lgap, rgap, tgap | |
| Fields inherited from class java.awt.Component | |
| BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT | |
| Constructor Summary | |
| PanelButton(int thickness)
create a clickable button with a given border thickness |
|
| PanelButton(int thickness,
java.awt.Component c)
create a clickable button with a given border thickness and containing a given component. |
|
| PanelButton(int thickness,
PanelButton.RadioGroup rg,
java.awt.Component c)
create a clickable radio button. |
|
| Method Summary | |
| void | actionPerformed(java.awt.event.ActionEvent ev)
|
| void | addActionListener(java.awt.event.ActionListener l)
add an action listener that will be notified when the button has been engaged. |
| java.awt.Component | add(java.awt.Component comp)
|
| PanelButton.RadioGroup | getRadioGroup()
return the RadioGroup managing this button. |
| boolean | getState()
return the state of the button. |
| boolean | isSticky()
return whether the button should be sticky. |
| static void | main(java.lang.String[] args)
|
| void | mouseClicked(java.awt.event.MouseEvent ev)
|
| void | mouseDragged(java.awt.event.MouseEvent ev)
|
| void | mouseEntered(java.awt.event.MouseEvent ev)
|
| void | mouseExited(java.awt.event.MouseEvent ev)
|
| void | mousePressed(java.awt.event.MouseEvent ev)
|
| void | mouseReleased(java.awt.event.MouseEvent ev)
|
| void | paint(java.awt.Graphics g)
|
| void | removeActionListener(java.awt.event.ActionListener l)
remove an action listener |
| void | setState(boolean pressed)
set the state of the button. |
| void | setSticky(boolean b)
set whether the button is sticky. |
| Methods inherited from class ncsa.horizon.awt.SingleComponentPanel | |
| add, initLayout, setBounds | |
| Methods inherited from class java.awt.Panel | |
| addNotify | |
| Methods inherited from class java.awt.Container | |
| add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree | |
| Methods inherited from class java.awt.Component | |
| action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate | |
| Methods inherited from class java.lang.Object | |
| clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait | |
| Constructor Detail |
public PanelButton(int thickness)
public PanelButton(int thickness,
java.awt.Component c)
public PanelButton(int thickness,
PanelButton.RadioGroup rg,
java.awt.Component c)
| Method Detail |
public java.awt.Component add(java.awt.Component comp)
public boolean getState()
public void setState(boolean pressed)
public boolean isSticky()
public void setSticky(boolean b)
public PanelButton.RadioGroup getRadioGroup()
public void paint(java.awt.Graphics g)
public void mousePressed(java.awt.event.MouseEvent ev)
public void mouseReleased(java.awt.event.MouseEvent ev)
public void mouseExited(java.awt.event.MouseEvent ev)
public void mouseDragged(java.awt.event.MouseEvent ev)
public void mouseEntered(java.awt.event.MouseEvent ev)
public void mouseClicked(java.awt.event.MouseEvent ev)
public void addActionListener(java.awt.event.ActionListener l)
public void removeActionListener(java.awt.event.ActionListener l)
public void actionPerformed(java.awt.event.ActionEvent ev)
public static void main(java.lang.String[] args)
| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||