如何显示第2个Frame? 有什么方法能显示第2个Frame?在第一个Frame中设置按钮点击显示第二个Frame有这种方法么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在按钮事件中将第二个窗口显示就行了frame2.setVisible(true); 你说的是不是 你想在第一个FRAME中,设置一个按钮,点击按钮,显示第二个FRAME? 现在 show() 方法 好像换成了 SETVISIBLE()方法 首先,在你的第一个类开头添加一个ActionListener接口 xxx implements ActionListener;然后就为你的按钮添加动作 public void actionPerformed(ActionEvent e) {新增一个你要打开窗口的一个对象 xxx a=new xxx();然后显示这个对象的窗口 a.setVisible(true);} 最后,就是在控件添加时注册ActionListener jButtonx.addActionListener(this); 这就可以 真接生成第二个frame对象,然后用对象.setVisible(true)就可以了,如果要关闭当前的frame的话,直接用this.dispose()方法关闭 按钮事件添加//frame frame2=new frame();//frame2.setVisible(true); 给你一个例子,好好研究一下import java.awt.*;import java.awt.event.*;public class DialogTest extends Frame { private Dialog d; public DialogTest() { Button b; setBounds(100, 100, 600, 400); b = new Button("NEW"); d = new Dialog(this, "NEW"); //无模式的 SubDialog d.setBounds(150, 150, 300, 200); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { d.setVisible(true); } }); d.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { d.setVisible(false); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); add("South", b); setVisible(true); } public static void main(String[] args) { new DialogTest(); }} 请教高手jdic的知识 java递规算法达人请进,帮小弟看一下关于递规算法的问题!!!!!! 关于逻辑表达式的问题 请问如何自己打包一个setup,将我要建的库和表全部安装好? 有关数据库的小问题 有关一些网络游戏他的服务器数据是怎么发送的,难道是服务器定时向客户发送? 我是个初学者,一个文件编译通不过,希望高手指点一下 session 里变量是否不能重置? java线程问题 lambda表达式 石头近来看下(oxfordxyc)求助关于学生学习管理系统,高人也来 java.lang.ClassCastException: java.lang.String
frame2.setVisible(true);
xxx implements ActionListener;
然后就为你的按钮添加动作
public void actionPerformed(ActionEvent e) {
新增一个你要打开窗口的一个对象
xxx a=new xxx();
然后显示这个对象的窗口
a.setVisible(true);
}
最后,就是在控件添加时注册ActionListener
jButtonx.addActionListener(this);
这就可以
//frame frame2=new frame();
//frame2.setVisible(true);
import java.awt.*;
import java.awt.event.*;public class DialogTest
extends Frame {
private Dialog d;
public DialogTest() {
Button b;
setBounds(100, 100, 600, 400);
b = new Button("NEW");
d = new Dialog(this, "NEW"); //无模式的 SubDialog
d.setBounds(150, 150, 300, 200);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
d.setVisible(true);
}
});
d.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
d.setVisible(false);
}
});
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
add("South", b);
setVisible(true);
}
public static void main(String[] args) {
new DialogTest();
}
}