2011-11-03, 18:49
#1
Läs under som norrut och under som "pappret ligger på bordet alltså är bordet under pappret", typ..
Nu är det så att jag sitter o försöker placera ut ett JWindow objekt under ett JTextField objekt. Hur jag än försöker så placeras mitt JWindow bakom mitt JTextField och börjar ritas från samma Point (se setLocation()) som det verkar.
Försökte förstå api:n men fick inte ihop det:
Är det någon som vet "the way to go"?
Kan även tillägga att när jag hämtar locationOnScreen från JTextField så är det de värdet plus höjden på samma objekt jag vill ange hos JWindow, setLocation verkar inte ge detta.
Nu är det så att jag sitter o försöker placera ut ett JWindow objekt under ett JTextField objekt. Hur jag än försöker så placeras mitt JWindow bakom mitt JTextField och börjar ritas från samma Point (se setLocation()) som det verkar.
Försökte förstå api:n men fick inte ihop det:
Citat:
In such an environment, when calling setLocation, you must pass a virtual coordinate to this method. Similarly, calling getLocationOnScreen on a Window returns virtual device coordinates. Call the getBounds method of a GraphicsConfiguration to find its origin in the virtual coordinate system.
The following code sets the location of a Window at (10, 10) relative to the origin of the physical screen of the corresponding GraphicsConfiguration. If the bounds of the GraphicsConfiguration is not taken into account, the Window location would be set at (10, 10) relative to the virtual-coordinate system and would appear on the primary physical screen, which might be different from the physical screen of the specified GraphicsConfiguration.
Window w = new Window(Window owner, GraphicsConfiguration gc);
Rectangle bounds = gc.getBounds();
w.setLocation(10 + bounds.x, 10 + bounds.y);
The following code sets the location of a Window at (10, 10) relative to the origin of the physical screen of the corresponding GraphicsConfiguration. If the bounds of the GraphicsConfiguration is not taken into account, the Window location would be set at (10, 10) relative to the virtual-coordinate system and would appear on the primary physical screen, which might be different from the physical screen of the specified GraphicsConfiguration.
Window w = new Window(Window owner, GraphicsConfiguration gc);
Rectangle bounds = gc.getBounds();
w.setLocation(10 + bounds.x, 10 + bounds.y);
Är det någon som vet "the way to go"?
Kan även tillägga att när jag hämtar locationOnScreen från JTextField så är det de värdet plus höjden på samma objekt jag vill ange hos JWindow, setLocation verkar inte ge detta.