aspose file tools
The moose likes Swing / AWT / SWT and the fly likes positioning of JFrames on the Screen Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "positioning of JFrames on the Screen" Watch "positioning of JFrames on the Screen" New topic
Author

positioning of JFrames on the Screen

trippyslippy
Greenhorn

Joined: May 07, 2001
Posts: 3

In the main window I have an image. when I click on a point in that image, i have a JFrame pops up with a with an image which is
the subimage of the orginal image, using the point selected (in
the orginal) as the center of the subimage. Well right now the subimage in the new frame pops up on the screens orgin (top-left). I want to position this new frame such that
the new frames center point is the point that was chosen on
the screen ( thus the orgin would be
[newFrame.getWidth() /2, newFrame.getHeight() /2]).
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Trippy,
Just set its location!
setSize( w,h );
setLocation( x, y );
setVisible( true );
Regards,
Manfred.
trippyslippy
Greenhorn

Joined: May 07, 2001
Posts: 3
well, i guess i should have been more clear...so here goes...
the is the heirachy of the image in the GUI
'=>' means that is contained in
image => JLabel => JScrollPane => JPanel => JFrame => screen(monitor)
and when i click on a point in the image how does that tranlate
thru the heirachy? coz once i have that i can determin where
to put the new frame on the screen
thanks fro the speed reply thou..
danny
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Danny,
I don't understand the problem ... Since your mouse callback knows the point clicked and it must have the frame because it pops it up. So just set the location before you set visible to true.
Regards,
Manfred.
trippyslippy
Greenhorn

Joined: May 07, 2001
Posts: 3
Hey Manfred,
well i figured out the problem. I had to findout the position of the container on the screen, ( that contained the image ) and add to that the point that was selected on the picture. That new point on the screen si where i have to draw the new frame.
but thanks for you time Manfred, i really appreciate it,
sincerely
Danny
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: positioning of JFrames on the Screen
 
Similar Threads
Image
Dynamically positioning a window so it isn't in the way.
JDialog positioning
centering a dialog
Position of new frame