为什么要最大化后才能看见? 1,“为什么出来的只是蓝色的MyFrame看不见button”先在Frame上添加控件,再调用setVisible2,“运行上述类似程序后只能先用Ctrl+c关闭GUI”给该窗口添加WindowClosing事件,在该事件中调用:System.exit(0); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.*;public class MyFrame extends Frame{ public MyFrame(String str){ super(str); }public static void main (String args[]){ MyFrame fr=new MyFrame ("Hello"); fr.setBackground(Color.blue); fr.setVisible(true); fr.setSize(300,300); fr.setLayout(new GridLayout(4,4)); fr.add(new Button("7")); fr.add(new Button("8")); fr.add(new Button("9")); fr.add(new Button("+")); fr.add(new Button("4")); fr.add(new Button("5")); fr.add(new Button("6")); fr.add(new Button("-")); fr.add(new Button("1")); fr.add(new Button("2")); fr.add(new Button("3")); fr.add(new Button("*")); fr.add(new Button("0")); fr.add(new Button(".")); fr.add(new Button("=")); fr.add(new Button("/")); fr.show(); }} 至于第二个问题 建议你改用swing............如果你的内存足够多的话不然就照(阿土)说得做吧 加了fr.show();能看见了System.exit(0);不好用.一闪而过.dos还是得重开 swing我还没用过,具体怎么用.(在线) 在你的构造方法中加上下面的语句addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }}); 24点算法问题 java如何实现拨号连接??? 刚刚看了关于JAVA的一本书,遇到点问题,请教!!! 同样的程序,为什么这个就编译不过去? JInternalFrame关闭问题 怎样使用Random类比如比较两个随机数大小?????? JDK入门问题,在线等侯.救急 我下载了一个jbulider6.bin的文件,6百多兆呢,怎么安装呀?各位请多指教 到哪找netscape.javascript.*这个包? 有一个关于java的问题 如何返回数据库,ncharnvarchar型的字段! 怎么我的 HellWorld 都要出问题啊??
public class MyFrame extends Frame{
public MyFrame(String str){
super(str);
}
public static void main (String args[]){
MyFrame fr=new MyFrame ("Hello");
fr.setBackground(Color.blue);
fr.setVisible(true);
fr.setSize(300,300);
fr.setLayout(new GridLayout(4,4));
fr.add(new Button("7"));
fr.add(new Button("8"));
fr.add(new Button("9"));
fr.add(new Button("+"));
fr.add(new Button("4"));
fr.add(new Button("5"));
fr.add(new Button("6"));
fr.add(new Button("-"));
fr.add(new Button("1"));
fr.add(new Button("2"));
fr.add(new Button("3"));
fr.add(new Button("*"));
fr.add(new Button("0"));
fr.add(new Button("."));
fr.add(new Button("="));
fr.add(new Button("/"));
fr.show();
}
}
不然就照(阿土)说得做吧
System.exit(0);不好用.一闪而过.dos还是得重开
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});