Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

positioning of JFrames on the Screen  RSS feed

 
trippyslippy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Trippy,
Just set its location!
setSize( w,h );
setLocation( x, y );
setVisible( true );
Regards,
Manfred.
 
trippyslippy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!