Home » Eclipse-SWT-3.5.1 » org.eclipse.swt.widgets » [javadoc | source]
org.eclipse.swt.widgets
public class: Button [javadoc | source]
java.lang.Object
   org.eclipse.swt.widgets.Widget
      org.eclipse.swt.widgets.Control
         org.eclipse.swt.widgets.Button

All Implemented Interfaces:
    Drawable

Instances of this class represent a selectable user interface object that issues notification when pressed and released.
Styles:
ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT
UP, DOWN, LEFT, RIGHT, CENTER
Events:
Selection

Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE may be specified.

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

Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified when the ARROW style is specified.

IMPORTANT: This class is intended to be subclassed only within the SWT implementation.

Field Summary
 String text     
 String message     
 Image image     
 Image image2     
 Image disabledImage     
 ImageList imageList     
 boolean ignoreMouse     
 boolean grayed     
static final  int MARGIN     
static final  int CHECK_WIDTH     
static final  int CHECK_HEIGHT     
static final  int ICON_WIDTH     
static final  int ICON_HEIGHT     
static  boolean COMMAND_LINK     
static final  int ButtonProc     
static final  TCHAR ButtonClass     
Fields inherited from org.eclipse.swt.widgets.Control:
handle,  parent,  cursor,  menu,  toolTipText,  layoutData,  accessible,  backgroundImage,  region,  font,  drawCount,  foreground,  background
Fields inherited from org.eclipse.swt.widgets.Widget:
style,  state,  display,  eventTable,  data,  DISPOSED,  CANVAS,  KEYED_DATA,  DISABLED,  HIDDEN,  LAYOUT_NEEDED,  LAYOUT_CHANGED,  LAYOUT_CHILD,  THEME_BACKGROUND,  DRAW_BACKGROUND,  PARENT_BACKGROUND,  RELEASED,  DISPOSE_SENT,  TRACK_MOUSE,  FOREIGN_HANDLE,  DRAG_DETECT,  MOVE_OCCURRED,  MOVE_DEFERRED,  RESIZE_OCCURRED,  RESIZE_DEFERRED,  IGNORE_WM_CHANGEUISTATE,  DEFAULT_WIDTH,  DEFAULT_HEIGHT,  MAJOR,  MINOR
Constructor:
 public Button(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:
    IllegalArgumentException -
    • ERROR_NULL_ARGUMENT - if the parent is null

    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

    Also see:
    SWT#ARROW
    SWT#CHECK
    SWT#PUSH
    SWT#RADIO
    SWT#TOGGLE
    SWT#FLAT
    SWT#UP
    SWT#DOWN
    SWT#LEFT
    SWT#RIGHT
    SWT#CENTER
    Widget#checkSubclass
    Widget#getStyle
    exception: IllegalArgumentException -
    • ERROR_NULL_ARGUMENT - if the parent is null

    exception: 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

Method from org.eclipse.swt.widgets.Button Summary:
WM_ERASEBKGND,   WM_GETDLGCODE,   WM_KILLFOCUS,   WM_LBUTTONDOWN,   WM_LBUTTONUP,   WM_SETFOCUS,   WM_SIZE,   WM_SYSCOLORCHANGE,   WM_UPDATEUISTATE,   _setImage,   _setText,   addSelectionListener,   callWindowProc,   checkStyle,   click,   computeLeftMargin,   computeSize,   createHandle,   defaultBackground,   defaultForeground,   enableWidget,   getAlignment,   getDefault,   getGrayed,   getImage,   getMessage,   getNameText,   getSelection,   getText,   isTabItem,   mnemonicHit,   mnemonicMatch,   releaseWidget,   removeSelectionListener,   selectRadio,   setAlignment,   setDefault,   setFixedFocus,   setGrayed,   setImage,   setMessage,   setRadioFocus,   setRadioSelection,   setSavedFocus,   setSelection,   setText,   updateSelection,   widgetStyle,   windowClass,   windowProc,   wmColorChild,   wmCommandChild,   wmDrawChild
Methods from org.eclipse.swt.widgets.Control:
WM_ACTIVATE,   WM_CAPTURECHANGED,   WM_CHANGEUISTATE,   WM_CHAR,   WM_CLEAR,   WM_CLOSE,   WM_COMMAND,   WM_CONTEXTMENU,   WM_CTLCOLOR,   WM_CUT,   WM_DESTROY,   WM_DRAWITEM,   WM_ENDSESSION,   WM_ENTERIDLE,   WM_ERASEBKGND,   WM_GETDLGCODE,   WM_GETFONT,   WM_GETMINMAXINFO,   WM_GETOBJECT,   WM_HELP,   WM_HOTKEY,   WM_HSCROLL,   WM_IME_CHAR,   WM_IME_COMPOSITION,   WM_IME_COMPOSITION_START,   WM_IME_ENDCOMPOSITION,   WM_INITMENUPOPUP,   WM_INPUTLANGCHANGE,   WM_KEYDOWN,   WM_KEYUP,   WM_KILLFOCUS,   WM_LBUTTONDBLCLK,   WM_LBUTTONDOWN,   WM_LBUTTONUP,   WM_MBUTTONDBLCLK,   WM_MBUTTONDOWN,   WM_MBUTTONUP,   WM_MEASUREITEM,   WM_MENUCHAR,   WM_MENUSELECT,   WM_MOUSEACTIVATE,   WM_MOUSEHOVER,   WM_MOUSELEAVE,   WM_MOUSEMOVE,   WM_MOUSEWHEEL,   WM_MOVE,   WM_NCACTIVATE,   WM_NCCALCSIZE,   WM_NCHITTEST,   WM_NCLBUTTONDOWN,   WM_NCPAINT,   WM_NOTIFY,   WM_PAINT,   WM_PALETTECHANGED,   WM_PARENTNOTIFY,   WM_PASTE,   WM_PRINT,   WM_PRINTCLIENT,   WM_QUERYENDSESSION,   WM_QUERYNEWPALETTE,   WM_QUERYOPEN,   WM_RBUTTONDBLCLK,   WM_RBUTTONDOWN,   WM_RBUTTONUP,   WM_SETCURSOR,   WM_SETFOCUS,   WM_SETFONT,   WM_SETREDRAW,   WM_SETTINGCHANGE,   WM_SHOWWINDOW,   WM_SIZE,   WM_SYSCHAR,   WM_SYSCOLORCHANGE,   WM_SYSCOMMAND,   WM_SYSKEYDOWN,   WM_SYSKEYUP,   WM_TIMER,   WM_UNDO,   WM_UPDATEUISTATE,   WM_VSCROLL,   WM_WINDOWPOSCHANGED,   WM_WINDOWPOSCHANGING,   WM_XBUTTONDBLCLK,   WM_XBUTTONDOWN,   WM_XBUTTONUP,   addControlListener,   addDragDetectListener,   addFocusListener,   addHelpListener,   addKeyListener,   addMenuDetectListener,   addMouseListener,   addMouseMoveListener,   addMouseTrackListener,   addMouseWheelListener,   addPaintListener,   addTraverseListener,   borderHandle,   checkBackground,   checkBorder,   checkBuffered,   checkComposited,   checkHandle,   checkMirrored,   computeSize,   computeSize,   computeTabGroup,   computeTabList,   computeTabRoot,   createHandle,   createWidget,   defaultBackground,   defaultFont,   defaultForeground,   deregister,   destroyWidget,   dragDetect,   dragDetect,   dragDetect,   drawBackground,   drawBackground,   drawBackground,   drawImageBackground,   drawThemeBackground,   enableDrag,   enableWidget,   fillBackground,   fillImageBackground,   fillThemeBackground,   findBackgroundControl,   findBrush,   findCursor,   findImageControl,   findMenus,   findMnemonic,   findThemeControl,   fixChildren,   fixFocus,   forceFocus,   forceResize,   getAccessible,   getBackground,   getBackgroundImage,   getBackgroundPixel,   getBorderWidth,   getBounds,   getClipboardText,   getCodePage,   getCursor,   getDragDetect,   getDrawing,   getEnabled,   getFont,   getForeground,   getForegroundPixel,   getLayoutData,   getLocation,   getMenu,   getMonitor,   getParent,   getPath,   getRegion,   getShell,   getSize,   getToolTipText,   getVisible,   hasCursor,   hasFocus,   internal_dispose_GC,   internal_new_GC,   isActive,   isEnabled,   isFocusAncestor,   isFocusControl,   isReparentable,   isShowing,   isTabGroup,   isTabItem,   isVisible,   mapEvent,   markLayout,   menuShell,   mnemonicHit,   mnemonicMatch,   moveAbove,   moveBelow,   new_Accessible,   new_GC,   pack,   pack,   print,   printWidget,   redraw,   redraw,   redraw,   redrawChildren,   register,   releaseHandle,   releaseParent,   releaseWidget,   removeControlListener,   removeDragDetectListener,   removeFocusListener,   removeHelpListener,   removeKeyListener,   removeMenuDetectListener,   removeMouseListener,   removeMouseMoveListener,   removeMouseTrackListener,   removeMouseWheelListener,   removePaintListener,   removeTraverseListener,   sendFocusEvent,   sendMove,   sendResize,   setBackground,   setBackground,   setBackgroundImage,   setBackgroundImage,   setBackgroundPixel,   setBounds,   setBounds,   setBounds,   setBounds,   setCapture,   setCursor,   setCursor,   setDefaultFont,   setDragDetect,   setEnabled,   setFixedFocus,   setFocus,   setFont,   setForeground,   setForegroundPixel,   setLayoutData,   setLocation,   setLocation,   setMenu,   setParent,   setRadioFocus,   setRadioSelection,   setRedraw,   setRegion,   setSavedFocus,   setSize,   setSize,   setTabItemFocus,   setToolTipText,   setToolTipText,   setVisible,   showWidget,   sort,   subclass,   toControl,   toControl,   toDisplay,   toDisplay,   topHandle,   translateAccelerator,   translateMnemonic,   translateMnemonic,   translateTraversal,   traverse,   traverse,   traverseEscape,   traverseGroup,   traverseItem,   traverseMnemonic,   traversePage,   traverseReturn,   unsubclass,   update,   update,   updateBackgroundColor,   updateBackgroundImage,   updateBackgroundMode,   updateFont,   updateImages,   updateLayout,   widgetCreateStruct,   widgetExtStyle,   widgetParent,   widgetStyle,   windowClass,   windowProc,   windowProc,   wmColorChild,   wmCommandChild,   wmDrawChild,   wmMeasureChild,   wmNotify,   wmNotifyChild,   wmScrollChild
Methods from org.eclipse.swt.widgets.Widget:
DeferWindowPos,   SetWindowPos,   _addListener,   addDisposeListener,   addListener,   callWindowProc,   checkBits,   checkOpened,   checkOrientation,   checkParent,   checkSubclass,   checkWidget,   destroyWidget,   dispose,   dragDetect,   error,   filters,   findItem,   fixMnemonic,   fixMnemonic,   getData,   getData,   getDisplay,   getListeners,   getMenu,   getName,   getNameText,   getStyle,   hooks,   isDisposed,   isListening,   isValidSubclass,   isValidThread,   mapEvent,   new_GC,   notifyListeners,   postEvent,   postEvent,   release,   releaseChildren,   releaseHandle,   releaseParent,   releaseWidget,   removeDisposeListener,   removeListener,   removeListener,   sendDragEvent,   sendDragEvent,   sendEvent,   sendEvent,   sendEvent,   sendEvent,   sendFocusEvent,   sendKeyEvent,   sendKeyEvent,   sendMouseEvent,   sendMouseEvent,   setData,   setData,   setInputState,   setKeyState,   setTabGroupFocus,   setTabItemFocus,   showMenu,   toString,   wmCaptureChanged,   wmChar,   wmContextMenu,   wmIMEChar,   wmKeyDown,   wmKeyUp,   wmKillFocus,   wmLButtonDblClk,   wmLButtonDown,   wmLButtonUp,   wmMButtonDblClk,   wmMButtonDown,   wmMButtonUp,   wmMouseHover,   wmMouseLeave,   wmMouseMove,   wmMouseWheel,   wmNCPaint,   wmPaint,   wmPrint,   wmRButtonDblClk,   wmRButtonDown,   wmRButtonUp,   wmSetFocus,   wmSysChar,   wmSysKeyDown,   wmSysKeyUp,   wmXButtonDblClk,   wmXButtonDown,   wmXButtonUp
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.eclipse.swt.widgets.Button Detail:
 LRESULT WM_ERASEBKGND(int wParam,
    int lParam) 
 LRESULT WM_GETDLGCODE(int wParam,
    int lParam) 
 LRESULT WM_KILLFOCUS(int wParam,
    int lParam) 
 LRESULT WM_LBUTTONDOWN(int wParam,
    int lParam) 
 LRESULT WM_LBUTTONUP(int wParam,
    int lParam) 
 LRESULT WM_SETFOCUS(int wParam,
    int lParam) 
 LRESULT WM_SIZE(int wParam,
    int lParam) 
 LRESULT WM_SYSCOLORCHANGE(int wParam,
    int lParam) 
 LRESULT WM_UPDATEUISTATE(int wParam,
    int lParam) 
  void _setImage(Image image) 
  void _setText(String text) 
 public  void addSelectionListener(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.

 int callWindowProc(int hwnd,
    int msg,
    int wParam,
    int lParam) 
 static int checkStyle(int style) 
  void click() 
 int computeLeftMargin() 
 public Point computeSize(int wHint,
    int hHint,
    boolean changed) 
  void createHandle() 
 int defaultBackground() 
 int defaultForeground() 
  void enableWidget(boolean enabled) 
 public int getAlignment() 
    Returns a value which describes the position of the text or image in the receiver. The value will be one of LEFT, RIGHT or CENTER unless the receiver is an ARROW button, in which case, the alignment will indicate the direction of the arrow (one of LEFT, RIGHT, UP or DOWN).
 boolean getDefault() 
 public boolean getGrayed() 
    Returns true if the receiver is grayed, and false otherwise. When the widget does not have the CHECK style, return false.
 public Image getImage() 
    Returns the receiver's image if it has one, or null if it does not.
 String getMessage() 
    Returns the widget message. When the widget is created with the style SWT.COMMAND, the message text is displayed to provide further information for the user.
 String getNameText() 
 public boolean getSelection() 
    Returns true if the receiver is selected, and false otherwise.

    When the receiver is of type CHECK or RADIO, it is selected when it is checked. When it is of type TOGGLE, it is selected when it is pushed in. If the receiver is of any other type, this method returns false.

 public String getText() 
    Returns the receiver's text, which will be an empty string if it has never been set or if the receiver is an ARROW button.
 boolean isTabItem() 
 boolean mnemonicHit(char ch) 
 boolean mnemonicMatch(char key) 
  void releaseWidget() 
 public  void removeSelectionListener(SelectionListener listener) 
    Removes the listener from the collection of listeners who will be notified when the control is selected by the user.
  void selectRadio() 
 public  void setAlignment(int alignment) 
    Controls how text, images and arrows will be displayed in the receiver. The argument should be one of LEFT, RIGHT or CENTER unless the receiver is an ARROW button, in which case, the argument indicates the direction of the arrow (one of LEFT, RIGHT, UP or DOWN).
  void setDefault(boolean value) 
 boolean setFixedFocus() 
 public  void setGrayed(boolean grayed) 
    Sets the grayed state of the receiver. This state change only applies if the control was created with the SWT.CHECK style.
 public  void setImage(Image image) 
    Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.

    Note that a Button can display an image and text simultaneously on Windows (starting with XP), GTK+ and OSX. On other platforms, a Button that has an image and text set into it will display the image or text that was set most recently.

  void setMessage(String message) 
    Sets the widget message. When the widget is created with the style SWT.COMMAND, the message text is displayed to provide further information for the user.
 boolean setRadioFocus(boolean tabbing) 
 boolean setRadioSelection(boolean value) 
 boolean setSavedFocus() 
 public  void setSelection(boolean selected) 
    Sets the selection state of the receiver, if it is of type CHECK, RADIO, or TOGGLE.

    When the receiver is of type CHECK or RADIO, it is selected when it is checked. When it is of type TOGGLE, it is selected when it is pushed in.

 public  void setText(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 emphasized in a platform specific manner. The mnemonic indicator character '&' can be escaped by doubling it in the string, causing a single '&' to be displayed.

    Note that a Button can display an image and text simultaneously on Windows (starting with XP), GTK+ and OSX. On other platforms, a Button that has an image and text set into it will display the image or text that was set most recently.

  void updateSelection(int flags) 
 int widgetStyle() 
 TCHAR windowClass() 
 int windowProc() 
 LRESULT wmColorChild(int wParam,
    int lParam) 
 LRESULT wmCommandChild(int wParam,
    int lParam) 
 LRESULT wmDrawChild(int wParam,
    int lParam)