请看看我的代码;import java.awt.*;
import java.awt.event.*;
public class myFrame extends Frame implements ActionListener {
Label res;
TextField my;
Button button1;
String word[]={"zero","one","two","three","four","five","six","seven", "eight","nine","ten"};
public myFrame(){
my =new TextField(10);
res=new Label(" 英文单词:");
button1=new Button("显示");
setLayout(new FlowLayout());
add(my);
add(button1);
add(res);
button1.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
String s=my.getText();
int n=Integer.parseInt(s);
String labelText="";
for(int i=0;i<word.length;i++)
{
if(n==i)
labelText=word[i];
}
res.setText(" 英文单词:"+labelText);
}
public static void main(String args[]){
Frame m=new myFrame();
m.setTitle("显示文本");
m.setSize(400,150);
m.setVisible(true);
}
}
只有调整窗口大小才能完全看见,我肯定不是窗口大小的问题,因为我已经试过了,还请高手多指教一下!