public class SwingButtonHandler extends Object implements ItemListener
A specific Swing component handler implementation that deals with several kinds of button like components.
This component handler class handles buttons (command and toggle buttons), check boxes and radio buttons. Data type is boolean, i.e. a flag whether the button is selected. All type of event handlers are supported.
Constructor and Description |
---|
SwingButtonHandler(AbstractButton button)
Creates a new instance of
SwingButtonHandler . |
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener l)
Adds an action listener at this component.
|
void |
addChangeListener(ChangeListener l)
Adds a change listener at the managed component.
|
void |
addFocusListener(FocusListener l)
Registers a focus listener at the managed component.
|
void |
addMouseListener(MouseListener l)
Adds the specified mouse listener to the managed component.
|
protected void |
fireChangeEvent(Object event)
Fires a change event to the registered change listeners.
|
AbstractButton |
getButton()
Returns the managed button.
|
Object |
getComponent()
Returns a reference to the managed component.
|
Boolean |
getData()
Returns the component's data.
|
JComponent |
getJComponent()
Returns a reference to the managed Swing component.
|
Object |
getOuterComponent()
Returns the outer most component.
|
Class<?> |
getType()
Returns the component's data type.
|
boolean |
isEnabled()
Checks whether the managed component is enabled.
|
void |
itemStateChanged(ItemEvent event)
Callback for item events.
|
protected void |
registerChangeListener()
Registers this object as change listener at the managed button.
|
void |
removeActionListener(ActionListener l)
Removes an action listener from this component.
|
void |
removeChangeListener(ChangeListener l)
Removes a change listener from this component.
|
void |
removeFocusListener(FocusListener l)
Removes the specified focus listener from this component.
|
void |
removeMouseListener(MouseListener l)
Removes the specified mouse listener from the managed component.
|
void |
setData(Boolean data)
Sets the component's data.
|
void |
setEnabled(boolean f)
Sets the enabled flag of the managed component.
|
protected void |
unregisterChangeListener()
Unregisters this object as change listener at the managed button.
|
public SwingButtonHandler(AbstractButton button)
SwingButtonHandler
.button
- the button to handlepublic AbstractButton getButton()
public Boolean getData()
getData
in interface ComponentHandler<Boolean>
public void setData(Boolean data)
setData
in interface ComponentHandler<Boolean>
data
- the component's data.public Class<?> getType()
getType
in interface ComponentHandler<Boolean>
public void addActionListener(ActionListener l)
addActionListener
in interface SwingEventSource
l
- the listener to registerpublic void removeActionListener(ActionListener l)
removeActionListener
in interface SwingEventSource
l
- the listener to be removedprotected void registerChangeListener()
protected void unregisterChangeListener()
registerChangeListener()
public void itemStateChanged(ItemEvent event)
itemStateChanged
in interface ItemListener
event
- the eventpublic JComponent getJComponent()
public Object getComponent()
getComponent
in interface ComponentHandler<T>
public Object getOuterComponent()
getComponent()
.getOuterComponent
in interface ComponentHandler<T>
public boolean isEnabled()
isEnabled
in interface ComponentHandler<T>
public void setEnabled(boolean f)
setEnabled
in interface ComponentHandler<T>
f
- the value of the enabled flagpublic void addChangeListener(ChangeListener l)
FormEventManager
will do the multiplexing). Because
there is no generic change listener in Swing
registerChangeListener()
will be invoked for doing the actual
registration.addChangeListener
in interface SwingEventSource
l
- the listener to registerpublic void removeChangeListener(ChangeListener l)
addChangeListener()
can be removed again. If the passed in
listener is different from the registered listener, this operation will
have no effect.removeChangeListener
in interface SwingEventSource
l
- the listener to be removedaddChangeListener(ChangeListener)
public void addFocusListener(FocusListener l)
addFocusListener
in interface SwingEventSource
l
- the listener to registerpublic void removeFocusListener(FocusListener l)
removeFocusListener
in interface SwingEventSource
l
- the listener to be removedpublic void addMouseListener(MouseListener l)
addMouseListener
in interface SwingEventSource
l
- the listener to be addedpublic void removeMouseListener(MouseListener l)
removeMouseListener
in interface SwingEventSource
l
- the listener to removeprotected void fireChangeEvent(Object event)
event
- the eventCopyright © 2016 The JGUIraffe Team. All rights reserved.