一个关于窗口的问题 不就是frame.setVisible(true);就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不行亚在Frame2中不能用frame。setvisible(true) 我建议改一下程序,方法如下创建主界面,同你上面一样Frame1 frame = new Frame1(); frame.setVisible(false);然后不要再用一个JFrame而改做由frame调用一个Dialog作为登录界面再由Dialog返回值决定是否frame.setVisible(true); 楼上说得对,楼主的可以如下实现import javax.swing.*;import java.awt.event.*;import java.awt.*;public class test extends JFrame implements ActionListener{ JButton jb = new JButton("打开"); public test(){ this.getContentPane().add(jb); jb.addActionListener(this); this.setTitle("frame1"); this.pack(); this.show(); } public static void main(String a[]){ new test(); } public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("打开")){ Frame frame2 = new Frame("frame2"); frame2.setSize(400,300); this.setVisible(false); frame2.show(); } }} 多线程问题 javaSE项目。。。 居然在简单的代码上找不出错误,关于窗体显示.... 关于创建对象的疑问?高手请进 高手救命,关于TABLE的数据 Java学习群,刚建的一个学习交流群,适合于中级学习者.群号:31487584 JBuilder问题? method.invoke取值的问题? 如何使applet能够访问本地资源 各位大虾,菜鸟wo又来了! 关于KeyStroke的问题,请高手指点 在指定的矩形区域中显示字符信息
在Frame2中不能用frame。setvisible(true)
创建主界面,同你上面一样
Frame1 frame = new Frame1();
frame.setVisible(false);
然后不要再用一个JFrame而改做由frame调用一个Dialog作为登录界面
再由Dialog返回值决定是否frame.setVisible(true);
import java.awt.event.*;
import java.awt.*;public class test extends JFrame implements ActionListener{
JButton jb = new JButton("打开");
public test(){
this.getContentPane().add(jb);
jb.addActionListener(this);
this.setTitle("frame1");
this.pack();
this.show();
}
public static void main(String a[]){
new test();
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("打开")){
Frame frame2 = new Frame("frame2");
frame2.setSize(400,300);
this.setVisible(false);
frame2.show();
}
}
}