This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes painting problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "painting problems" Watch "painting problems" New topic

painting problems

Tian Zhang

Joined: Mar 23, 2005
Posts: 24
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?

Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
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.

"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
rob armstrong
Ranch Hand

Joined: Jul 25, 2005
Posts: 77
extends JFrame?
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
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.
subject: painting problems
Similar Threads
Regarding Borders..
paint() and applets
A better way with the if statement?
Grid Alignment and Null Exception
disappearing square