Class JXButton

  • All Implemented Interfaces:
    ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

    public class JXButton
    extends JButton

    A Painter enabled subclass of JButton. This class supports setting the foreground and background painters of the button separately.

    For example, if you wanted to blur just the text on the button, and let everything else be handled by the UI delegate for your look and feel, then you could:

    
      JXButton b = new JXButton("Execute");
      AbstractPainter fgPainter = (AbstractPainter)b.getForegroundPainter();
      StackBlurFilter filter = new StackBlurFilter();
      fgPainter.setFilters(filter);
     

    If either the foreground painter or the background painter is set, then super.paintComponent() is not called. By setting both the foreground and background painters to null, you get exactly the same painting behavior as JButton.

    Author:
    rbair, rah003, Jan Stola, Karl George Schaefer
    See Also:
    Serialized Form
    • Constructor Detail

      • JXButton

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

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

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

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

        public JXButton​(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 Detail

      • getBackgroundPainter

        public Painter getBackgroundPainter()
      • setBackgroundPainter

        public void setBackgroundPainter​(Painter p)
      • getForegroundPainter

        public Painter getForegroundPainter()
        Returns:
      • setForegroundPainter

        public void setForegroundPainter​(Painter p)
      • isPaintBorderInsets

        public boolean isPaintBorderInsets()
        Returns true if the background painter should paint where the border is or false if it should only paint inside the border. This property is true by default. This property affects the width, height, and initial transform passed to the background painter.
      • setPaintBorderInsets

        public void setPaintBorderInsets​(boolean paintBorderInsets)
        Sets the paintBorderInsets property. Set to true if the background painter should paint where the border is or false if it should only paint inside the border. This property is true by default. This property affects the width, height, and initial transform passed to the background painter. This is a bound property.
      • updateUI

        public void updateUI()
        Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
        Overrides:
        updateUI in class JButton
        See Also:
        JComponent.updateUI()