/    Sign up×
Community /Pin to ProfileBookmark

how to send value?

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();
}
}
[/CODE]

to post a comment
Java

6 Comments(s)

Copy linkTweet thisAlerts:
@BigDogFeb 08.2006 — Sorry, don't know anything about graphics
Copy linkTweet thisAlerts:
@merxaisauthorFeb 08.2006 — its ok BigDog.. anyone could help pls?
Copy linkTweet thisAlerts:
@OziFeb 08.2006 — are you trying to display a clock? i did this as my first coursework in java. do you want to have a look at the code?
Copy linkTweet thisAlerts:
@OziFeb 08.2006 — could it be that your xH, yH, xM, and yM variables are not intialised anywhere?
Copy linkTweet thisAlerts:
@merxaisauthorFeb 09.2006 — dunno how to pass the value to draw the line for hour and minute... yes it is to display a clock when input hour and minute..
Copy linkTweet thisAlerts:
@reggaeton_kingFeb 09.2006 — yeah, initalize your variable before you make your methods! So they will be abled to be scoop from any method within that class! Also could it be that the variables are private as well? tell us the results
×

Success!

Help @merxais spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...