Class SplitButton

  • All Implemented Interfaces:
    org.eclipse.swt.graphics.Drawable

    public class SplitButton
    extends org.eclipse.swt.widgets.Button
    Instances of this class represent a selectable user interface object that issues notification when pressed and released. A menu can be attached to this button
    Styles:
    PUSH, TOGGLE
    Events:
    Selection

    Note: Only one of the styles PUSH or TOGGLE may be specified.

    Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.

    • Constructor Summary

      Constructors 
      Constructor Description
      SplitButton​(org.eclipse.swt.widgets.Composite parent, int style)
      Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addListener​(int eventType, org.eclipse.swt.widgets.Listener listener)
      Adds the listener to the collection of listeners who will be notified when an event of the given type occurs.
      private void addMouseDownListener()  
      private void addPaintListener()  
      void addSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
      Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.
      private static int checkBits​(int style, int int0, int int1, int int2)  
      private static int checkStyle​(int style)  
      protected void checkSubclass()  
      org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)  
      org.eclipse.swt.widgets.Menu getMenu()  
      void removeListener​(int eventType, org.eclipse.swt.widgets.Listener listener)
      Removes the listener from the collection of listeners who will be notified when an event of the given type occurs.
      void removeSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
      Removes the listener from the collection of listeners who will be notified when the control is selected by the user.
      void setMenu​(org.eclipse.swt.widgets.Menu menu)  
      • Methods inherited from class org.eclipse.swt.widgets.Button

        getAlignment, getGrayed, getImage, getSelection, getText, setAlignment, setGrayed, setImage, setSelection, setText
      • Methods inherited from class org.eclipse.swt.widgets.Control

        addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isAutoScalable, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFocus, setFont, setForeground, setLayoutData, setLocation, setLocation, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
      • Methods inherited from class org.eclipse.swt.widgets.Widget

        addDisposeListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, reskin, setData, setData, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • listeners

        private final java.util.List<org.eclipse.swt.widgets.Listener> listeners
      • splitButtonAreaLeft

        private int splitButtonAreaLeft
      • splitButtonAreaTop

        private int splitButtonAreaTop
      • splitButtonAreaRight

        private int splitButtonAreaRight
      • splitButtonAreaBottom

        private int splitButtonAreaBottom
      • menu

        private org.eclipse.swt.widgets.Menu menu
    • Constructor Detail

      • SplitButton

        public SplitButton​(org.eclipse.swt.widgets.Composite parent,
                           int style)
        Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

        The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

        Parameters:
        parent - a composite control which will be the parent of the new instance (cannot be null)
        style - the style of control to construct
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the parent is null
        org.eclipse.swt.SWTException -
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
        • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
        See Also:
        SWT.PUSH, SWT.TOGGLE, Widget.getStyle()
    • Method Detail

      • checkStyle

        private static int checkStyle​(int style)
      • checkBits

        private static int checkBits​(int style,
                                     int int0,
                                     int int1,
                                     int int2)
      • addPaintListener

        private void addPaintListener()
      • addMouseDownListener

        private void addMouseDownListener()
      • addSelectionListener

        public void addSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
        Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

        widgetDefaultSelected is not called.

        Overrides:
        addSelectionListener in class org.eclipse.swt.widgets.Button
        Parameters:
        listener - the listener which should be notified when the control is selected by the user,
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent
      • removeSelectionListener

        public void removeSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
        Removes the listener from the collection of listeners who will be notified when the control is selected by the user.
        Overrides:
        removeSelectionListener in class org.eclipse.swt.widgets.Button
        Parameters:
        listener - the listener which should no longer be notified
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        SelectionListener, addSelectionListener(org.eclipse.swt.events.SelectionListener)
      • addListener

        public void addListener​(int eventType,
                                org.eclipse.swt.widgets.Listener listener)
        Adds the listener to the collection of listeners who will be notified when an event of the given type occurs. When the event does occur in the widget, the listener is notified by sending it the handleEvent() message. The event type is one of the event constants defined in class SWT.
        Overrides:
        addListener in class org.eclipse.swt.widgets.Widget
        Parameters:
        eventType - the type of event to listen for
        listener - the listener which should be notified when the event occurs
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Listener, SWT, Widget.getListeners(int), removeListener(int, Listener), Widget.notifyListeners(int, org.eclipse.swt.widgets.Event)
      • removeListener

        public void removeListener​(int eventType,
                                   org.eclipse.swt.widgets.Listener listener)
        Removes the listener from the collection of listeners who will be notified when an event of the given type occurs. The event type is one of the event constants defined in class SWT.
        Overrides:
        removeListener in class org.eclipse.swt.widgets.Widget
        Parameters:
        eventType - the type of event to listen for
        listener - the listener which should no longer be notified
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Listener, SWT, addListener(int, org.eclipse.swt.widgets.Listener), Widget.getListeners(int), Widget.notifyListeners(int, org.eclipse.swt.widgets.Event)
      • getMenu

        public org.eclipse.swt.widgets.Menu getMenu()
        Overrides:
        getMenu in class org.eclipse.swt.widgets.Control
        See Also:
        Control.getMenu()
      • setMenu

        public void setMenu​(org.eclipse.swt.widgets.Menu menu)
        Overrides:
        setMenu in class org.eclipse.swt.widgets.Control
        See Also:
        Control.setMenu(org.eclipse.swt.widgets.Menu)
      • checkSubclass

        protected void checkSubclass()
        Overrides:
        checkSubclass in class org.eclipse.swt.widgets.Widget
        See Also:
        Widget.checkSubclass()
      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(int wHint,
                                                          int hHint,
                                                          boolean changed)
        Overrides:
        computeSize in class org.eclipse.swt.widgets.Control
        See Also:
        Control.computeSize(int, int, boolean)