Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
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 755 times)
0 Members and 1 Guest are viewing this topic.
Offline Nark

Senior Newbie





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

Hi there,

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

My Main.java File (extends Applet) konstructs an objekt out of the Animation.java 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:
1  
The method add(Animation.Scale) is undefined for the type Animation      Animation.java


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 Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2005-04-18 14: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.

Kev

Offline Nark

Senior Newbie





« Reply #2 - Posted 2005-04-18 18: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-19 00: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!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (48 views)
2014-04-15 18:08:23

BurntPizza (44 views)
2014-04-15 03:46:01

UprightPath (60 views)
2014-04-14 17:39:50

UprightPath (42 views)
2014-04-14 17:35:47

Porlus (58 views)
2014-04-14 15:48:38

tom_mai78101 (82 views)
2014-04-10 04:04:31

BurntPizza (140 views)
2014-04-08 23:06:04

tom_mai78101 (240 views)
2014-04-05 13:34:39

trollwarrior1 (200 views)
2014-04-04 12:06:45

CJLetsGame (207 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org 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‑gaming.org
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!