Class RunnablePanelPauseAction

java.lang.Object
javax.swing.AbstractAction
be.gaudry.swing.action.RunnablePanelPauseAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public abstract class RunnablePanelPauseAction extends AbstractAction
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
  • Constructor Details

    • RunnablePanelPauseAction

      public RunnablePanelPauseAction()
      Builds a default instance of an action to pause or resume a runnable
    • RunnablePanelPauseAction

      public RunnablePanelPauseAction(String lRBPath, String lRBPauseKey, String lRBResumeKey)
      Builds a custom instance of an action to start or stop a runnable
      Parameters:
      lRBPath - language resource bundle path
      lRBPauseKey - key to access the "pause" localized string
      lRBResumeKey - 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" action
      stopProcessImage - icon associated to the "resume" action
      lRBPath - language resource bundle path
      lRBPauseKey - key to access the "pause" localized string
      lRBResumeKey - key to access the "resume" localized string
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent e)
    • 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 the Action.SMALL_ICON and Action.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

      public JPanel getPanel()
      Returns the runnable component
      Returns:
      the panel, or null
    • setPanel

      public void setPanel(IRunnablePauseablePanel panel)
      Sets the JPanel to link to this action \nDoes nothing if the parameter is not an instance of JPanel.
      Parameters:
      panel - the panel to set