JAVA怎么用子窗体调用另一个子窗体 我有一个父窗体(form1),还有二个子窗体(form2,form3)我想用父窗体(form1)调用子窗体(form2),再通过子窗体(form2)中的按钮调用另一个子窗体(form3)需要怎么做我是个新手,谢谢大家帮个忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在form1中new一个form2,在form2中new一个form3.........最好把form2和form3设置成模态的。 我的代码是这样写的,单调FORM2、FORM3都可以,只要一用FORM2调FORM3就不成功,FORM3调不也来,系统也不报错。主页面的public class form1 extends JFrame {JDesktopPane desk = null;JButton jButton1 = new JButton();private void jbInit() throws Exception {desk = new JDesktopPane();jButton1.setText("调用FORM2"); jButton1.addActionListener(new form2_ActionAdapter(this));}void form2_actionPerformed(ActionEvent actionEvent) {form2 dlg = new form2(); dlg.setClosable(true); desk.add(dlg); dlg.setVisible(true); try{ dlg.setSelected(true); } catch(java.beans.PropertyVetoException ex) { System.out.println(ex.toString()); }}}class form2_ActionAdapter implements ActionListener { form1 adaptee; form2_ActionAdapter(form1 adaptee) { this.adaptee = adaptee; }public void actionPerformed(ActionEvent actionEvent) { adaptee.form2_actionPerformed(actionEvent); }}在FORM2的public class form2 extends JInternalFrame {JButton jButton1 = new JButton();private void jbInit() throws Exception {jButton1.setText("调用FORM3"); jButton1.addActionListener(new form3_ActionAdapter(this));}void form3_actionPerformed(ActionEvent actionEvent) {form1 a=new from1();form3 dlg = new form3(); dlg.setClosable(true); a.desk.add(dlg); dlg.setVisible(true); try{ dlg.setSelected(true); } catch(java.beans.PropertyVetoException ex) { System.out.println(ex.toString()); }}} 问两道java题目,别笑话我 请教一下?? 请教一下关于Java范型 AES加、解密程序和java界面程序整合的问题!急--在线等!!分不够可再加!! java构造函数问题 求救,读文件的方法 求一个java的mp3的解码的源代码 请教,关于Lomboz插件 Jpanel 自适应大小的问题 java为什么不能执行这句sql语句? BufferedReader 问题 求救!!!!!!!! 怎样把这个矩阵输出成图片?
最好把form2和form3设置成模态的。
主页面的
public class form1 extends JFrame {
JDesktopPane desk = null;
JButton jButton1 = new JButton();private void jbInit() throws Exception {
desk = new JDesktopPane();
jButton1.setText("调用FORM2");
jButton1.addActionListener(new form2_ActionAdapter(this));
}
void form2_actionPerformed(ActionEvent actionEvent) {
form2 dlg = new form2();
dlg.setClosable(true);
desk.add(dlg);
dlg.setVisible(true);
try{
dlg.setSelected(true);
} catch(java.beans.PropertyVetoException ex) {
System.out.println(ex.toString());
}
}
}
class form2_ActionAdapter implements ActionListener {
form1 adaptee; form2_ActionAdapter(form1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.form2_actionPerformed(actionEvent);
}
}在FORM2的public class form2 extends JInternalFrame {
JButton jButton1 = new JButton();
private void jbInit() throws Exception {
jButton1.setText("调用FORM3");
jButton1.addActionListener(new form3_ActionAdapter(this));
}
void form3_actionPerformed(ActionEvent actionEvent) {
form1 a=new from1();
form3 dlg = new form3();
dlg.setClosable(true);
a.desk.add(dlg);
dlg.setVisible(true);
try{
dlg.setSelected(true);
} catch(java.beans.PropertyVetoException ex) {
System.out.println(ex.toString());
}
}
}