View Full Version : GUI question in Java
brad211987
10-26-2005, 05:39 AM
For a school program we have to have a frame, with a JComponent inside it, and then a few objects drawn on it. All of which is no problem but the last thing that is needed, is when the entire frame is resized, all of the pieces inside it need to stretch out as well. This is where my problem is, I think it is because the paintComponent method needs to be called again when the frame is resized but I do not know how to do that. Any ideas?
All of my drawing statements use variables as opposed to set sizes, so it should all work if I could update it after the frame is resized.
kalium
10-26-2005, 12:20 PM
For a school program we have to have a frame, with a JComponent inside it, and then a few objects drawn on it. All of which is no problem but the last thing that is needed, is when the entire frame is resized, all of the pieces inside it need to stretch out as well. This is where my problem is, I think it is because the paintComponent method needs to be called again when the frame is resized but I do not know how to do that. Any ideas?
All of my drawing statements use variables as opposed to set sizes, so it should all work if I could update it after the frame is resized.
If you want to call painComponent, just call repaint() .
EDIT: Actually you shouldnt need to call repaint() if you are resizing the frame. It should call it automatically.
Ray
brad211987
10-26-2005, 06:29 PM
I found that out while playing with it today, it was just painting over the same spot so it didnt appear to be re painting, but it works now, thanx
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.