*
The moose likes Swing / AWT / SWT and the fly likes JFrame resize Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame resize" Watch "JFrame resize" New topic
Author

JFrame resize

Timothy Leong
Ranch Hand

Joined: May 25, 2005
Posts: 55
when a user resize the java application, how can I get dimensions before resized and dimensions after resize??
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I don't believe there are events for "about to resize" so what I would do is store your deminsions when your application first loads. Afterwhich you can capture resize events and store them accordingly.


GenRocket - Experts at Building Test Data
Timothy Leong
Ranch Hand

Joined: May 25, 2005
Posts: 55
If I want to store the dimensions when the java Frame first loads. I should call getHeight, getWidth from the constructor right? But the value I gotten is 0. Is there anyway I can get the initial value?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
call your getWidth() getHeight() after setting the frame's visibility to true
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Michael Dunn:
call your getWidth() getHeight() after setting the frame's visibility to true


I was going to suggest that but wanted to do a bit more research on when the size actually gets set. It seems odd to me that setting the frame visible is when that happens. To me it makes more sense for it to be when a) pack() is called or b) setSize(x,y) is called. I'd assume, though I haven't tested, that setVisible(false) will then return 0,0 for w and h. Again, seems odd as the frame is not disposed of, merely invisible. I guess if you think of it in terms of the frame being "turned off" then it makes more sense. But still odd.

Ok, I am rambling and it doesn't really matter. Michael is right, of course.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame resize