Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Rich Ajax Platform
Release 1.2

org.eclipse.swt.custom
Class CLabel


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

org.eclipse.swt.widgets.Canvas
                      extended by
org.eclipse.swt.custom.CLabel
All Implemented Interfaces:
Adaptable

public class CLabel
extends Canvas

A Label which supports aligned text and/or an image and different border styles.

If there is not enough space a CLabel uses the following strategy to fit the information into the available space:

 		ignores the indent in left align mode
 		ignores the image and the gap
 		shortens the text by replacing the center portion of the label with an ellipsis
 		shortens the text by removing the center portion of the label
 

Styles:
LEFT, RIGHT, CENTER, SHADOW_IN, SHADOW_OUT, SHADOW_NONE
Events:

IMPORTANT: This class is not intended to be subclassed.

Since:
1.0

Constructor Summary
CLabel ( 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
  Point computeSize (int wHint, int hHint, boolean changed)
          Returns the preferred size of the receiver.
 int getAlignment ()
          Returns the alignment.
  Image getImage ()
          Return the CLabel's image or null.
 int getStyle ()
          Returns the receiver's style information.
  String getText ()
          Return the Label's text.
  String getToolTipText ()
          Returns the receiver's tool tip text, or null if it has not been set.
 void setAlignment (int align)
          Set the alignment of the CLabel.
 void setBackground ( Color color)
          Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setBackground ( Image image)
          Set the image to be drawn in the background of the label.
 void setFont ( Font font)
          Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
 void setImage ( Image image)
          Set the label's Image.
 void setText ( String text)
          Set the label's text.
 void setToolTipText ( 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.
 
Methods inherited from class org.eclipse.swt.widgets. Composite
changed, getAdapter, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets. Scrollable
computeTrim, getClientArea
 
Methods inherited from class org.eclipse.swt.widgets. Control
addControlListener, addFocusListener, addKeyListener, addMouseListener, addTraverseListener, computeSize, forceFocus, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getVisible, isEnabled, isFocusControl, isVisible, moveAbove, moveBelow, pack, pack, redraw, removeControlListener, removeFocusListener, removeKeyListener, removeMouseListener, removeTraverseListener, setBackgroundImage, setBounds, setBounds, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setRedraw, setSize, setSize, setVisible, toControl, toControl, toDisplay, toDisplay
 
Methods inherited from class org.eclipse.swt.widgets. Widget
addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, isDisposed, notifyListeners, removeDisposeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CLabel

public CLabel(
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:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the parent is null
SWTException -
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
See Also:
SWT.LEFT, SWT.RIGHT, SWT.CENTER, SWT.SHADOW_IN, SWT.SHADOW_OUT, SWT.SHADOW_NONE, getStyle()
Method Detail

computeSize

public 
Point computeSize(int wHint,
                         int hHint,
                         boolean changed)
Description copied from class: Control
Returns the preferred size of the receiver.

The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant SWT.DEFAULT is passed for the hint.

If the changed flag is true, it indicates that the receiver's contents have changed, therefore any caches that a layout manager containing the control may have been keeping need to be flushed. When the control is resized, the changed flag will be false, so layout manager caches can be retained.

Overrides:
computeSize in class Composite

getAlignment

public int getAlignment()
Returns the alignment. The alignment style (LEFT, CENTER or RIGHT) is returned.

Returns:
SWT.LEFT, SWT.RIGHT or SWT.CENTER

getImage

public 
Image getImage()
Return the CLabel's image or null.

Returns:
the image of the label or null

getStyle

public int getStyle()
Description copied from class: Widget
Returns the receiver's style information.

Note that the value which is returned by this method may not match the value which was provided to the constructor when the receiver was created. This can occur when the underlying operating system does not support a particular combination of requested styles. For example, if the platform widget used to implement a particular SWT widget always has scroll bars, the result of calling this method would always have the SWT.H_SCROLL and SWT.V_SCROLL bits set.

Overrides:
getStyle in class Widget
Returns:
the style bits

getText

public 
String getText()
Return the Label's text.

Returns:
the text of the label or null

getToolTipText

public 
String getToolTipText()
Description copied from class: Control
Returns the receiver's tool tip text, or null if it has not been set.

Overrides:
getToolTipText in class Control
Returns:
the receiver's tool tip text

setAlignment

public void setAlignment(int align)
Set the alignment of the CLabel. Use the values LEFT, CENTER and RIGHT to align image and text within the available space.

Parameters:
align - the alignment style of LEFT, RIGHT or CENTER
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • ERROR_INVALID_ARGUMENT - if the value of align is not one of SWT.LEFT, SWT.RIGHT or SWT.CENTER

setBackground

public void setBackground(
Color color)
Description copied from class: Control
Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

Overrides:
setBackground in class Control
Parameters:
color - the new color (or null)

setBackground

public void setBackground(
Image image)
Set the image to be drawn in the background of the label.

Parameters:
image - the image to be drawn in the background
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setFont

public void setFont(
Font font)
Description copied from class: Control
Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.

Overrides:
setFont in class Control
Parameters:
font - the new font (or null)

setImage

public void setImage(
Image image)
Set the label's Image. The value null clears it.

Parameters:
image - the image to be displayed in the label or null
Throws:
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(
String text)
Set the label's text. The value null clears it.

Parameters:
text - the text to be displayed in the label or null
Throws:
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(
String string)
Description copied from class: Control
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 Control
Parameters:
string - the new tool tip text (or null)

Eclipse Rich Ajax Platform
Release 1.2

Copyright (c) Innoopract Informationssysteme GmbH and others 2002, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire