|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.AbstractButton javax.swing.JButton uic.widgets.ToolBarButton
public class ToolBarButton
Button that behaves like a normal JButton, but looks different. It has no border and has a rollover-icon by default.
This button can have a popupmenu assigned to it, and have a default "pressed" action at the same time
allowing a normal button press to trigger the default action and when the user keeps the button depressed
for a specified delay the popup menu will appear.
An example of setting the popupmenu:
ToolBarButton bt = new ToolBarButton(); // create new empty button JPopupMenu myJPopupMenu = new JPopupMenu(); myJPopupMenu.add(new JMenuItem("First")); // register menu items that should be shown myJPopupMenu.add(new JMenuItem("Second item")); // on longer selection bt.setPopupMenu(myJPopupMenu); // register the menu with the toolbar button.Setting of the default action (which is the action when the button is pressed without triggering the popup to show) you just have add an action listener to this button, like on all AbstractButton extending classes.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JButton |
---|
JButton.AccessibleJButton |
Nested classes/interfaces inherited from class javax.swing.AbstractButton |
---|
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
ToolBarButton()
Constructor. |
|
ToolBarButton(Icon icon)
|
|
ToolBarButton(String label)
Constructor. |
|
ToolBarButton(String text,
Icon icon)
|
|
ToolBarButton(String text,
IconFactory iconFactory,
String iconBaseName)
|
Method Summary | |
---|---|
void |
addActionListener(ActionListener listener)
Override to set the initial delay of the popupmenu to be shown (if available). |
ActionListener |
createActionListener()
Override to overcome double events fired. |
protected void |
fireActionPerformed(ActionEvent event)
|
Dimension |
getMinimumSize()
|
int |
getPopupDelay()
Returns the popup menu delay. |
Dimension |
getPreferredSize()
|
boolean |
getToggleButton()
Returns returns if this button is a togglebutton. |
boolean |
hasPopupMenu()
|
boolean |
isFocusTraversable()
|
void |
paintComponent(Graphics g)
|
void |
removeActionListener(ActionListener listener)
Override to set the initial delay of the popupmenu to be shown (if available). |
void |
setBorder(Border b)
Overriden method to overcome border settings. |
void |
setIcon(Icon icon)
Set the icon. |
void |
setPopupDelay(int popupDelay)
Set the popupmenu delay. |
void |
setPopupMenu(JPopupMenu menu)
Set the popupmenu to show on click. |
void |
setSelected(boolean on)
If this button is a togglebutton, set it to be selected currently. |
void |
setText(String text)
|
void |
setToggleButton(boolean on)
Set this button to behave like it is a toggleButton. |
Methods inherited from class javax.swing.JButton |
---|
configurePropertiesFromAction, getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ToolBarButton()
public ToolBarButton(String label)
label
- the label to show on the buttonpublic ToolBarButton(Icon icon)
public ToolBarButton(String text, Icon icon)
public ToolBarButton(String text, IconFactory iconFactory, String iconBaseName)
Method Detail |
---|
public void setText(String text)
setText
in class AbstractButton
public void setToggleButton(boolean on)
on
- true if this button should behave like a togglebutton.public boolean getToggleButton()
public void setSelected(boolean on)
setSelected
in class AbstractButton
on
- the selected state.public void addActionListener(ActionListener listener)
addActionListener
in class AbstractButton
listener
- the listener to be setpublic void removeActionListener(ActionListener listener)
removeActionListener
in class AbstractButton
listener
- the listener to be setpublic ActionListener createActionListener()
createActionListener
in class AbstractButton
public void setBorder(Border b)
setBorder
in class JComponent
b
- the border to be ignored :)public void setIcon(Icon icon)
setIcon
in class AbstractButton
icon
- the icon to setpublic void setPopupDelay(int popupDelay)
popupDelay
- the delay in millis to show the popupmenu
IllegalArgumentException
- when popupDelay < 0public int getPopupDelay()
public boolean isFocusTraversable()
isFocusTraversable
in class Component
public void setPopupMenu(JPopupMenu menu)
menu
- the popup menu to showpublic boolean hasPopupMenu()
public void paintComponent(Graphics g)
paintComponent
in class JComponent
protected void fireActionPerformed(ActionEvent event)
fireActionPerformed
in class AbstractButton
public Dimension getMinimumSize()
getMinimumSize
in class JComponent
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |