Class CheckBoxGroup

  • All Implemented Interfaces:
    java.util.EventListener, org.eclipse.swt.events.PaintListener, org.eclipse.swt.graphics.Drawable, org.eclipse.swt.internal.SWTEventListener

    public class CheckBoxGroup
    extends org.eclipse.swt.widgets.Canvas
    implements org.eclipse.swt.events.PaintListener
    Instances of this class provide an etched border with a title and a checkbox. If the checkbox is checked, the content of the composite is enabled. If the checkbox is unchecked, the content of the composite is disabled, thus not editable.

    Styles:
    BORDER
    Events:
    (none)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.eclipse.swt.widgets.Button button  
      private org.eclipse.swt.widgets.Composite content  
      private java.util.List<org.eclipse.swt.events.SelectionListener> selectionListeners  
      private boolean transparent  
      • Fields inherited from class org.eclipse.swt.widgets.Composite

        embeddedHandle
      • Fields inherited from class org.eclipse.swt.widgets.Widget

        handle
    • Constructor Summary

      Constructors 
      Constructor Description
      CheckBoxGroup​(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 Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activate()
      Activate the content
      void addSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
      Adds the listener to the collection of listeners who will be notified when the user changes the receiver's selection, by sending it one of the messages defined in the SelectionListener interface.
      private void createCheckBoxButton()  
      void deactivate()
      Deactivate the content
      private void drawWidget​(org.eclipse.swt.graphics.GC gc)
      Draws the widget
      private boolean fireSelectionListeners​(org.eclipse.swt.events.SelectionEvent selectionEvent)
      Fire the selection listeners
      org.eclipse.swt.widgets.Composite getContent()  
      org.eclipse.swt.graphics.Font getFont()  
      org.eclipse.swt.widgets.Layout getLayout()  
      boolean getSelection()
      Returns true if the receiver is selected, and false otherwise
      java.lang.String getText()  
      boolean isActivated()  
      boolean isTransparent()  
      void paintControl​(org.eclipse.swt.events.PaintEvent paintEvent)  
      void removeSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
      Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.
      boolean setFocus()  
      void setFont​(org.eclipse.swt.graphics.Font font)  
      void setLayout​(org.eclipse.swt.widgets.Layout layout)  
      void setSelection​(boolean selection)
      Sets the selection state of the receiver
      void setText​(java.lang.String text)  
      void setTransparent​(boolean transparent)  
      • Methods inherited from class org.eclipse.swt.widgets.Canvas

        drawBackground, getCaret, getIME, scroll, setCaret, setIME
      • Methods inherited from class org.eclipse.swt.widgets.Composite

        changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayoutDeferred, setTabList
      • Methods inherited from class org.eclipse.swt.widgets.Scrollable

        computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
      • Methods inherited from class org.eclipse.swt.widgets.Control

        addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getForeground, getLayoutData, getLocation, getMenu, 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, setForeground, setLayoutData, setLocation, setLocation, setMenu, 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, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
      • Methods inherited from class java.lang.Object

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

      • button

        protected org.eclipse.swt.widgets.Button button
      • content

        private final org.eclipse.swt.widgets.Composite content
      • selectionListeners

        private final java.util.List<org.eclipse.swt.events.SelectionListener> selectionListeners
      • transparent

        private boolean transparent
    • Constructor Detail

      • CheckBoxGroup

        public CheckBoxGroup​(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 widget which will be the parent of the new instance (cannot be null)
        style - the style of widget 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
        See Also:
        Composite(Composite, int), SWT.BORDER, Widget.getStyle()
    • Method Detail

      • createCheckBoxButton

        private void createCheckBoxButton()
      • fireSelectionListeners

        private boolean fireSelectionListeners​(org.eclipse.swt.events.SelectionEvent selectionEvent)
        Fire the selection listeners
        Parameters:
        selectionEvent - mouse event
        Returns:
        true if the selection could be changed, false otherwise
      • activate

        public void activate()
        Activate the content
      • addSelectionListener

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

        When widgetSelected is called, the item field of the event object is valid. If the receiver has the SWT.CHECK style and the check selection changes, the event object detail field contains the value SWT.CHECK. widgetDefaultSelected is typically called when an item is double-clicked. The item field of the event object is valid for default selection, but the detail field is not used.

        Parameters:
        listener - the listener which should be notified when the user changes the receiver's selection
        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
      • deactivate

        public void deactivate()
        Deactivate the content
      • isActivated

        public boolean isActivated()
        Returns:
        true if the content is activated, false otherwise
      • getLayout

        public org.eclipse.swt.widgets.Layout getLayout()
        Overrides:
        getLayout in class org.eclipse.swt.widgets.Composite
        See Also:
        Composite.getLayout()
      • removeSelectionListener

        public void removeSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
        Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.
        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)
      • setFocus

        public boolean setFocus()
        Overrides:
        setFocus in class org.eclipse.swt.widgets.Composite
        See Also:
        Composite.setFocus()
      • setLayout

        public void setLayout​(org.eclipse.swt.widgets.Layout layout)
        Overrides:
        setLayout in class org.eclipse.swt.widgets.Composite
        See Also:
        Composite.setLayout(org.eclipse.swt.widgets.Layout)
      • getText

        public java.lang.String getText()
        Returns:
        the text of the button
      • setText

        public void setText​(java.lang.String text)
        Parameters:
        text - the text of the button to set
      • getFont

        public org.eclipse.swt.graphics.Font getFont()
        Overrides:
        getFont in class org.eclipse.swt.widgets.Control
        Returns:
        the font of the button
      • setFont

        public void setFont​(org.eclipse.swt.graphics.Font font)
        Overrides:
        setFont in class org.eclipse.swt.widgets.Canvas
        Parameters:
        font - the font to set
      • getContent

        public org.eclipse.swt.widgets.Composite getContent()
        Returns:
        the content of the group
      • isTransparent

        public boolean isTransparent()
      • setTransparent

        public void setTransparent​(boolean transparent)
      • paintControl

        public void paintControl​(org.eclipse.swt.events.PaintEvent paintEvent)
        Specified by:
        paintControl in interface org.eclipse.swt.events.PaintListener
      • drawWidget

        private void drawWidget​(org.eclipse.swt.graphics.GC gc)
        Draws the widget
      • setSelection

        public void setSelection​(boolean selection)
        Sets the selection state of the receiver
        Parameters:
        selection - the new selection state
      • getSelection

        public boolean getSelection()
        Returns true if the receiver is selected, and false otherwise
        Returns:
        the selection state