wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes labeling in this Applet.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "labeling in this Applet.." Watch "labeling in this Applet.." New topic
Author

labeling in this Applet..

Jeremy Parsons
Ranch Hand

Joined: Apr 21, 2006
Posts: 74
I'm trying to take the same applet I was trying to get working earlier and apply a label inside the square that says "square".. I can't seem to get more than a flashing square and no label.



I created the Label and Font objects I had learned, and I tried using add() method with no success.. Any tips to point me in the right direction would be greatly appreciated..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
You should not call add in the paint method, since paint will be called may times over. Move that call into the init method, which is only called once during applet initialization.


Ping & DNS - my free Android networking tools app
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Ulf Dittmer:
You should not call add in the paint method, since paint will be called may times over. Move that call into the init method, which is only called once during applet initialization.


When you do that, you will also want to call super.paint(gr) in your paint method. That will cause your applet to tell all components that have been added (i.e. your label) to paint themselves.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: labeling in this Applet..
 
Similar Threads
So difficult to use Layout managers!!!
Applet problem...
Applet Problem...
labeling in this Applet..
Applet help.....