I included the following line in my code to change the size.
frame.setSize(frame.getWidth()+DELTA_WIDTH, frame.getHeight());
Indeed, frame does grow by DELTA_WIDTH.
Nothing shows up in the extra area, however.
If I tweak the size a bit with the mouse, it all shows up.
Do I need to send a message to the frame's layout manager?
Do I need to send a message to the frame's contentPane?
Any help is appreciated.
Thanks,
Stu Hansen
I am not a awt/swing expert but it looks like you have to execute a
repaint after the resize. no?
--
Peter
Looking for a JAVA opportunity in Calgary
http://wilboo.dyn.ca/resume.htm
I have tried repaint on the frame and on the contentPane to no avail.
I have also tried paintImmediately on each of the components in the expanded
area.
None of these solve my problem.
Thanks,
Stu
Hope this helps!
Frank
"Stuart Hansen" <han...@cs.uwp.edu> wrote in message
news:3C6855A7...@cs.uwp.edu...
>> > I want to programmatically change the width of my application's JFrame.
>> > Everything seems to work fine when I do it with the mouse.
>> >
>> > I included the following line in my code to change the size.
>> >
>> > frame.setSize(frame.getWidth()+DELTA_WIDTH, frame.getHeight());
>> >
>> > Indeed, frame does grow by DELTA_WIDTH.
>> > Nothing shows up in the extra area, however.
>> > If I tweak the size a bit with the mouse, it all shows up.
>> I am not a awt/swing expert but it looks like you have to execute a
>> repaint after the resize. no?
>I have tried repaint on the frame and on the contentPane to no avail.
>I have also tried paintImmediately on each of the components in the expanded
>area.
>None of these solve my problem.
frame.getContentPane().revalidate();
frame.getContentPane().repaint();
BK
Thanks.
This works after I cast the contentPane to a JComponent. e.g.
((JComponent)frame.getContentPane()).revalidate();
Stu
Strange, I wrote a little 'test' and resize(x,y) worked perfectly.
I know that calling to much repaint() 's can cause troubles to,
because the operating system then skips 'arbitrarely' some calls. (to speed up
things)
As far as I know if you call repaint on the top window, the components inside
will call repaint automatically.
So that should be enough.
If you like you may send me (a part of) the code so I can take a look at it to.
Alex Molochnikov
Gestalt Corporation
This also does the trick.
Thanks,
Stu