向各位请教一些事件触发的问题~~ 本人编写两个窗体,分别在不同的JAVA文件里,请问怎样通过时间触发将两了窗体连接起来.比如说点击第一个窗体的按钮,第二个窗体弹出.请指教 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这我知道 但是如何让弹出第2个窗口 Object obj=e.getSource(); if (obj==button1) { }打括号里语句怎么写~~ 不知道我实现的效果是你想要的不,代码如下窗体1import javax.swing.*;import java.awt.*;import java.awt.event.*;public class test2 extends JFrame{ JPanel jPanel1 = new JPanel(); JButton jButton1 = new JButton(); public test2() { try { jbInit(); this.setSize(400,300); this.show(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { test2 test21 = new test2(); } private void jbInit() throws Exception { jButton1.setText("jButton1"); jButton1.addActionListener(new test2_jButton1_actionAdapter(this)); this.getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.add(jButton1, null); } void jButton1_actionPerformed(ActionEvent e) { new test3(); }}class test2_jButton1_actionAdapter implements java.awt.event.ActionListener { test2 adaptee; test2_jButton1_actionAdapter(test2 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }} 窗体2import javax.swing.JFrame;public class test3 extends JFrame{ public test3() { this.setSize(200,100); this.show(); } public static void main(String[] args) { test3 test31 = new test3(); }} 关于静态方法的意义和运用问题 class file has wrong version 49.0, should be 48.0 C#中的属性 和 java中的域 初学者问一个关于泛型的小问题 请教一个关于内部类的问题 关于swing性能的问题 applet 求助 jbpm 与 obpm 的区别 ? 求j2se面试资料、复习资料 Java Textfield里面的数字是什么意思? 急!!!求助java语音聊天 各位大哥,小女有一个问题关于 返回类型 的问题
Object obj=e.getSource();
if (obj==button1)
{
}
打括号里语句怎么写~~
窗体1
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class test2 extends JFrame{
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton(); public test2() {
try {
jbInit();
this.setSize(400,300);
this.show();
}
catch(Exception e) {
e.printStackTrace();
} }
public static void main(String[] args) {
test2 test21 = new test2();
}
private void jbInit() throws Exception {
jButton1.setText("jButton1");
jButton1.addActionListener(new test2_jButton1_actionAdapter(this));
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jButton1, null);
} void jButton1_actionPerformed(ActionEvent e) {
new test3();
}}class test2_jButton1_actionAdapter implements java.awt.event.ActionListener {
test2 adaptee; test2_jButton1_actionAdapter(test2 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
import javax.swing.JFrame;public class test3 extends JFrame{
public test3() {
this.setSize(200,100);
this.show();
}
public static void main(String[] args) {
test3 test31 = new test3();
}}