• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Drawing to a JFrame (Java) - must drag the window around to see the drawing?

slugg

Diamond Member
So I'm just trying to hack together a little proof of concept app. It involves drawing directly to a JFrame. Everything works just fine, except in order to actually see the shapes I've drawn, I need to drag the window off the screen, then bring it back. Since 99.9% of all the programming I've ever done in any language has not involved a GUI, I'm a bit perplexed. Also, I haven't touched Java in 4 years, so I forgot all the intricacies of it. I'm missing something stupid...

Obviously this has something to do with refreshing/redrawing/whatever the window. I'm not quite sure how to properly attack this problem. Unfortunately, I'm not allowed to show you my source code. I can say this: I'm using the NetBeans IDE. I just made a JFrame and added a menu bar to it. When one of the menu items is clicked, my code draws something directly to the frame (under the menu bar). That's about it - nothing special. I do my drawing in the overrode paint(Graphics g) method.

Any ideas?
 
Back
Top