wood burning stoves 2.0
The moose likes Java in General and the fly likes repaint() won't call paint() and I'm out of ideas why Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "repaint() won Watch "repaint() won New topic

repaint() won't call paint() and I'm out of ideas why

Jeff Finn

Joined: Aug 07, 2005
Posts: 13
I've been banging my head on this for a while now. In run() everything is peachy if I use show(). I'm pretty sure I need to use repaint() if I want to move the figure around the board without tracers. also, the thread doesn't quit when I close the app, but that's not my big problem now.

heres the code (all of it) edited, compiled and run in BlueJ

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199


Welcome to JavaRanch!

First, I note that in your haste to come in and ask a question, you seem to have missed reading our policy on display names, which quite clearly states that you must use a real (sounding) first and last name for your display name -- no joke names, "handles," or last initials are acceptable. You can fix your display name here. We take this policy rather seriously. Thanks for your cooperation!

Second, your problem: this ought to work, more or less, if you get the JFrame to appear on the screen by calling setVisible(true) in your constructor.

As far as the threads not stopping: graphics programs simply won't quit unless you, one way or another, arrange to have System.exit() be called; usually just by calling setDefaultCloseOperation() on your JFrame.

I should point out that you're mixing AWT and Swing techniques here. With Swing, you don't override paint(), but rather paintComponent(); you always call super.paintComponent(); and you don't need to override update(). Typically you'd write a subclass of a JPanel, not a JFrame, and add that JPanel to an "off-the-shelf" JFrame.

Finally, we've got a Swing/AWT forum here where this post would fit right in. I'm going to move it there. See you around the Ranch!

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link: http://aspose.com/file-tools
subject: repaint() won't call paint() and I'm out of ideas why
It's not a secret anymore!