当前位置: 技术问答>java相关
help me!What is worry???
来源: 互联网 发布时间:2014-12-25
本文导语: What is worry??? import java.awt.*; import java.awt.event.*; public class number{ public static void main(String args[]){ new FrameInOut(); } } class FrameInOut extends Frame implement...
What is worry???
import java.awt.*;
import java.awt.event.*;
public class number{
public static void main(String args[]){
new FrameInOut();
}
}
class FrameInOut extends Frame implements ActionListener{
Label output;
TextField in1=new TextField(4),in2=new TextField(4),in3=new TextField(4);
int x,y,z,max;
Button ok=new Button("OK"),exit=new Button("exit");
FrameInOut(){
super("MAX");
add(in1);
add(in2);
add(in3);
add(ok);
add(exit);
ok.addActionListener(this);
exit.addActionListener(this);
setSize(400,400);
show();
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==ok)
x=Integer.parseInt(in1.getText());
y=Integer.parseInt(in2.getText());
z=Integer.parseInt(in3.getText());
if(x>y)
if(x>z)
max=x;
else
max=z;
else
if(y>z)
max=y;
else
max=z;
output.setText(" The max is:"+max);
}
}
import java.awt.*;
import java.awt.event.*;
public class number{
public static void main(String args[]){
new FrameInOut();
}
}
class FrameInOut extends Frame implements ActionListener{
Label output;
TextField in1=new TextField(4),in2=new TextField(4),in3=new TextField(4);
int x,y,z,max;
Button ok=new Button("OK"),exit=new Button("exit");
FrameInOut(){
super("MAX");
add(in1);
add(in2);
add(in3);
add(ok);
add(exit);
ok.addActionListener(this);
exit.addActionListener(this);
setSize(400,400);
show();
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==ok)
x=Integer.parseInt(in1.getText());
y=Integer.parseInt(in2.getText());
z=Integer.parseInt(in3.getText());
if(x>y)
if(x>z)
max=x;
else
max=z;
else
if(y>z)
max=y;
else
max=z;
output.setText(" The max is:"+max);
}
}
|
不过,没加上Label output,也没有退出控制程序。