aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Paint method is covering other layouts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Paint method is covering other layouts" Watch "Paint method is covering other layouts" New topic
Author

Paint method is covering other layouts

Michael Carol
Greenhorn

Joined: Aug 19, 2012
Posts: 3
Hello, I have just started learning AWT and Swing so I've done my first application. It works fine except one part. Application draws shapes which user choose by clicking button. The problem is that paint method is covering all the rest. Moreover at the start of the application there is a transparent background and nothing is visible until I move mouse cursor above one of the hidden buttons and click it. Also neither labels nor panels are visible. If you cut this method from code menu is visible and looks like it should:




This is strange because it shouldn't even work at start of the application because flags are set on false. Please take a look at this and give me a hint



Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 560
I don't see a print() method. What print() method?

Your program seems to work fine. How about adding a Clear button?


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Michael Carol
Greenhorn

Joined: Aug 19, 2012
Posts: 3
I'm sorry it was a typo. I was talking about paint method above.

So when I open my app it looks like this (everything is transparent):



And I must move my mouse cursor above each button to show them.



No labels and panels are available either. However on my other PC with WinXP labels and panels are shown after moving cursor above the button. I really have no idea why this happens :/

Without paint method menu looks fine and app starts ok but when I add paint method it start to be messed up :/
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 560
Try starting your paint() method with:

super.paint( g );

You should find that the accepted/recommended approach in your study material.
Michael Carol
Greenhorn

Joined: Aug 19, 2012
Posts: 3
Thank you very much for your help - it works perfect now
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Paint method is covering other layouts