Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

painting problems

 
Tian Zhang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there!

just a quick question, i have two classes as follows:



and the later on else where in a different class i have



unfortunatly the instance of display does not show the two rectangles... could you tell me where i'm going wrong?

thanks,
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not too knowlegable in GUI stuff, but don't you want setVisible(true); ?

It is painting it, but is the frame is not visible. Hope that helps.
 
rob armstrong
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
extends JFrame?
roba
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Rusty mentioned you need to make the Frame visible using setVisible(true) not false. Your code won't work though, it's going to paint the rectangles once. As soon as the frame repaints the rectangles will be gone. You need to move your rectangle painting code to paint() method of the frame or to a widget which you add to the frame.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic