Hi, I'm writing a lab for a comp course, and i just can't get it to work properly. Could anyone take a look and figure out whats up with it? Its virtually all done...just need to work out a bug or 2. Any help would be awesome.
Lab outline
http://hal.cs.camosun.bc.ca/%7Eshadi...bs/F04Lab4.htm
/*
* Author: C. Bolton
* Date: 10/18/04
* Purpose: To call on multiple methods in one program.
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Lab4 extends Applet implements ActionListener, AdjustmentListener{
String myName;
TextField name, seconds;
int totalSeconds;
private Scrollbar slider;
private int sliderValue;
double fran;
public void paint(Graphics g) {
time(g, totalSeconds, 200, 70 );
fran= convert(sliderValue);
tempBox(g);
showStatus("The temp in Fahrenheit is " +fran);
g.drawString("Fahrenheit "+fran+" Celcius "+sliderValue,200,200);
tempChange();
colorInfo(g, 50,70, Color.blue); //calls on the name and info
}//paint method
private void colorInfo(Graphics g, int x, int y, Color c){//draws the name information
g.setColor(c);
g.drawString("****", x,y);
g.drawString("****"+myName, x,y+15);
g.drawString("***Comp 132",x,y+30);
g.drawString("****Section ? ",x,y+45);
g.drawString("*****",x,y+60);
g.drawString("****",x,y+75);
}//colorInfo method
public void init(){
name = new TextField("", 15);
add(name);
name.addActionListener(this);
seconds = new TextField("", 15);
add(seconds);
seconds.addActionListener(this);
}//end of init method
public void actionPerformed(ActionEvent event){
myName = name.getText();
totalSeconds = Integer.parseInt (seconds.getText());
repaint();
}//end of actionPerformed
private void time(Graphics g, int totalSeconds, int x, int y ){
//int totalSeconds = x;
int hr, min, sec;
int rem;
final int CONV1=3600;
final int CONV2=60;
//caculation
g.drawString("the total second is =" + totalSeconds, x,y); //total amount of seconds
hr= totalSeconds/CONV1;
g.drawString("the number of hours is =" + hr, x,y+15); //conversion from sec to hr
rem= totalSeconds % CONV1;
min=rem/CONV2;
g.drawString("the number of minutes is =" + min, x, y+30); //conversion to minutes
sec= rem % CONV2;
g.drawString("the number of seconds is =" + sec, x, y+45); //remainder of all operations in secs
}//end of time method
public double convert(int sliderValue){
return ((sliderValue*9/5) + 32);
}
}
public void adjustmentValueChanged(AdjustmentEvent e){
sliderValue = slider.getValue();
repaint();
}
public void tempChange(){
slider=new Scrollbar(Scrollbar.HORIZONTAL, 0,1,0,45);
add(slider);
slider.addAdjustmentListener(this);
}
private void tempBox(Graphics g){
g.drawRect(70, 200, 5, 100);
g.drawOval(66,298,13,13);
g.setColor(Color.red);
g.fillOval(67,299,12,12);
g.fillRect(71,300-(int)fran, 4, (int)fran+1);
}//class Lab4