package tilraunir;
import java.applet.Applet;
import java.awt.*;
public class Klukka extends Applet
{
/**
*
*/
private static final long serialVersionUID = 1L;
TextField t1, tSvar;
Button bReikna;
Label a1;
Integer I;
int i, sek, min;
public void init()
{
t1 = new TextField (5);
tSvar = new TextField (25);
bReikna = new Button ("Reikna mínútur");//Calculate minutes
a1 = new Label ("Sekúndur");
this.add(a1);
this.add(t1);
this.add(bReikna);
this.add(tSvar);
}
public boolean action(Event e, Object o)
{
if (e.target == bReikna)
{
I = new Integer(t1.getText());
i = I.intValue();
min = i / 60;
sek = i % 60;
tSvar.setText(i + " sek. er " + min + " mín. og " + sek + " sek.");
return true;
}
return false;
}
}