为什么我的文本框不能写入字符 那你的textfild中都设定了什么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把所有的关于JTextFeld的设置都去掉就行了,肯定行的,别忘了给我分呀! 我简化了一下,代码如下文本框里居然不能写,奇怪了import java.awt.*;public class menuWindow extends Frame{ public menuWindow(){ super("newWindow"); pack(); resize(400,300); show(); } public static void main(String args[]){ menuWindow myWindow=new menuWindow(); Panel p=new Panel(); p.add(new TextField(4)); p.add(new TextField(8)); p.add(new TextField()); p.add(new TextField()); p.add(new TextField()); myWindow.add("South",p); myWindow.show(); } public boolean handleEvent(Event e){ if(e.id==Event.WINDOW_DESTROY){ System.exit(0); } return true; }} 啊!推荐你还是用轻量的swing吧! import java.awt.*;public class menuWindow extends Frame{ public menuWindow(){ super("newWindow"); pack(); resize(400,300); show(); } public static void main(String args[]){ menuWindow myWindow=new menuWindow(); Panel p=new Panel(); p.add(new TextField(4)); p.add(new TextField(8)); p.add(new TextField()); p.add(new TextField()); p.add(new TextField()); myWindow.add("South",p); myWindow.show(); } public boolean handleEvent(Event e){ boolean result = true; if(e.id==Event.WINDOW_DESTROY){ System.exit(0); } else { result = super.handleEvent(e); } return result; }}你试试这个!主要是因为你重写了handleEvent方法,可是你的方法有问题!少了一些case! 问题出在这:handleEvent(Event e)public boolean handleEvent(Event e){ if(e.id==Event.WINDOW_DESTROY){ System.exit(0); } return true; } 问题出在这:handleEvent(Event e)public boolean handleEvent(Event e){ if(e.id==Event.WINDOW_DESTROY){ System.exit(0); } return true; } 试试这个:import java.awt.*;import java.awt.event.WindowEvent;import java.awt.event.*;public class menuWindow extends Frame{ public menuWindow(){ super("newWindow"); pack(); resize(400,300); show(); } public static void main(String args[]){ menuWindow myWindow=new menuWindow(); TextField a; Panel p=new Panel(); p.add(a=new TextField(4)); p.add(new TextField(8)); p.add(new TextField()); p.add(new TextField()); p.add(new TextField()); myWindow.add("South",p); myWindow.addWindowListener(new AppCloser()); myWindow.show(); }// public boolean handleEvent(Event e){} class AppCloser extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(0); } } new TextField(),就算能输入,你没保存句柄,也没办法用getText()拿回输入的内容来 swing判断程序是否已经运行。。。 关于JSP页面传参 请教一个简单的正则表达式 请教线程同步问题 正则表达式匹配问题 tuxedo报错 哪位可以帮助解决下 谢谢 怎样把list中用get取出来的元素变为可运算的? 新手请教:有关package的问题, 考sjcp,英文不好能带文曲星吗? 请问如何用JAVA实现下面的应用?谢谢! 急!我用applet访问本地资源,该怎么做?(分不够再加50) java客户端与vb的服务器端连接。
文本框里居然不能写,奇怪了
import java.awt.*;
public class menuWindow extends Frame{
public menuWindow(){
super("newWindow");
pack();
resize(400,300);
show();
}
public static void main(String args[]){
menuWindow myWindow=new menuWindow();
Panel p=new Panel();
p.add(new TextField(4));
p.add(new TextField(8));
p.add(new TextField());
p.add(new TextField());
p.add(new TextField());
myWindow.add("South",p);
myWindow.show();
}
public boolean handleEvent(Event e){
if(e.id==Event.WINDOW_DESTROY){
System.exit(0);
}
return true;
}
}
public class menuWindow extends Frame{
public menuWindow(){
super("newWindow");
pack();
resize(400,300);
show();
}
public static void main(String args[]){
menuWindow myWindow=new menuWindow();
Panel p=new Panel();
p.add(new TextField(4));
p.add(new TextField(8));
p.add(new TextField());
p.add(new TextField());
p.add(new TextField());
myWindow.add("South",p);
myWindow.show();
}
public boolean handleEvent(Event e){
boolean result = true;
if(e.id==Event.WINDOW_DESTROY){
System.exit(0);
} else {
result = super.handleEvent(e);
}
return result;
}
}
你试试这个!主要是因为你重写了handleEvent方法,可是你的方法有问题!少了一些case!
public boolean handleEvent(Event e){
if(e.id==Event.WINDOW_DESTROY){
System.exit(0);
}
return true;
}
public boolean handleEvent(Event e){
if(e.id==Event.WINDOW_DESTROY){
System.exit(0);
}
return true;
}
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.*;
public class menuWindow extends Frame{
public menuWindow(){
super("newWindow");
pack();
resize(400,300);
show();
}
public static void main(String args[]){
menuWindow myWindow=new menuWindow();
TextField a;
Panel p=new Panel();
p.add(a=new TextField(4));
p.add(new TextField(8));
p.add(new TextField());
p.add(new TextField());
p.add(new TextField());
myWindow.add("South",p);
myWindow.addWindowListener(new AppCloser());
myWindow.show();
}
// public boolean handleEvent(Event e){}
class AppCloser extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}