Chat on IRC |
GUI problem
Posted by mrnorman [send private reply] at July 07, 2002, 12:41:02 AM
That's a good idea, thanks.
Posted by taubz [send private reply] at July 06, 2002, 06:01:29 PM
I'm not familiar with Swing, but it sounds like your idea for the initializing the form in the Paint method would work. Maybe set a flag the first time you init. the form so you only have to do it once, thus not slowing down the paint method in the future?
I'd imagine there's an easier way to do it, though.... - taubz
Posted by mrnorman [send private reply] at July 06, 2002, 03:13:52 PM
Hi, I'm programming a card game, and after tackling all but the GUI, I find that I can't get the GUI right. Well, I want the window (JFrame) to be resizable and the components to resize/replace themselves with it. I knew that I'd need the content pane's width and height to accomplish this and then found out that I'm not guarenteed that those will be initialized until just before the paint(Graphics g) method is run. Well, I've thought about delaying all of the graphical placement until the window's content pane is painted by allocating the child containers (JPanels) and atomic components inside the paint method. However, this kills the speed of the program (especially when you move the window around!) because the paint method is run quite often. Where and how should I allocate, initialize, and place stuff inside the container so that it's all placed and sized relative to the content pane's size and doesn't slow stuff down too much?
Register as a new user | |||||