• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

labeling in this Applet..

 
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..
 
Rancher
Posts: 43011
76
  • 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.
 
author
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!