Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple repaint() question!  RSS feed

 
Ben Jass
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I'm trying to draw a .png file onto a panel. I'm using eclipse and whenever I try to simply call the repaint() method (wouldn't that just call the paint() method automatically?). It doesn't know what the repaint() method is (It gets the line under it saying it's undefined).
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are evidently trying to code a call to repaint() of a class that doesn't have a repaint() method.

To get better help sooner, post a SSCCE that clearly demonstrates your problem.
 
Ben Jass
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I thought all classes inherit the repaint() method? I've seen people who haven't declared it and yet they get it to redirect there program to paint(Graphics g);
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the repaint() method is part of the class java.awt.Component. Ofcourse, not all classes in Java are subclasses of that class, so not all classes have a repaint() method.

Most GUI things like windows, buttons, etc. are of types that are a subclass of java.awt.Component so you can call repaint() on them.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only methods you'll always have are the public methods from java.lang.Object: equals(Object), hashCode(), toString(), getClass(), notify(), notifyAll() and the three wait methods.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!