Package be.gaudry.swing.action
Class RunnablePanelPauseAction
java.lang.Object
javax.swing.AbstractAction
be.gaudry.swing.action.RunnablePanelPauseAction
- All Implemented Interfaces:
ActionListener
,Serializable
,Cloneable
,EventListener
,Action
Action associated to a runnable component.
Allows to control the way to display the action(the image and the name)
depending on the status(if the process is running or not) and on the
availability of the component(if the panel is hidden, the action is disabled).
Provided by the broldev.core.swing project.
- Since:
- 1.0 (Mar 23, 2009), broldev.core.swing 0.0.1-SNAPSHOT dependency
- Version:
- 1.3 (Sep 4, 2009)
- Author:
- Steph GAUDRY
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
Constructor Summary
ConstructorsConstructorDescriptionBuilds a default instance of an action to pause or resume a runnableRunnablePanelPauseAction(String lRBPath, String lRBPauseKey, String lRBResumeKey)
Builds a custom instance of an action to start or stop a runnableRunnablePanelPauseAction(Icon startProcessImage, Icon stopProcessImage, String lRBPath, String lRBPauseKey, String lRBResumeKey)
Builds a custom instance of an action to start or stop a runnable -
Method Summary
Modifier and TypeMethodDescriptionvoid
getPanel()
Returns the runnable componentboolean
isPaused()
Returns the runnable statusvoid
Forces to read localized strings to actualize this.void
setPanel(IRunnablePauseablePanel panel)
Sets the JPanel to link to this action \nDoes nothing if the parameter is not an instance ofJPanel
.void
setPaused(boolean paused)
Toggles the runnable status, and sets theAction.SMALL_ICON
andAction.NAME
values according to the status.Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Constructor Details
-
RunnablePanelPauseAction
public RunnablePanelPauseAction()Builds a default instance of an action to pause or resume a runnable -
RunnablePanelPauseAction
Builds a custom instance of an action to start or stop a runnable- Parameters:
lRBPath
- language resource bundle pathlRBPauseKey
- key to access the "pause" localized stringlRBResumeKey
- key to access the "resume" localized string
-
RunnablePanelPauseAction
public RunnablePanelPauseAction(Icon startProcessImage, Icon stopProcessImage, String lRBPath, String lRBPauseKey, String lRBResumeKey)Builds a custom instance of an action to start or stop a runnable- Parameters:
startProcessImage
- icon associated to the "pause" actionstopProcessImage
- icon associated to the "resume" actionlRBPath
- language resource bundle pathlRBPauseKey
- key to access the "pause" localized stringlRBResumeKey
- key to access the "resume" localized string
-
-
Method Details
-
actionPerformed
-
setLanguage
public void setLanguage()Forces to read localized strings to actualize this. -
isPaused
public boolean isPaused()Returns the runnable status- Returns:
- true if the runnable is started
-
setPaused
public void setPaused(boolean paused)Toggles the runnable status, and sets theAction.SMALL_ICON
andAction.NAME
values according to the status. \nThis sets the status to provide a way to know if the runnable is running or not without knowing the process, but doesn't affect the process itself. As starting and stopping the process is usually done in another thread, the responsibility of setting this status is left to the client.- Parameters:
paused
- set true if the runnable is started
-
getPanel
Returns the runnable component- Returns:
- the panel, or null
-
setPanel
Sets the JPanel to link to this action \nDoes nothing if the parameter is not an instance ofJPanel
.- Parameters:
panel
- the panel to set
-