2011-11-03, 18:49
#1
Ls under som norrut och under som "pappret ligger p bordet allts r bordet under pappret", typ..
Nu r det s att jag sitter o frsker placera ut ett JWindow objekt under ett JTextField objekt. Hur jag n frsker s placeras mitt JWindow bakom mitt JTextField och brjar ritas frn samma Point (se setLocation()) som det verkar.
Frskte frst api:n men fick inte ihop det:
r det ngon som vet "the way to go"?
Kan ven tillgga att nr jag hmtar locationOnScreen frn JTextField s r det de vrdet plus hjden p samma objekt jag vill ange hos JWindow, setLocation verkar inte ge detta.
Nu r det s att jag sitter o frsker placera ut ett JWindow objekt under ett JTextField objekt. Hur jag n frsker s placeras mitt JWindow bakom mitt JTextField och brjar ritas frn samma Point (se setLocation()) som det verkar.
Frskte frst 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 ngon som vet "the way to go"?
Kan ven tillgga att nr jag hmtar locationOnScreen frn JTextField s r det de vrdet plus hjden p samma objekt jag vill ange hos JWindow, setLocation verkar inte ge detta.