Label Highlighting 3 : Label « SWT JFace Eclipse « Java

Label Highlighting 3

Label Highlighting 3

 * Copyright (c) 1998, 2004 Jackwind Li Guojie
 * All right reserved. 
 * Created on Oct 28, 2003 8:10:30 PM by JACK
 * $Id:,v 1.1 2003/12/22 12:07:54 jackwind Exp $
 * visit:

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class LabelHighlighting3 {
  Display display = new Display();
  Shell shell = new Shell(display);
  Label label = new Label(shell, SWT.SHADOW_IN | SWT.CENTER);
  MouseTrackListener listener = new MouseEnterExitListener();
  public LabelHighlighting3() {
    label.setText("Point your cursor here ...");
    label.setBounds(30, 30, 200, 30);
    shell.setText("Move your cursor to test ...");
    shell.setSize(260, 120);;    
    while(! shell.isDisposed()) {
      if(! display.readAndDispatch()) {// If no more entries in event queue
  class MouseEnterExitListener extends MouseTrackAdapter {
    public void mouseEnter(MouseEvent e) {
      display.syncExec(new Runnable() {
        public void run() {
          label.setText("Cursor enters the label");


    public void mouseExit(MouseEvent arg0) {
      display.syncExec(new Runnable() {
        public void run() {
          label.setText("Cursor leaves the label");

  public static void main(String[] args) {
    new LabelHighlighting3();


Related examples in the same category

1.First SWT: LabelFirst SWT: Label
2.SWT Label With TextSWT Label With Text
3.Label HighlightingLabel Highlighting
4.Label Highlighting 2Label Highlighting 2
5.CLabel BorderCLabel Border
6.CLabel Gradient Background CLabel Gradient Background
7.Label SeparatorLabel Separator
8.Label WrapLabel Wrap
9.Text and Label demoText and Label demo
10.Formatted TextFormatted Text
11.Demonstrates LabelsDemonstrates Labels
12.Demonstrates CLabel gradientsDemonstrates CLabel gradients
13.Demonstrates CLabel 2Demonstrates CLabel 2
14.Demonstrates CLabelDemonstrates CLabel
15.Create a label (a separator)Create a label (a separator)
16.Create a label (with an image)Create a label (with an image) to resize the Label when the Shell resizes using a Listener mechanismhow to resize the Label when the Shell resizes using a Listener mechanism
18.How to resize the Label when the Shell resizes using a LayoutHow to resize the Label when the Shell resizes using a Layout