Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Subclass won't use it's paint() Method  (Read 1504 times)
0 Members and 1 Guest are viewing this topic.
Offline Nark

Senior Newbie

« Posted 2005-04-18 11:47:17 »

Hi there,

Ich am writing an Applet consisting of multiple .java Files.

My File (extends Applet) konstructs an objekt out of the file/class (doesn't extend anywere).

The animation constructor calls the constuctor of a subclass "Scale" (extends Canvas).

The Animation class has a method called refresh(). This calls another refresh() Method within the Scale-class. I put a System.out.println("Hello World, my name is Scale.refresh()"); in there and that is displayed.
After refresh() (The one in scale) has done some calculations is calls repaint(). I put a System.out.println("..."); in the scale's paint(Graphics g) method but this is never displayed in the console.

If I try to put an add(scale); (I called the objekt from Scale scale) in the Animation constructor Eclipse outputs the following error message:
The method add(Animation.Scale) is undefined for the type Animation

Why isn't scale's paint method called?
(Please feel free to just make suggestions if you don't know a working answer because I need to get this finished today.)

Btw.: Extending Animation to Canvas and then adding the Animation-objekt in the Main class (that works) doesn't solve my problem.
Offline kevglass

« JGO Spiffy Duke »

Medals: 319
Projects: 25
Exp: 22 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #1 - Posted 2005-04-18 12:59:02 »

Calling repaint() schedules a repaint but doesn't actually force the paint() call. Maybe its just the scheduled repaint hasn't occured yet?

repaint(0); forces the paint() to happen within 0 milliseconds (?), i.e. straight away, maybe that'll work better.


Offline Nark

Senior Newbie

« Reply #2 - Posted 2005-04-18 16:49:12 »

OK, thank's I've fixed that problem.

But I've got a new one.

Another subclass of Animation in Rectangular. This is extended to PhysicsEngine which (currently is empty) is extended to canvas

Now the paint method of Rectangular is called and all Graphics methods work, but they dont't draw their stuff on the screen.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder

Got any cats?

« Reply #3 - Posted 2005-04-18 22:20:16 »

Without code Im kind of stabbing in the dark.

Are you drawing to the Graphics object passed in to the paint() call?

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!
Pages: [1]
  ignore  |  Print  

EgonOlsen (61 views)
2018-06-10 19:43:48

EgonOlsen (42 views)
2018-06-10 19:43:44

EgonOlsen (61 views)
2018-06-10 19:43:20

DesertCoockie (241 views)
2018-05-13 18:23:11

nelsongames (142 views)
2018-04-24 18:15:36

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!