Using a Timer for a JMenu
I have some example code that creates and displays the date in a label.
Here is the code:
// ClockLabel.java
// An extension of the JLabel class that listens to events from
// a Timer object to update itself with the current date & time.
//
import java.util.Date;
import java.awt.event.*;
import javax.swing.*;
public class ClockLabel extends JLabel implements ActionListener {
public ClockLabel() {
super("" + new Date());
Timer t = new Timer(1000, this);
t.start();
}
public void actionPerformed(ActionEvent ae) {
setText((new Date()).toString());
}
}
I want to make this code work in a JMenu. I can get it to work in a label. I want the time and date displayed in JMenuBar. I created a JPanel and inserted a Label in to a Jmenu, and it does not work. I have tried setTextToolTip, ANd help would be appreciated.

