Class SwitchButton
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.swt.widgets.Canvas
org.eclipse.nebula.widgets.opal.switchbutton.SwitchButton
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class SwitchButton
extends org.eclipse.swt.widgets.Canvas
Instances of this class are simple switch button.
- Styles:
- (none)
- Events:
- Selection
-
Field Summary
-
Constructor Summary
Constructors Constructor Description SwitchButton(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 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 theSelectionListener
interface.org.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint, boolean changed)
int
getArc()
org.eclipse.swt.graphics.Color
getBorderColor()
org.eclipse.swt.graphics.Color
getButtonBackgroundColor1()
org.eclipse.swt.graphics.Color
getButtonBackgroundColor2()
org.eclipse.swt.graphics.Color
getButtonBorderColor()
org.eclipse.swt.graphics.Color
getFocusColor()
int
getGap()
org.eclipse.swt.graphics.Point
getInsideMargin()
org.eclipse.swt.graphics.Color
getSelectedBackgroundColor()
org.eclipse.swt.graphics.Color
getSelectedForegroundColor()
boolean
getSelection()
java.lang.String
getText()
java.lang.String
getTextForSelect()
java.lang.String
getTextForUnselect()
org.eclipse.swt.graphics.Color
getUnselectedBackgroundColor()
org.eclipse.swt.graphics.Color
getUnselectedForegroundColor()
boolean
isRound()
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
setArc(int arc)
void
setBorderColor(org.eclipse.swt.graphics.Color borderColor)
void
setButtonBackgroundColor1(org.eclipse.swt.graphics.Color buttonBackgroundColor1)
void
setButtonBackgroundColor2(org.eclipse.swt.graphics.Color buttonBackgroundColor2)
void
setButtonBorderColor(org.eclipse.swt.graphics.Color buttonBorderColor)
void
setFocusColor(org.eclipse.swt.graphics.Color focusColor)
void
setGap(int gap)
void
setInsideMargin(int insideMarginX, int insideMarginY)
void
setInsideMargin(org.eclipse.swt.graphics.Point insideMargin)
void
setRound(boolean round)
void
setSelectedBackgroundColor(org.eclipse.swt.graphics.Color selectedBackgroundColor)
void
setSelectedForegroundColor(org.eclipse.swt.graphics.Color selectedForegroundColor)
void
setSelection(boolean selection)
void
setText(java.lang.String text)
void
setTextForSelect(java.lang.String textForSelect)
void
setTextForUnselect(java.lang.String textForUnselect)
void
setUnselectedBackgroundColor(org.eclipse.swt.graphics.Color unselectedBackgroundColor)
void
setUnselectedForegroundColor(org.eclipse.swt.graphics.Color unselectedForegroundColor)
Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME
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, setLayout, 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, 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, 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
-
Constructor Details
-
SwitchButton
public SwitchButton(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 theint
"|" operator) two or more of thoseSWT
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
-
-
Method Details
-
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 theSelectionListener
interface.widgetSelected
is called when the control is selected by the user.widgetDefaultSelected
is not called.- 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
-
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.- 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)
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)- Overrides:
computeSize
in classorg.eclipse.swt.widgets.Control
- See Also:
Control.computeSize(int, int, boolean)
-
getSelection
public boolean getSelection()- Returns:
- the selection state of the button
- 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
-
setSelection
public void setSelection(boolean selection)- Parameters:
selection
- the selection state of the button- 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
-
getTextForSelect
public java.lang.String getTextForSelect()- Returns:
- the text used to display the selection
- 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
-
setTextForSelect
public void setTextForSelect(java.lang.String textForSelect)- Parameters:
textForSelect
- the text used to display the selection- 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
-
getTextForUnselect
public java.lang.String getTextForUnselect()- Returns:
- the text used to display the unselected option
- 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
-
setTextForUnselect
public void setTextForUnselect(java.lang.String textForUnselect)- Parameters:
textForUnselect
- the text used to display the unselected option- 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
-
getText
public java.lang.String getText()- Returns:
- the text displayed in the widget
- 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
-
setText
public void setText(java.lang.String text)- Parameters:
the
- text displayed in the widget- 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
-
isRound
public boolean isRound()- Returns:
- the round flag
- 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
-
setRound
public void setRound(boolean round)- Parameters:
round
- the round flag to set. If true, the widget is composed of round rectangle instead of rectangles- 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
-
getBorderColor
public org.eclipse.swt.graphics.Color getBorderColor()- Returns:
- the border's color. If null, no border is displayed
- 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
-
setBorderColor
public void setBorderColor(org.eclipse.swt.graphics.Color borderColor)- Parameters:
borderColor
- the border's color. If null, no border is displayed.- 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
-
getFocusColor
public org.eclipse.swt.graphics.Color getFocusColor()- Returns:
- the focus color. If null, no focus effect is displayed.
- 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
-
setFocusColor
public void setFocusColor(org.eclipse.swt.graphics.Color focusColor)- Parameters:
focusColor
- the focus color to set. If null, no focus effect is displayed.- 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
-
getSelectedForegroundColor
public org.eclipse.swt.graphics.Color getSelectedForegroundColor()- Returns:
- the foreground color of the left part of the widget (selection is on)
- 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
-
setSelectedForegroundColor
public void setSelectedForegroundColor(org.eclipse.swt.graphics.Color selectedForegroundColor)- Parameters:
the
- foreground color of the left part of the widget (selection is on)- 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
-
getSelectedBackgroundColor
public org.eclipse.swt.graphics.Color getSelectedBackgroundColor()- Returns:
- the background color of the left part of the widget (selection is on)
- 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
-
setSelectedBackgroundColor
public void setSelectedBackgroundColor(org.eclipse.swt.graphics.Color selectedBackgroundColor)- Parameters:
the
- background color of the left part of the widget (selection is on)
-
getUnselectedForegroundColor
public org.eclipse.swt.graphics.Color getUnselectedForegroundColor()- Returns:
- the foreground color of the left part of the widget (selection is on)
- 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
-
setUnselectedForegroundColor
public void setUnselectedForegroundColor(org.eclipse.swt.graphics.Color unselectedForegroundColor)- Parameters:
unselectedForegroundColor
- the foreground color of the left part of the widget (selection is on)- 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
-
getUnselectedBackgroundColor
public org.eclipse.swt.graphics.Color getUnselectedBackgroundColor()- Returns:
- the background color of the left part of the widget (selection is on)
- 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
-
setUnselectedBackgroundColor
public void setUnselectedBackgroundColor(org.eclipse.swt.graphics.Color unselectedBackgroundColor)- Parameters:
unselectedBackgroundColor
- the background color of the left part of the widget (selection is on)- 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
-
getButtonBorderColor
public org.eclipse.swt.graphics.Color getButtonBorderColor()- Returns:
- the border color of the switch button
- 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
-
setButtonBorderColor
public void setButtonBorderColor(org.eclipse.swt.graphics.Color buttonBorderColor)- Parameters:
buttonBorderColor
- the border color of the switch button- 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
-
getButtonBackgroundColor1
public org.eclipse.swt.graphics.Color getButtonBackgroundColor1()- Returns:
- the first color of the toggle button
- 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
-
setButtonBackgroundColor1
public void setButtonBackgroundColor1(org.eclipse.swt.graphics.Color buttonBackgroundColor1)- Parameters:
buttonBackgroundColor1
- the first color of the toggle button- 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
-
getButtonBackgroundColor2
public org.eclipse.swt.graphics.Color getButtonBackgroundColor2()- Returns:
- the second color of the toggle button
- 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
-
setButtonBackgroundColor2
public void setButtonBackgroundColor2(org.eclipse.swt.graphics.Color buttonBackgroundColor2)- Parameters:
buttonBackgroundColor2
- the second color of the toggle button- 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
-
getGap
public int getGap()- Returns:
- the gap value
- 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
-
setGap
public void setGap(int gap)- Parameters:
gap
- the gap value to set- 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
-
getInsideMargin
public org.eclipse.swt.graphics.Point getInsideMargin()- Returns:
- the margin value
- 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
-
setInsideMargin
public void setInsideMargin(int insideMarginX, int insideMarginY)- Parameters:
insideMarginX
- the new margin value (horizontal)insideMarginY
- the new margin value (vertical)- 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
-
setInsideMargin
public void setInsideMargin(org.eclipse.swt.graphics.Point insideMargin)- Parameters:
insideMargin
- the new margin value- 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
-
getArc
public int getArc()- Returns:
- the arc value
- 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
-
setArc
public void setArc(int arc)- Parameters:
arc
- the arc value to set- 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
-