MouseEvent: x : MouseEvent « org.eclipse.swt.events « Java by API






MouseEvent: x


import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class MainClass {

  public static void main(String[] a) {
    Display d = new Display();
    final Shell s = new Shell(d);

    s.setSize(250, 200);
    s.setText("A MouseListener Example");
    s.open();

    s.addMouseListener(new MouseListener() {
      public void mouseDown(MouseEvent e) {
        System.out.println("Mouse Button Down at:" + e.x + " " + e.y);

      }

      public void mouseUp(MouseEvent e) {
        System.out.println("Mouse Button up at:" + e.x + " " + e.y);
        System.out.println(e.button);
        
      }

      public void mouseDoubleClick(MouseEvent e) {
        System.out.println("Mouse Double Clicked at:" + e.x + " " + e.y);
      }
    });

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

  }
}

           
       








Related examples in the same category

1.MouseEvent: button
2.MouseEvent: y