[Bluej-discuss] Digital Clock using Applet

Jaime Beckman goldmoon77 at yahoo.com
Fri Feb 9 20:51:31 GMT 2007


Hello all~

I am taking a course in Java as my University that uses BlueJ and have run into an issue while working on a project.

We are required to create a digital clock (which I have done) and then use that code in an applet given to us by the instructor.

What I do not understand is how to get the applet to use my code.  I have inserted it in the applet program, and it compiles and runs, but only the base applet is running.  None of my clock classes or methods are there.

Can someone point me in the right direction?

This is the applet code:

import java.applet.*;       
import java.awt.*;
import java.awt.event.*;

public class TextApplet extends Applet implements ActionListener
   {                                                   
    private Button incrementNumberDisplayButton = new Button("Click to increment");  
    private TextField numberDisplay = new TextField(2);
    private int displayValue = 0;
        
    public void init()
       {
        add(incrementNumberDisplayButton);  
        add (numberDisplay);
        incrementNumberDisplayButton.addActionListener(this);              // add components to applet
        numberDisplay.setText(" " + displayValue);
        } // init()
    I INSERTED MY CODE HERE
    public void actionPerformed(ActionEvent e)        // Action for button clicked
       {
       if (e.getSource() == incrementNumberDisplayButton)
            {
             repaint();
             displayValue = displayValue +1;
             numberDisplay.setText(" " + displayValue);
            }

     }    // end actionPerformed

} // end TextApplet

Thanks
 
Jaime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20070209/23009d4a/attachment.html


More information about the bluej-discuss mailing list