This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Paint method is covering other layouts

 
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



 
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic