Java Reference
In-Depth Information
public class ErrorDialog extends Dialog implements ActionListener
{
private Button okButton = new Button ("Ok");
public ErrorDialog(String error) {
super (frame, "Error", true);
add("Center", new Label (error));
Panel buttonPanel = new Panel();
buttonPanel.add(okButton);
okButton.addActionListener(this);
add("South", buttonPanel);
addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent ev) {
setVisible (false);
dispose();
}
});
pack();
}
public void actionPerformed (ActionEvent e) {
setVisible (false);
dispose();
}
}
Frame frame = new Frame();
LogStorage log;
DayLog dayLog;
Button setButton = new Button ("set");
Button removeButton = new Button ("remove");
Button dateButton = new Button ("date...");
TextField timeField = new TextField();
TextField valueField = new TextField();
Chart chart = new Chart();
class Chart extends Canvas {
public void paint (Graphics g) {
FontMetrics fm = g.getFontMetrics();
Dimension size = getSize();
int cw = fm.stringWidth ("0");
int lw = 3*cw;
int lh = fm.getHeight();
int w = size.width - lw;
int h = size.height - lh;
g.drawString (""+DayLog.MAX_VALUE, 0, fm.getAscent());
g.drawString (""+DayLog.MIN_VALUE, cw, h -
fm.getDescent());
g.translate (lw, h);
Search WWH ::




Custom Search