List of usage examples for org.eclipse.swt.widgets Display getCursorLocation
public Point getCursorLocation()
From source file:DialogShellPositionIt.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Point pt = display.getCursorLocation(); dialog.setLocation(pt.x, pt.y);/*from ww w .j av a 2 s . c o m*/ dialog.setText("Dialog Shell"); dialog.setSize(100, 100); dialog.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TimerRepeating.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final int time = 500; Runnable timer = new Runnable() { public void run() { Point point = display.getCursorLocation(); Rectangle rect = shell.getBounds(); if (rect.contains(point)) { System.out.println("In"); } else { System.out.println("Out"); }/*from www .ja v a 2 s. c o m*/ display.timerExec(time, this); } }; display.timerExec(time, timer); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet233.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Parent Shell"); shell.addMouseListener(mouseDownAdapter(e -> { Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Point pt = display.getCursorLocation(); dialog.setLocation(pt.x, pt.y);//from w ww.ja v a2 s . c o m dialog.setText("Dialog Shell"); dialog.setSize(100, 100); dialog.open(); })); shell.setSize(400, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet16.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 16"); final int time = 500; Runnable timer = new Runnable() { @Override/*from ww w . ja v a2s .co m*/ public void run() { if (shell.isDisposed()) return; Point point = display.getCursorLocation(); Rectangle rect = shell.getBounds(); if (rect.contains(point)) { System.out.println("In"); } else { System.out.println("Out"); } display.timerExec(time, this); } }; display.timerExec(time, timer); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet221.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 221"); shell.setLayout(new FillLayout()); final Tree tree = new Tree(shell, SWT.FULL_SELECTION | SWT.BORDER); tree.setHeaderVisible(true);//from w w w. java 2 s . c om TreeColumn column0 = new TreeColumn(tree, SWT.LEFT); column0.setText("Column 0"); TreeColumn column1 = new TreeColumn(tree, SWT.LEFT); column1.setText("Column 1"); TreeColumn column2 = new TreeColumn(tree, SWT.LEFT); column2.setText("Column 2"); for (int i = 0; i < 9; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("item " + i); item.setText(1, "column 1 - " + i); item.setText(2, "column 2 - " + i); for (int j = 0; j < 9; j++) { TreeItem subItem = new TreeItem(item, SWT.NONE); subItem.setText("item " + i + " " + j); subItem.setText(1, "column 1 - " + i + " " + j); subItem.setText(2, "column 2 - " + i + " " + j); for (int k = 0; k < 9; k++) { TreeItem subsubItem = new TreeItem(subItem, SWT.NONE); subsubItem.setText("item " + i + " " + j + " " + k); subsubItem.setText(1, "column 1 - " + i + " " + j + " " + k); subsubItem.setText(2, "column 2 - " + i + " " + j + " " + k); } } } column0.pack(); column1.pack(); column2.pack(); Heartbeat = () -> { if (!Tracking || tree.isDisposed()) return; Point cursor = display.getCursorLocation(); cursor = display.map(null, tree, cursor); Scroll(tree, cursor.x, cursor.y); display.timerExec(ScrollSpeed, Heartbeat); }; Listener listener = event -> { switch (event.type) { case SWT.MouseEnter: Tracking = true; display.timerExec(0, Heartbeat); break; case SWT.MouseExit: Tracking = false; break; } }; tree.addListener(SWT.MouseEnter, listener); tree.addListener(SWT.MouseExit, listener); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }