Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Paint method is covering other layouts

 
Michael Carol
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see a print() method. What print() method?

Your program seems to work fine. How about adding a Clear button?
 
Michael Carol
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 563
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try starting your paint() method with:

super.paint( g );

You should find that the accepted/recommended approach in your study material.
 
Michael Carol
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your help - it works perfect now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic