I am trying to compile a program but receive errors.
I am using jdk1.3 and j2sdk1.4.2 on separate machines.
Errors are:
cannot resolve symbol
symbol: method parseFloat (java.lang.String)
location: class Float
float x = Float.parseFloat(xString)
and receive the same for float y
Is thier an upgrade or soemthing I else I need to do?
Any help would be greatly appreciated.
The following is my script:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class AddFloat extends Applet implements ActionListener{
TextField txtX = new TextField();
TextField txtY = new TextField();
Panel pnlCenter = new Panel();
Label lblAnswer = new Label();
Button btnAdd = new Button("Add 'em up"
;
Panel pnlSouth = new Panel();
public void init(){
//main layout
setLayout(new BorderLayout());
add(pnlCenter, BorderLayout.CENTER);
add(pnlSouth, BorderLayout.SOUTH);
//center panel
pnlCenter.setLayout(new GridLayout(3,2));
pnlCenter.setFont(new Font("SansSerif", Font.BOLD, 20));
pnlCenter.add(new Label("X:"
);
pnlCenter.add(txtX);
pnlCenter.add(new Label("Y:"
);
pnlCenter.add(txtY);
pnlCenter.add(new Label("X + Y"
);
pnlCenter.add(lblAnswer);
//south panel
pnlSouth.setLayout(new FlowLayout());
pnlSouth.add(btnAdd);
btnAdd.addActionListener(this);
} // end init
public void actionPerformed(ActionEvent e){
Float xWrapper = new Float(txtX.getText());
Float yWrapper = new Float(txtY.getText());
float x = xWrapper.floatValue();
float y = yWrapper.floatValue();
String result = String.valueOf(x + y);
lblAnswer.setText(result);
} // end actionPerformed
} // end class def
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class AddFloat extends Applet implements ActionListener{
TextField txtX = new TextField();
TextField txtY = new TextField();
Panel pnlCenter = new Panel();
Label lblAnswer = new Label();
Button btnAdd = new Button("Add 'em up"
;
Panel pnlSouth = new Panel();
public void init(){
//main layout
setLayout(new BorderLayout());
add(pnlCenter, BorderLayout.CENTER);
add(pnlSouth, BorderLayout.SOUTH);
//center panel
pnlCenter.setLayout(new GridLayout(3,2));
pnlCenter.setFont(new Font("SansSerif", Font.BOLD, 20));
pnlCenter.add(new Label("X:"
);
pnlCenter.add(txtX);
pnlCenter.add(new Label("Y:"
);
pnlCenter.add(txtY);
pnlCenter.add(new Label("X + Y"
);
pnlCenter.add(lblAnswer);
//south panel
pnlSouth.setLayout(new FlowLayout());
pnlSouth.add(btnAdd);
btnAdd.addActionListener(this);
} // end init
public void actionPerformed(ActionEvent e){
Float xWrapper = new Float(txtX.getText());
Float yWrapper = new Float(txtY.getText());
float x = xWrapper.floatValue();
float y = yWrapper.floatValue();
String result = String.valueOf(x + y);
lblAnswer.setText(result);
} // end actionPerformed
} // end class def
I am using jdk1.3 and j2sdk1.4.2 on separate machines.
Errors are:
cannot resolve symbol
symbol: method parseFloat (java.lang.String)
location: class Float
float x = Float.parseFloat(xString)
and receive the same for float y
Is thier an upgrade or soemthing I else I need to do?
Any help would be greatly appreciated.
The following is my script:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class AddFloat extends Applet implements ActionListener{
TextField txtX = new TextField();
TextField txtY = new TextField();
Panel pnlCenter = new Panel();
Label lblAnswer = new Label();
Button btnAdd = new Button("Add 'em up"
Panel pnlSouth = new Panel();
public void init(){
//main layout
setLayout(new BorderLayout());
add(pnlCenter, BorderLayout.CENTER);
add(pnlSouth, BorderLayout.SOUTH);
//center panel
pnlCenter.setLayout(new GridLayout(3,2));
pnlCenter.setFont(new Font("SansSerif", Font.BOLD, 20));
pnlCenter.add(new Label("X:"
pnlCenter.add(txtX);
pnlCenter.add(new Label("Y:"
pnlCenter.add(txtY);
pnlCenter.add(new Label("X + Y"
pnlCenter.add(lblAnswer);
//south panel
pnlSouth.setLayout(new FlowLayout());
pnlSouth.add(btnAdd);
btnAdd.addActionListener(this);
} // end init
public void actionPerformed(ActionEvent e){
Float xWrapper = new Float(txtX.getText());
Float yWrapper = new Float(txtY.getText());
float x = xWrapper.floatValue();
float y = yWrapper.floatValue();
String result = String.valueOf(x + y);
lblAnswer.setText(result);
} // end actionPerformed
} // end class def
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class AddFloat extends Applet implements ActionListener{
TextField txtX = new TextField();
TextField txtY = new TextField();
Panel pnlCenter = new Panel();
Label lblAnswer = new Label();
Button btnAdd = new Button("Add 'em up"
Panel pnlSouth = new Panel();
public void init(){
//main layout
setLayout(new BorderLayout());
add(pnlCenter, BorderLayout.CENTER);
add(pnlSouth, BorderLayout.SOUTH);
//center panel
pnlCenter.setLayout(new GridLayout(3,2));
pnlCenter.setFont(new Font("SansSerif", Font.BOLD, 20));
pnlCenter.add(new Label("X:"
pnlCenter.add(txtX);
pnlCenter.add(new Label("Y:"
pnlCenter.add(txtY);
pnlCenter.add(new Label("X + Y"
pnlCenter.add(lblAnswer);
//south panel
pnlSouth.setLayout(new FlowLayout());
pnlSouth.add(btnAdd);
btnAdd.addActionListener(this);
} // end init
public void actionPerformed(ActionEvent e){
Float xWrapper = new Float(txtX.getText());
Float yWrapper = new Float(txtY.getText());
float x = xWrapper.floatValue();
float y = yWrapper.floatValue();
String result = String.valueOf(x + y);
lblAnswer.setText(result);
} // end actionPerformed
} // end class def