一个关于窗口的问题 不就是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(); } }} 求助,怎样用java实现这种功能 Socket 关闭问题 值类型,引用类型 疑惑String 新手问题 如何从线程中返回对象??? String 转换成 XML 问题请教 在Swing程序中可以调用MS Word 的 OLE 控件 在程序中直接打开word嘛? 求书 [求助]JFrame不规则边框问题(高手请进) 为什么JDK的Bin目录下的所有exe都是20KB大小 关于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();
}
}
}