Class JideButton

All Implemented Interfaces:
Alignable, AlignmentSupport, ButtonStyle, ComponentStateSupport, ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants
Direct Known Subclasses:
CornerScroller, HeaderBox, JideToggleButton, NullJideButton, SimpleScrollPane.ScrollButton

public class JideButton extends JButton implements Alignable, ButtonStyle, ComponentStateSupport, AlignmentSupport
JideButton is a replacement for JButton when it is used on toolbar (or command bar in the case of JIDE Action Framework).
See Also:
  • Field Details

    • CLIENT_PROPERTY_HIDE_POPUPMENU

      public static final String CLIENT_PROPERTY_HIDE_POPUPMENU
      By default, if a JideButton is added to a popup menu, clicking on the button will dismiss the popup menu. However if you change the default behavior, you can use this client property and set it to Boolean.FALSE.
      See Also:
  • Constructor Details

    • JideButton

      public JideButton()
      Creates a button with no set text or icon.
    • JideButton

      public JideButton(Icon icon)
      Creates a button with an icon.
      Parameters:
      icon - the Icon image to display on the button
    • JideButton

      public JideButton(String text)
      Creates a button with text.
      Parameters:
      text - the text of the button
    • JideButton

      public JideButton(Action a)
      Creates a button where properties are taken from the Action supplied.
      Parameters:
      a - the Action used to specify the new button
      Since:
      1.3
    • JideButton

      public JideButton(String text, Icon icon)
      Creates a button with initial text and an icon.
      Parameters:
      text - the text of the button
      icon - the Icon image to display on the button
  • Method Details

    • updateUI

      public void updateUI()
      Resets the UI property to a value from the current look and feel.
      Overrides:
      updateUI in class JButton
      See Also:
    • getUIClassID

      public String getUIClassID()
      Returns a string that specifies the name of the L&F class that renders this component.
      Overrides:
      getUIClassID in class JButton
      Returns:
      the string "ButtonUI"
      See Also:
    • getOrientation

      public int getOrientation()
      The button orientation.
      Specified by:
      getOrientation in interface Alignable
      Returns:
      the orientation.
    • setOrientation

      public void setOrientation(int orientation)
      Description copied from interface: Alignable
      Changes the orientation. If the component is a Swing component, the default implementation is this.
      JideSwingUtilities.setOrientationOf(this, orientation);
      Specified by:
      setOrientation in interface Alignable
      Parameters:
      orientation - the new orientation
    • supportVerticalOrientation

      public boolean supportVerticalOrientation()
      return true if it supports vertical orientation.
      Specified by:
      supportVerticalOrientation in interface Alignable
      Returns:
      true if it supports vertical orientation
    • supportHorizontalOrientation

      public boolean supportHorizontalOrientation()
      return true if it supports horizontal orientation.
      Specified by:
      supportHorizontalOrientation in interface Alignable
      Returns:
      true if it supports horizontal orientation
    • getButtonStyle

      public int getButtonStyle()
      Gets the button style.
      Specified by:
      getButtonStyle in interface ButtonStyle
      Returns:
      the button style.
    • setButtonStyle

      public void setButtonStyle(int buttonStyle)
      Sets the button style.
      Specified by:
      setButtonStyle in interface ButtonStyle
      Parameters:
      buttonStyle - one of the following values: ButtonStyle.TOOLBAR_STYLE (default), ButtonStyle.TOOLBOX_STYLE, ButtonStyle.FLAT_STYLE and ButtonStyle.HYPERLINK_STYLE.
    • setRolloverEnabled

      public void setRolloverEnabled(boolean b)
      Overrides:
      setRolloverEnabled in class AbstractButton
    • setText

      public void setText(String text)
      Overrides:
      setText in class AbstractButton
    • setIcon

      public void setIcon(Icon defaultIcon)
      Overrides:
      setIcon in class AbstractButton
    • isAlwaysShowHyperlink

      public boolean isAlwaysShowHyperlink()
      Checks the alwaysShowHyperlink property value.
      Returns:
      true if the hyperlink is always visible. False if the hyperlink will be visible only when mouse rolls over.
    • setAlwaysShowHyperlink

      public void setAlwaysShowHyperlink(boolean alwaysShowHyperlink)
      Sets the property if hyperlink (the underline) should be visible all the time. By default the hyperlink is visible when mouse is over the button. If set to true, the hyperlink will always be visible.

      Please notes, this is an option only available when button style is set to HYPERLINK_STYLE.

      Parameters:
      alwaysShowHyperlink - a boolean value. True means the button will always show hyperlink. False means it will show hyperlink only when mouse is over the button.
    • getDefaultForeground

      public Color getDefaultForeground()
    • setDefaultForeground

      public void setDefaultForeground(Color defaultForeground)
    • getBackgroundOfState

      public Color getBackgroundOfState(int state)
      Gets the background for different states. The states are defined in ThemePainter as constants. Not all states are supported by all components. If the state is not supported or background is never set, it will return null.

      Please note, each L&F will have its own way to paint the different backgrounds. This method allows you to customize it for each component to use a different background. So if you want the background to be used, don't use a ColorUIResource because UIResource is considered as a setting set by the L&F and any L&F can choose to ignore it.

      Specified by:
      getBackgroundOfState in interface ComponentStateSupport
      Parameters:
      state - the button state. Valid values are ThemePainter.STATE_DEFAULT, ThemePainter.STATE_ROLLOVER, ThemePainter.STATE_SELECTED and ThemePainter.STATE_PRESSED.
      Returns:
      the background for different states.
    • setBackgroundOfState

      public void setBackgroundOfState(int state, Color color)
      Sets the background for different states. The states are defined in ThemePainter as constants. Not all states are supported by all components. If the state is not supported or background is never set, it will return null.

      Please note, each L&F will have its own way to paint the different backgrounds. This method allows you to customize it for each component to use a different background. So if you want the background to be used, don't use a ColorUIResource because UIResource is considered as a setting set by the L&F and any L&F can choose to ignore it.

      Specified by:
      setBackgroundOfState in interface ComponentStateSupport
      Parameters:
      state - the button state. Valid values are ThemePainter.STATE_DEFAULT, ThemePainter.STATE_ROLLOVER, ThemePainter.STATE_SELECTED and ThemePainter.STATE_PRESSED.
      color - the new background for the state.
    • getForegroundOfState

      public Color getForegroundOfState(int state)
      Gets the foreground for different states. The states are defined in ThemePainter as constants. Not all states are supported by all components. If the state is not supported or foreground is never set, it will return null.

      Please note, each L&F will have its own way to paint the different foregrounds. This method allows you to customize it for each component to use a different foreground. So if you want the foreground to be used, don't use a ColorUIResource because UIResource is considered as a setting set by the L&F and any L&F can choose to ignore it.

      Specified by:
      getForegroundOfState in interface ComponentStateSupport
      Parameters:
      state - the button state. Valid values are ThemePainter.STATE_DEFAULT, ThemePainter.STATE_ROLLOVER, ThemePainter.STATE_SELECTED and ThemePainter.STATE_PRESSED.
      Returns:
      the foreground for different states.
    • setForegroundOfState

      public void setForegroundOfState(int state, Color color)
      Sets the foreground for different states. The states are defined in ThemePainter as constants. Not all states are supported by all components. If the state is not supported or foreground is never set, it will return null.

      Please note, each L&F will have its own way to paint the different foregrounds. This method allows you to customize it for each component to use a different foreground. So if you want the foreground to be used, don't use a ColorUIResource because UIResource is considered as a setting set by the L&F and any L&F can choose to ignore it.

      Specified by:
      setForegroundOfState in interface ComponentStateSupport
      Parameters:
      state - the button state. Valid values are ThemePainter.STATE_DEFAULT, ThemePainter.STATE_ROLLOVER, ThemePainter.STATE_SELECTED and ThemePainter.STATE_PRESSED.
      color - the new foreground for the state.