- 论坛徽章:
- 0
|
请教一个很白痴的问题,我是一个新手
不是要解析啊
我是想有没有什么方法分别输进去
就是输两次,第一次给第一个第二次给第二个
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Eg6_15 extends JApplet implements ActionListener{
JTextField text;
public void init()
{
text=new JTextField(10);
Container c=getContentPane ();
c.setLayout(new FlowLayout());
c.add(text);
text.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String s1,s2;
double side;
s1=e.getActionCommand();我这里是这样编的,但不成功
s2=e.getActionCommand();
side=hypotenuse(Double.parseDouble(s1),Double.parseDouble(s2));
showStatus("斜边的长度为:"+side);
}
public double hypotenuse(double side1,double side2)
{
double side3;
side3=Math.sqrt(Math.pow(side1,2)+Math.pow(side2,2));
return side3;
}
} |
|