This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes Paint not being called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Paint not being called" Watch "Paint not being called" New topic

Paint not being called

Joel McNary

Joined: Aug 20, 2001
Posts: 1817

I've got a custom component that I'm trying to draw on the screen. However, my paint()/painComponent() method is not being called. My component inherits from JPanel and overrides paintComponent(Graphics g) (although it has also overridden paint(Graphics g) at various points in its history as I've tried to make this thing work.)
I place this JPanel in another JPanel and that in a JFrame and show the JFrame and .... nothing
below is my current draft code, along with a lot of stuff commented out that I've tried and it hasn't worked. Any suggestions?

[ March 16, 2004: Message edited by: Joel McNary ]

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Where's the code for the component that overrides paint() and paintComponent()?

If you override paint() and don't call super.paint() inside it, then paintComponent() will never get called.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Paint not being called