wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes inherited from the Component class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "inherited from the Component class " Watch "inherited from the Component class " New topic
Author

inherited from the Component class

David McHugh
Greenhorn

Joined: Oct 01, 2008
Posts: 23
hi all,

what is the syntax to call a repaint object that is inherited from the Component class via Container and JComponent classes???
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37890
    
  22
repaint(); ??

And the paintComponent method should read like this:Probably best to move this thread to the Swing forum where they usually discuss this sort of thing.
David McHugh
Greenhorn

Joined: Oct 01, 2008
Posts: 23
hi cambell, didn't seem to work, gave me a cannot find symbol error..
i have posted my original code below, it is the bit at the bottom plotdarryl.repaint giving the problem, it would usually work but i realised in the question it says "repaint Not part of PicturePlotter; inherited from the component class via Container and JComponent classes, so at that point i need to jiggle the code slightly??? cheers

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

And what is this PicturePlotter object?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
David McHugh
Greenhorn

Joined: Oct 01, 2008
Posts: 23
hi rob,

picture plotter is where all the classes are stored i.e. plot, setColorTable and repaint but plotdarryl.repaint(); does not work because it says "repaint Not part of PicturePlotter; inherited from the component class via Container and JComponent classes"

cheers
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37890
    
  22
And as Rob was asking, what is PicturePlotter's inheritance hierarchy?
David McHugh
Greenhorn

Joined: Oct 01, 2008
Posts: 23
hi campbell,

is this what you mean?

class PicturePlotter extends JComponent
public PicturePlotter(int width,int height)
public void plot(int x, int y, int color)
// Plot a single pixel at (x,y) in the given color.
public void plot(int x, int y, int count, int color)
// Plot count pixels at (x,y) in the given color.
public void setColorTable(int[][] table)
// Set a user defined int-based color table.
// Turn the table into Color objects.
public void repaint()
// Call to tidy up display of image
// Not part of PicturePlotter; inherited from the
// Component class via Container and JComponent classes
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37890
    
  22
Yes, thank you, that is what I wanted.

I can't see why you are having problems.

Has somebody else given you the PicturePlotter class? If it extends JComponent it will have several overridden repaint() methods inherited from java.awt.Component and javax.swing.JComponent; the no-args version is from Component. So I can't see why it doesn't work.

Please check your imports that you are actually importing javax.swing.JComponent and you haven't somehow found another class called JComponent. [You probably don't need to import Component.]

What actually happens? I can think of three ways it can go wrong
  • Compiler errors. In which case you might be reverting somehow to an old version of the .class files.
  • Exception when starting up.
  • Exception after it has run for some time.
  • Sorry I'm not more helpful.
    David McHugh
    Greenhorn

    Joined: Oct 01, 2008
    Posts: 23
    cheers for your time campbell, it is a strange one really, i will get the answer on tuesday and let you now what was wrong, it is only a simple exercise so it must be something small i am missing, but that is inexperience for you!!!
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
     
    subject: inherited from the Component class
     
    Similar Threads
    Do you always need setVisible?
    java.awt.List componenet
    Layout Management
    Private fields declared in super class exist in subclass instance?
    SET FOCUS