Class RadioGroup

java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.nebula.widgets.radiogroup.RadioGroup
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class RadioGroup
extends org.eclipse.swt.widgets.Composite

SWT Widget that presents a group of radio buttons.

Styles:
BORDER, FLAT, HORIZONTAL, VERTICAL, LEFT, RIGHT, CENTER, LEFT_TO_RIGHT, RIGHT_TO_LEFT

Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.

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

Note: Only one of the styles LEFT_TO_RIGHT and RIGHT_TO_LEFT may be specified.

Events:
Selection, DefaultSelection

NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT. THIS IS A PRE-RELEASE ALPHA VERSION. USERS SHOULD EXPECT API CHANGES IN FUTURE VERSIONS.

IMPORTANT: This class is not intended to be subclassed.

  • Field Summary

    Fields inherited from class org.eclipse.swt.widgets.Control

    handle
  • Constructor Summary

    Constructors 
    Constructor Description
    RadioGroup​(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

    Modifier and Type Method Description
    (package private) void addItem​(RadioItem item, int position)  
    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.
    void clear​(int position)
    Reset the button at position position (reset content to empty string, reset font, images...)
    (package private) org.eclipse.swt.widgets.Button createButton​(int itemStyle, int position)  
    void deselectAll()
    Deselects all selected items in the receiver's list.
    int getItemCount()
    Returns the number of items contained in the receiver's list.
    RadioItem[] getItems()
    Returns a (possibly empty) array of RadioItems which are the items in the receiver's list.
    RadioItem getSelection()
    Returns the the item which is currently selected in the receiver's list, or null if no item is selected.
    int getSelectionIndex()
    Returns the zero-relative index of the item which is currently selected in the receiver's list, or -1 if no item is selected.
    int getStyle()  
    int indexOf​(RadioItem item)
    Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item.
    (package private) void itemSelected​(RadioItem item)  
    void remove​(int index)
    Removes the item from the receiver's list at the given zero-relative index.
    void remove​(int start, int end)
    Removes the items from the receiver's list which are between the given zero-relative start and end indices (inclusive).
    void remove​(RadioItem item)
    Searches the receiver's list starting at the first item until an item is found that is equal to the argument, and removes that item from the list.
    void removeAll()
    Removes all of the items from the receiver's list and clear the contents of receiver's text field.
    (package private) void removeItem​(RadioItem item)  
    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.
    void select​(int index)
    Selects the item at the given zero-relative index in the receiver's list.
    void setLayout​(org.eclipse.swt.widgets.Layout layout)  
    void setSelection​(RadioItem item)
    Sets the selection in the receiver

    Methods inherited from class org.eclipse.swt.widgets.Composite

    changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayoutDeferred, setTabList, toString

    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, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, 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, setFont, 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, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.swt.graphics.Drawable

    isAutoScalable
  • Constructor Details

    • RadioGroup

      public RadioGroup​(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:
      SWT.NO_BACKGROUND, SWT.NO_FOCUS, SWT.NO_MERGE_PAINTS, SWT.NO_REDRAW_RESIZE, SWT.NO_RADIO_GROUP, SWT.EMBEDDED, SWT.DOUBLE_BUFFERED, Widget.getStyle()
  • Method Details

    • addItem

      void addItem​(RadioItem item, int position)
    • 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.

      widgetSelected is called when the control is selected by the user. widgetDefaultSelected is not called.

      When the SWT.RADIO style bit is set, the widgetSelected method is also called when the receiver loses selection because another item in the same radio group was selected by the user. During widgetSelected the application can use getSelection() to determine the current selected state of the receiver.

      Parameters:
      listener - the listener which should 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, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent
    • clear

      public void clear​(int position)
      Reset the button at position position (reset content to empty string, reset font, images...)
      Parameters:
      listener - the listener which should be notified
      Throws:
      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
    • createButton

      org.eclipse.swt.widgets.Button createButton​(int itemStyle, int position)
    • deselectAll

      public void deselectAll()
      Deselects all selected items in the receiver's list.

      Note: To clear the selection in the receiver's text field, use clearSelection().

      Throws:
      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
    • getItemCount

      public int getItemCount()
      Returns the number of items contained in the receiver's list.
      Returns:
      the number of items
      Throws:
      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
    • getItems

      public RadioItem[] getItems()
      Returns a (possibly empty) array of RadioItems which are the items in the receiver's list.

      Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.

      Returns:
      the items in the receiver's list
      Throws:
      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
    • getSelection

      public RadioItem getSelection()
      Returns the the item which is currently selected in the receiver's list, or null if no item is selected.
      Returns:
      the selected item
      Throws:
      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
    • getSelectionIndex

      public int getSelectionIndex()
      Returns the zero-relative index of the item which is currently selected in the receiver's list, or -1 if no item is selected.
      Returns:
      the index of the selected item
      Throws:
      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
    • getStyle

      public int getStyle()
      Overrides:
      getStyle in class org.eclipse.swt.widgets.Widget
      See Also:
      Widget.getStyle()
    • indexOf

      public int indexOf​(RadioItem item)
      Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item. If no item is found, returns -1.
      Parameters:
      item - the search item
      Returns:
      the index of the item
      Throws:
      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
    • itemSelected

      void itemSelected​(RadioItem item)
    • remove

      public void remove​(int index)
      Removes the item from the receiver's list at the given zero-relative index.
      Parameters:
      index - the index for the item
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
      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
    • remove

      public void remove​(int start, int end)
      Removes the items from the receiver's list which are between the given zero-relative start and end indices (inclusive).
      Parameters:
      start - the start of the range
      end - the end of the range
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)
      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
    • remove

      public void remove​(RadioItem item)
      Searches the receiver's list starting at the first item until an item is found that is equal to the argument, and removes that item from the list.
      Parameters:
      item - the item to remove
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the string is null
      • ERROR_INVALID_ARGUMENT - if the string is not found in the list
      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
    • removeAll

      public void removeAll()
      Removes all of the items from the receiver's list and clear the contents of receiver's text field.

      Throws:
      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
    • removeItem

      void removeItem​(RadioItem item)
    • 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)
    • select

      public void select​(int index)
      Selects the item at the given zero-relative index in the receiver's list. If the item at the index was already selected, it remains selected. Indices that are out of range are ignored.
      Parameters:
      index - the index of the item to select
      Throws:
      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
    • 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)
    • setSelection

      public void setSelection​(RadioItem item)
      Sets the selection in the receiver
      Parameters:
      item - new selection
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the item does not exist in this widget
      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