tabs
Class ColorChooserButton

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by tabs.ColorChooserButton
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

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

Instances of this class are controls that allow the user to choose an item from a list of items. Often, ColorChooserButtons are used in the same place where a single selection Table widget could be used but space is limited. A ColorChooserButton takes less space than a Table widget and shows similar information.

Note that although this class is a subclass of Composite, it does not make sense to add children to it, or set a layout on it.

See Also:
Table

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
ColorChooserButton(org.eclipse.swt.widgets.Composite parent, int[] columnWidth)
          Create a new instance of ColorChooserButton, given it's parent composite and the columns widths
 
Method Summary
 void addMouseListener(org.eclipse.swt.events.MouseListener listener)
          Adds the listener to the collection of listeners who will be notified when mouse buttons are pressed and released, by sending it one of the messages defined in the MouseListener interface.
 org.eclipse.swt.widgets.TableItem addTableItem(int style)
          Constructs a new instance of TableItem class given a style value describing its behavior and appearance.
 void addTableSelectionListener(org.eclipse.swt.events.SelectionAdapter listener)
           
 void deselect()
          Deselects selected item in the receiver.
 int getSelectionIndex()
          Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.
 void select(int index)
          Selects the item at the given zero-relative index in the receiver's table list.
 void setLayout(org.eclipse.swt.widgets.Layout layout)
          Sets the layout which is associated with the receiver to be the argument which may be null.
 void setPageIncrement(int value)
          Sets the amount that the receiver's value will be modified by when the page increment/decrement areas are selected to the argument, which must be at least one.
 void setText(java.lang.String string)
          Sets the receiver's text.
 void setToolTipText(java.lang.String string)
          Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.
 void setVisibleItemCount(int count)
          Sets the number of items that are visible in the drop down portion of the receiver's list.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColorChooserButton

public ColorChooserButton(org.eclipse.swt.widgets.Composite parent,
                          int[] columnWidth)
Create a new instance of ColorChooserButton, given it's parent composite and the columns widths

Parameters:
parent - the parent composite
columnWidth - the column widths array
Method Detail

setLayout

public void setLayout(org.eclipse.swt.widgets.Layout layout)
Sets the layout which is associated with the receiver to be the argument which may be null.

Overrides:
setLayout in class org.eclipse.swt.widgets.Composite
Parameters:
layout - the receiver's new layout or null
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 string)
Sets the receiver's text.

This method sets the button label. The label may include the mnemonic character but must not contain line delimiters.

Mnemonics are indicated by an '&' that causes the next character to be the mnemonic. When the user presses a key sequence that matches the mnemonic, a selection event occurs. On most platforms, the mnemonic appears underlined but may be emphasised in a platform specific manner. The mnemonic indicator character '&' can be escaped by doubling it in the string, causing a single '&' to be displayed.

Parameters:
string - the new text
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the text 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

setToolTipText

public void setToolTipText(java.lang.String string)
Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.

Overrides:
setToolTipText in class org.eclipse.swt.widgets.Control
Parameters:
string - the new tool tip text (or null)
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

setVisibleItemCount

public void setVisibleItemCount(int count)
Sets the number of items that are visible in the drop down portion of the receiver's list. A value of 0 or a negative value means all items

The default visible item count value is 5

Parameters:
count - the new number of items to be visible

addTableItem

public org.eclipse.swt.widgets.TableItem addTableItem(int style)
Constructs a new instance of TableItem class given a style value describing its behavior and appearance. The item is added to the end of the items maintained by the ColorChooserButton.

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:
style - the style of item to construct
Returns:
the instance o the created TableItem
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, Widget.getStyle()

setPageIncrement

public void setPageIncrement(int value)
Sets the amount that the receiver's value will be modified by when the page increment/decrement areas are selected to the argument, which must be at least one.

The default page increment value is 5

Parameters:
pageIncrement - the page increment (must be greater than zero)
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

select

public void select(int index)
Selects the item at the given zero-relative index in the receiver's table 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

deselect

public void deselect()
Deselects selected item in the receiver.

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, 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

addTableSelectionListener

public void addTableSelectionListener(org.eclipse.swt.events.SelectionAdapter listener)

addMouseListener

public void addMouseListener(org.eclipse.swt.events.MouseListener listener)
Adds the listener to the collection of listeners who will be notified when mouse buttons are pressed and released, by sending it one of the messages defined in the MouseListener interface.

Overrides:
addMouseListener in class org.eclipse.swt.widgets.Control
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:
MouseListener, Control.removeMouseListener(org.eclipse.swt.events.MouseListener)