Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton only appears when I put the mouse over it  RSS feed

 
marty Philippe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my code
My JButton only appears when I put the mouse over it
Can someone help me
thanks


 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem is that you didn't invoke super.paint() so the child component are not painted, since you broke the painting mechanism of Swing.

Even if you do fix that it still won't work because you will paint the components but then you will paint the image over top of the components.

Don't override paint() on a JApplet. If you need to do custom painting then override paintComponent() on a JPanel and then add the panel to the applet. The components would then be added to the panel.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!