Class JSplitButton

  • All Implemented Interfaces:
    ActionListener, MouseListener, MouseMotionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, SwingConstants

    @Deprecated
    public class JSplitButton
    extends JButton
    implements MouseMotionListener, MouseListener, ActionListener, Serializable
    Deprecated.
    An implementation of a "split" button.The left side acts like a normal button, right side has a jPopupMenu attached.
    This class raises two events.
    1. buttonClicked(e); //when the button is clicked
    2. splitButtonClicked(e; //when the split part of the button is clicked)
    You need to subscribe to SplitButtonActionListener to handle these events.

    Use as you wish, but an acknowlegement would be appreciated, ;)

    Known Issue:
    The 'button part' of the splitbutton is being drawn without the border??? and this is only happening in CDE/Motif and Metal Look and Feels. GTK+ and nimbus works perfect. No Idea why? if anybody could point out the mistake that'd be nice.My email naveedmurtuza[at]gmail.com

    P.S. The fireXXX methods has been directly plagarized from JDK source code, and yes even the javadocs..;)

    The border bug in metal L&F is now fixed. Thanks to Hervé Guillaume.
    Author:
    Naveed Quadri
    See Also:
    Serialized Form
    • Constructor Detail

      • JSplitButton

        public JSplitButton​(String text,
                            Icon icon)
        Deprecated.
        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
      • JSplitButton

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

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

        public JSplitButton()
        Deprecated.
        Creates a button with no set text or icon.
    • Method Detail

      • getPopupMenu

        public JPopupMenu getPopupMenu()
        Deprecated.
        Returns the JPopupMenu if set, null otherwise.
        Returns:
        JPopupMenu
      • setPopupMenu

        public void setPopupMenu​(JPopupMenu popupMenu)
        Deprecated.
        Sets the JPopupMenu to be displayed, when the split part of the button is clicked.
        Parameters:
        popupMenu -
      • getSeparatorSpacing

        public int getSeparatorSpacing()
        Deprecated.
        Returns the separatorSpacing. Separator spacing is the space above and below the separator( the line drawn when you hover your mouse over the split part of the button).
        Returns:
        separatorSpacingimage = null; //to repaint the image with the new size
      • setSeparatorSpacing

        public void setSeparatorSpacing​(int separatorSpacing)
        Deprecated.
        Sets the separatorSpacing.Separator spacing is the space above and below the separator( the line drawn when you hover your mouse over the split part of the button).
        Parameters:
        separatorSpacing -
      • isAlwaysDropDown

        public boolean isAlwaysDropDown()
        Deprecated.
        Show the dropdown menu, if attached, even if the button part is clicked.
        Returns:
        true if alwaysDropdown, false otherwise.
      • setAlwaysDropDown

        public void setAlwaysDropDown​(boolean alwaysDropDown)
        Deprecated.
        Show the dropdown menu, if attached, even if the button part is clicked.
        Parameters:
        alwaysDropDown - true to show the attached dropdown even if the button part is clicked, false otherwise
      • getArrowColor

        public Color getArrowColor()
        Deprecated.
        Gets the color of the arrow.
        Returns:
        arrowColor
      • setArrowColor

        public void setArrowColor​(Color arrowColor)
        Deprecated.
        Set the arrow color.
        Parameters:
        arrowColor -
      • getDisabledArrowColor

        public Color getDisabledArrowColor()
        Deprecated.
        gets the disabled arrow color
        Returns:
        disabledArrowColor color of the arrow if no popup attached.
      • setDisabledArrowColor

        public void setDisabledArrowColor​(Color disabledArrowColor)
        Deprecated.
        sets the disabled arrow color
        Parameters:
        disabledArrowColor - color of the arrow if no popup attached.
      • getSplitWidth

        public int getSplitWidth()
        Deprecated.
        Splitwidth is the width of the split part of the button.
        Returns:
        splitWidth
      • setSplitWidth

        public void setSplitWidth​(int splitWidth)
        Deprecated.
        Splitwidth is the width of the split part of the button.
        Parameters:
        splitWidth -
      • getArrowSize

        public int getArrowSize()
        Deprecated.
        gets the size of the arrow.
        Returns:
        size of the arrow
      • setArrowSize

        public void setArrowSize​(int arrowSize)
        Deprecated.
        sets the size of the arrow
        Parameters:
        arrowSize -
      • setRecalculateWidth

        public void setRecalculateWidth​(boolean recalculateWidth)
        Deprecated.
      • getImage

        public Image getImage()
        Deprecated.
        Gets the image to be drawn in the split part. If no is set, a new image is created with the triangle.
        Returns:
        image
      • getDisabledImage

        public Image getDisabledImage()
        Deprecated.
        Gets the disabled image to be drawn in the split part. If no is set, a new image is created with the triangle.
        Returns:
        image
      • setImage

        public void setImage​(Image image)
        Deprecated.
        Sets the image to draw instead of the triangle.
        Parameters:
        image -
      • addSplitButtonActionListener

        public void addSplitButtonActionListener​(SplitButtonActionListener l)
        Deprecated.
        Adds an SplitButtonActionListener to the button.
        Parameters:
        l - the ActionListener to be added
      • removeSplitButtonActionListener

        public void removeSplitButtonActionListener​(SplitButtonActionListener l)
        Deprecated.
        Removes an SplitButtonActionListener from the button. If the listener is the currently set Action for the button, then the Action is set to null.
        Parameters:
        l - the listener to be removed