its a time program… get the input and show the time.. but how to send the value calculated to draw a line? anyone help pls.. thanks!
[CODE]
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class time extends Applet implements ActionListener
{ private Label prompt,dot;
private TextField hr,min;
private Button done;
public time()
{ setBackground(Color.pink);
prompt = new Label (“Please enter the time:”);
hr = new TextField(2);
dot = new Label (“:”);
min = new TextField(2);
done = new Button(“Done”);
setLayout(null);
add(prompt);
add(hr);
add(dot);
add(min);
add(done);
done.addActionListener(this);
prompt.setBounds(100,470,150,20);
hr.setBounds(250,470,20,20);
dot.setBounds(271,470,10,20);
min.setBounds(280,470,20,20);
done.setBounds(330,470,50,20);
}
public void paint(Graphics g)
{ g.setColor(Color.blue);
g.drawOval(50,35,400,400);
g.drawLine(250,235,xH,yH);
g.drawLine(250,235,xM,yM);
}
public void actionPerformed(ActionEvent event)
{ int Hour,Minute;
double Rhr,xH,yH,Rmin,xM,yM;
Hour = Integer.parseInt(hr.getText());
Minute = Integer.parseInt(min.getText());
Rhr=(90-(Hour+Minute/60.0)*30.0)*3.142/180;
xH=(250+5*0.9998*Rhr);
yH=(250-5*0.0174*Rhr);
Rmin=(90-Minute*6.0)*3.142/180;
xM=(250+3*0.9998*Rmin);
yM=(250-3*0.0174*Rmin);
doLayout();
}
}