import java.awt.*;
import java.awt.event.*;
public class Accelerator extends java.applet.Applet implements ActionListener {
double v1 = 0;
double v2 = 0;
double time = 0;
double a = 0;
TextField txt1 = new TextField("Initial Velocity",30);
TextField txt2 = new TextField("Final Velocity",30);
TextField txt3 = new TextField("Time",30);
TextField txt4 = new TextField("Meters/S ",30);
Button btn1 = new Button(" Compute ");
Button btn2 = new Button(" Reset ");
public void init() {
add(txt1);
add(txt2);
add(txt3);
add(btn1);
btn1.addActionListener(this);
add(btn2);
btn2.addActionListener(this);
add(txt4);
txt4.setEditable(false);
}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == btn1) {
double v1 = (double)((Double.parseDouble(txt1.getText())));
double v2 = (double)((Double.parseDouble(txt2.getText())));
double time = (double)((Double.parseDouble(txt3.getText())));
a = (v2 - v1) / time;
txt4.setText("Meters/S =" + a);
}
if (source == btn2) {
txt1.setText("Initial Velocity");
txt2.setText("Final Velocity");
txt3.setText("Time");
txt4.setText("Meters/S ");
}
else {
}
}
}
and JCreator says I have one error which is listed as:
" at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
Process completed."
Can someone please help me get this to run properly?
Thankss
Edited by WingedPanther, 03 March 2009 - 07:01 PM.
add code tags (the # button)


Sign In
Create Account

Back to top









