Class BadgedLabel

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.badgedlabel.BadgedLabel
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class BadgedLabel
extends org.eclipse.swt.widgets.Canvas
Instances of this class represent a non-selectable user interface object that displays a string or image. A badge is displayed on this label, so you can add extra information (the most common used is a notification label that shows the number of unread notifications).
Styles:
SWT.BORDER
SWT.LEFT or SWT.RIGHT (horizontal location)
SWT.TOP or SWT.BOTTOM (vertical location)
Events:
(none)
  • Field Summary

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

    handle
  • Constructor Summary

    Constructors 
    Constructor Description
    BadgedLabel​(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
    org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)  
    org.eclipse.swt.graphics.Color getBackgroundColor()
    Returns the background color that the receiver will use to draw.
    org.eclipse.swt.graphics.Color getBadgeBackground()
    Returns the background color that the badge will use to draw.
    org.eclipse.swt.graphics.Color getBadgeForeground()
    Returns the foreground color that the badge will use to draw.
    java.lang.String getBadgeValue()
    Returns the text of the badge
    org.eclipse.swt.graphics.Color getBorderColor()
    Returns the border color that the receiver will use to draw.
    org.eclipse.swt.graphics.Image getImage()
    Returns the receiver's image if it has one, or null if it does not.
    java.lang.String getText()
    Returns the receiver's text, which will be an empty string if it has never been set or if the receiver is a SEPARATOR label.
    org.eclipse.swt.graphics.Color getTextColor()
    Returns the text color that the receiver will use to draw.
    void setBackgroundColor​(org.eclipse.swt.graphics.Color backgroundColor)
    Sets the receiver's background color to the color specified by the argument
    void setBadgeBackground​(org.eclipse.swt.graphics.Color badgeBackground)
    Sets the badge's background color to the color specified by the argument
    void setBadgeForeground​(org.eclipse.swt.graphics.Color badgeForeground)
    Sets the badge's foreground color to the color specified by the argument
    void setBadgeValue​(java.lang.String value)
    Sets the badge's value (text) to the text specified by the argument
    void setBorderColor​(org.eclipse.swt.graphics.Color borderColor)
    Sets the receiver's border color to the color specified by the argument
    void setEnabled​(boolean enabled)  
    void setFont​(org.eclipse.swt.graphics.Font font)  
    void setImage​(org.eclipse.swt.graphics.Image image)
    Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.
    void setPredefinedColor​(int color)
    Sets the badge's color theme to the theme specified by the argument
    void setText​(java.lang.String text)
    Sets the receiver's text.
    void setTextColor​(org.eclipse.swt.graphics.Color textColor)
    Sets the receiver's text color to the color specified by the argument

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

    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

    • BadgedLabel

      public BadgedLabel​(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 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
      • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
  • Method Details

    • setPredefinedColor

      public void setPredefinedColor​(int color)
      Sets the badge's color theme to the theme specified by the argument
      Parameters:
      color - the new color, can pick one of the following value: SWT.COLOR_BLUE, SWT.COLOR_GRAY, SWT.COLOR_GREEN, SWT.COLOR_RED, SWT.COLOR_YELLOW, SWT.COLOR_CYAN, SWT.COLOR_BLACK
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the argument 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
    • computeSize

      public org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)
      Overrides:
      computeSize in class org.eclipse.swt.widgets.Control
      See Also:
      Control.computeSize(int, int, boolean)
    • getBackgroundColor

      public org.eclipse.swt.graphics.Color getBackgroundColor()
      Returns the background color that the receiver will use to draw.
      Returns:
      the receiver's background color
      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
    • getBadgeBackground

      public org.eclipse.swt.graphics.Color getBadgeBackground()
      Returns the background color that the badge will use to draw.
      Returns:
      the badge's backdground color
      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
    • getBadgeForeground

      public org.eclipse.swt.graphics.Color getBadgeForeground()
      Returns the foreground color that the badge will use to draw.
      Returns:
      the badge's foreground color
      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
    • getBadgeValue

      public java.lang.String getBadgeValue()
      Returns the text of the badge
      Returns:
      the badge's text
      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 color that the receiver will use to draw.
      Returns:
      the receiver's border color
      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
    • getImage

      public org.eclipse.swt.graphics.Image getImage()
      Returns the receiver's image if it has one, or null if it does not.
      Returns:
      the receiver's image
      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 receiver's text, which will be an empty string if it has never been set or if the receiver is a SEPARATOR label.
      Returns:
      the receiver's text
      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
    • getTextColor

      public org.eclipse.swt.graphics.Color getTextColor()
      Returns the text color that the receiver will use to draw.
      Returns:
      the receiver's text color
      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
    • setBackgroundColor

      public void setBackgroundColor​(org.eclipse.swt.graphics.Color backgroundColor)
      Sets the receiver's background color to the color specified by the argument
      Parameters:
      color - the new color
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the argument has been disposed
      • ERROR_NULL_ARGUMENT - if the argument 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
    • setBadgeBackground

      public void setBadgeBackground​(org.eclipse.swt.graphics.Color badgeBackground)
      Sets the badge's background color to the color specified by the argument
      Parameters:
      color - the new color
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the argument has been disposed
      • ERROR_NULL_ARGUMENT - if the argument 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
    • setBadgeForeground

      public void setBadgeForeground​(org.eclipse.swt.graphics.Color badgeForeground)
      Sets the badge's foreground color to the color specified by the argument
      Parameters:
      color - the new color
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the argument has been disposed
      • ERROR_NULL_ARGUMENT - if the argument 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
    • setBadgeValue

      public void setBadgeValue​(java.lang.String value)
      Sets the badge's value (text) to the text specified by the argument
      Parameters:
      value - the new text value
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the argument 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
    • setBorderColor

      public void setBorderColor​(org.eclipse.swt.graphics.Color borderColor)
      Sets the receiver's border color to the color specified by the argument
      Parameters:
      color - the new color
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the argument has been disposed
      • ERROR_NULL_ARGUMENT - if the argument 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
    • setEnabled

      public void setEnabled​(boolean enabled)
      Overrides:
      setEnabled in class org.eclipse.swt.widgets.Control
      See Also:
      Control.setEnabled(boolean)
    • setFont

      public void setFont​(org.eclipse.swt.graphics.Font font)
      Overrides:
      setFont in class org.eclipse.swt.widgets.Canvas
      See Also:
      Canvas.setFont(org.eclipse.swt.graphics.Font)
    • setImage

      public void setImage​(org.eclipse.swt.graphics.Image image)
      Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.
      Parameters:
      image - the image to display on the receiver (may be null)
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the image has been disposed
      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)
      Sets the receiver's text.

      This method sets the widget label. The label may include the mnemonic character and 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, focus is assigned to the control that follows the label. 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.

      Note: If control characters like '\n', '\t' etc. are used in the string, then the behavior is platform dependent.

      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
    • setTextColor

      public void setTextColor​(org.eclipse.swt.graphics.Color textColor)
      Sets the receiver's text color to the color specified by the argument
      Parameters:
      color - the new color
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the argument has been disposed
      • ERROR_NULL_ARGUMENT - if the argument 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