• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

labeling in this Applet..

 
Jeremy Parsons
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic