• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Simple repaint() question!

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic