Java by API/org.eclipse.swt.events/MouseTrackAdapter

Материал из Java эксперт
Перейти к: навигация, поиск

implements MouseTrackAdapter

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
  public static void main(String[] a) {
    final Display d = new Display();
    final Shell s = new Shell(d);
    s.setSize(250, 200);
    s.setText("A MouseTrackListener Example");
    s.open();
    s.addMouseTrackListener(new MouseTrackAdapter() {
      public void mouseEnter(MouseEvent e) {
        System.out.println("enter");
      }
      public void mouseExit(MouseEvent e) {
        System.out.println("exit");
      }
    });
    while (!s.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }
}