Mouse Track Example : Mouse Key « SWT JFace Eclipse « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » SWT JFace Eclipse » Mouse Key 




Mouse Track Example


import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class MouseTrackExample {

  final Display d;

  final Shell s;

  public MouseTrackExample() {
    d = new Display();
    s = new Shell(d);

    s.setSize(250200);
    
    s.setText("A MouseTrackListener Example");
    final Button b = new Button(s, SWT.PUSH);
    b.setText("Push Me");
    b.setBounds(20505525);
    s.open();
    final Color oldColor = b.getBackground();

    b.addMouseTrackListener(new MouseTrackAdapter() {
      public void mouseEnter(MouseEvent e) {
        b.setBackground(new Color(d, 0153153));

      }

      public void mouseExit(MouseEvent e) {
        b.setBackground(oldColor);
      }
    });

    while (!s.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }

  public static void main() {
    new MouseTrackExample();
  }

}


           
       














Related examples in the same category
1.Mouse Move Listener Example
2.Mouse Listener Example
3.SWT Mouse: A tracker (drag when 'torn off')SWT Mouse: A tracker (drag when 'torn off')
4.SWT Mouse : drag on mouse downSWT Mouse : drag on mouse down
5.UI Automation (for testing tools) snippet: post key eventsUI Automation (for testing tools) snippet: post key events
6.UI Automation (for testing tools) snippet: post mouse eventsUI Automation (for testing tools) snippet: post mouse events
7.Detect mouse enter, exit and hover eventsDetect mouse enter, exit and hover events
8.Intercept mouse events (drag a button with the mouse)Intercept mouse events (drag a button with the mouse)
9.How to implement hover help feedback using the MouseTrackListenerHow to implement hover help feedback using the MouseTrackListener
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.