ERLEDIGT
NEIN
NEIN
ANTWORTEN
2
2
ZUGRIFFE
1008
1008
EMPFEHLEN
-
13.03.07 20:12 #1
- Registriert seit
- Mar 2007
- Beiträge
- 10
Hallo Wissende,
ich habe folgendes Problem:
Im Rahmen meines Praktikums habe ich folgende Aufgabenstellung erhalten: Ich sollte eine graf. Oberfläche mit dem SWT und Einbettung eines Browser-Objektes erzeugen. Dannach per URL auf einen Map-Server zugreifen und das entsprechende Template (eine HTML-Datei) anzeigen lassen. Hat soweit alles super geklappt --- ABER NUN soll ich über die Mouseposition die entsprechenden Koordinaten in Textfeldern darstellen. Wie ermittle ich überhabt die jeweilige Mose-Position über dem Browser-Objekt? Dannach kann ich ja erst mit der Koordinatenumrechnung beginnen. Bin schon voll am verzweifeln, da ich ja erst Java / SWT - Neueinsteiger bin HILFFFEE!
Danke im Voraus
-
15.03.07 00:53 #2
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo,
hui, dass ist gar nicht so einfach, da das Browser Widget scheinbar keine MouseMoveEvents schickt...
schau mal hier:
(Aus einem anderen Thread)
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
/** * */ package de.tutorials; import java.util.concurrent.Executors; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; /** * @author Tom */ public class SWTBrowserMouseCoordinatesExample { /** * @param args */ public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText("SWTBrowserMouseCoordinatesExample"); final Browser browser = new Browser(shell, SWT.NONE); browser.setUrl("http://www.tutorials.de"); Executors.newSingleThreadExecutor().execute(new Runnable() { public void run() { Point oldCursorLocation = null; while (true) { final Point[] point = new Point[1]; display.syncExec(new Runnable(){ public void run() { point[0] = display.getCursorLocation(); } }); final Point currentCursorLocation = point[0]; if (null != oldCursorLocation && !currentCursorLocation.equals(oldCursorLocation)) { display.syncExec(new Runnable(){ public void run() { point[0] = display.map(null, browser, currentCursorLocation); } }); Point cursorLocatitonWithinBrowserWidget =point[0]; System.out.println(currentCursorLocation +" -> " + cursorLocatitonWithinBrowserWidget); } oldCursorLocation = currentCursorLocation; } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } System.exit(0); } }
Im UI Thread:
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
/** * */ package de.tutorials; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; /** * @author Tom */ public class SWTBrowserMouseCoordinatesExample { /** * @param args */ public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText("SWTBrowserMouseCoordinatesExample"); final Browser browser = new Browser(shell, SWT.NONE); browser.setUrl("http://www.tutorials.de"); shell.open(); Point oldCursorLocation = null; while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } else { Point currentCursorLocation = display.getCursorLocation(); if (null != oldCursorLocation && !currentCursorLocation.equals(oldCursorLocation)) { Point cursorLocatitonWithinBrowserWidget = display.map(null, browser, currentCursorLocation); System.out.println(currentCursorLocation + " -> " + cursorLocatitonWithinBrowserWidget); } oldCursorLocation = currentCursorLocation; } } System.exit(0); } }
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
-
15.03.07 08:36 #3
- Registriert seit
- Mar 2007
- Beiträge
- 10
Passt!! Vielen Dank für die schnelle Antwort
cheers Thomas
Ähnliche Themen
-
MousePosition Recorder
Von Blackhawk50000 im Forum .NET Windows FormsAntworten: 1Letzter Beitrag: 26.08.10, 21:19 -
JTable MousePosition nicht lesbar?!
Von ElJarno im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 2Letzter Beitrag: 17.08.10, 13:58 -
VB.NET Problem bei MousePosition
Von Shogoki92 im Forum .NET CaféAntworten: 6Letzter Beitrag: 13.10.08, 17:06 -
C# - MousePosition
Von kasal im Forum .NET Grafik und SoundAntworten: 3Letzter Beitrag: 21.02.06, 17:37 -
Probleme mit MousePosition
Von zioProduct im Forum .NET Windows FormsAntworten: 1Letzter Beitrag: 26.08.05, 11:31





Zitieren

Login





