• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Troubles with ActionListener and event driven program

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been trying to write an applet for a class I'm currently in. The assignment states that we are to create an applet which displays our name using a color drawn from a parameter in the html calling the applet. The background color is designated the same way. Finally the applet is to include a button which, when clicked displays a second string below the first string and button.
If anyone could point out my error(s) I would greatly appreciate it.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently it doesn't look like most of your code will even get called. The method public void init() will get called when you initialize the applet and
public void start() will get called when the applet starts. Your init(Graphics g) doesn't look like it will ever get called the way it is set up now.
Also, using the graphics class directly usually isn't necessary. Unless your teacher told you to do it that way specifically, you should probably have your name set in a Label and add the label to the applet in the same way you do your button. If your teacher did say to use the graphics specifically, you should understand that the entire applet is redrawn when paint(Graphics g) is called. Any direct painting using methods like g.drawstring that is done outside of this method will be overwritten every time the paint(Graphics g) method is called
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic