KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > TimeView


1 /*
2  * Copyright 2003, Franz-Josef Elmer, All rights reserved
3  */

4 import jcckit.util.Format;
5
6 import java.awt.*;
7 import java.awt.event.*;
8
9 public class TimeView extends Label {
10   private final Brusselator _brusselator;
11   private final Format _format = new Format("%1.2f");
12
13   public TimeView(Brusselator brusselator) {
14     _brusselator = brusselator;
15     brusselator.addActionListener(new ActionListener() {
16           public void actionPerformed(ActionEvent event) {
17             showValue();
18           }
19         });
20     setFont(Font.decode("SansSerif-bold-13"));
21     showValue();
22   }
23
24   private void showValue() {
25     setText("t = " + _format.form(_brusselator.getTime()));
26     invalidate();
27     if (getParent() != null) {
28       getParent().validate();
29     }
30   }
31 }
32
Popular Tags