一个问题,急~~ 我构造了3个窗口,主窗口,副窗口还有第三个窗口,我的第三个窗口的构造是写在主窗口里面的,但是我现在想副窗口也能共享第三个窗口的信息,我应该怎么做?? 就是怎么实现三个类之间的信息共享?? 急~~ 谢谢答复 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你说的是html还是swing awt 你说的是html还是swing awt 既然有构造,应该是swing awt之类的吧import java.awt.event.*;import javax.swing.*;public class CSDN extends JFrame { Child1 child1 = null; Child2 child2 = null; public CSDN(){ super("test"); this.setFocusable(true); init(); setLocation(200, 100); pack(); setVisible(true); this.addWindowListener(new WindowListener()); } void init(){ child1 = new Child1(this); child2 = new Child2(this); } class Child1 extends JFrame { CSDN father; JTextArea jt = new JTextArea(); Child1(CSDN father){ super("child1"); this.father = father; this.setFocusable(true); setLocation(200, 200); jt.setText("input something"); this.getContentPane().add(jt); pack(); setVisible(true); this.addWindowListener(new WindowListener()); } } class Child2 extends JFrame implements MouseListener{ CSDN father; JButton button = new JButton(""); Child2(CSDN father){ super("child2"); this.father = father; this.setFocusable(true); setLocation(200, 300); button.setText("click me"); button.addMouseListener(this); this.getContentPane().add(button); pack(); setVisible(true); this.addWindowListener(new WindowListener()); } public void mouseClicked(MouseEvent e) { JOptionPane.showMessageDialog(this,father.child1.jt.getText()); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } } class WindowListener extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(0); } } public static void main(String[] args){ CSDN csdn = new CSDN(); }} 2楼麻烦说清楚一点,谢谢~~3楼我用的是swing father.child1.jt.getText()这行看见了没?去找老爹的另一个儿子的某属性,不是很清楚吗 JAVA生成投票图片 无限级 jtree的例子(急用) 兄弟们,帮我注释下这段代码,关于TextArea 请教~~监听器为什么没有反应? oracle jaxb 读取xml时报错 Java日期操作常用方法征集 class 的构造函数访问权限究竟如何? 相入門,好難? 有回應就給分!!!! 初学JAVA问一个很简单的问题 Java构造函数前需要加public吗 Java开发邮件服务器
还是swing awt
还是swing awt
import javax.swing.*;
public class CSDN extends JFrame {
Child1 child1 = null;
Child2 child2 = null;
public CSDN(){
super("test");
this.setFocusable(true);
init();
setLocation(200, 100);
pack();
setVisible(true);
this.addWindowListener(new WindowListener());
}
void init(){
child1 = new Child1(this);
child2 = new Child2(this);
}
class Child1 extends JFrame {
CSDN father;
JTextArea jt = new JTextArea();
Child1(CSDN father){
super("child1");
this.father = father;
this.setFocusable(true);
setLocation(200, 200);
jt.setText("input something");
this.getContentPane().add(jt);
pack();
setVisible(true);
this.addWindowListener(new WindowListener());
}
}
class Child2 extends JFrame implements MouseListener{
CSDN father;
JButton button = new JButton("");
Child2(CSDN father){
super("child2");
this.father = father;
this.setFocusable(true);
setLocation(200, 300);
button.setText("click me");
button.addMouseListener(this);
this.getContentPane().add(button);
pack();
setVisible(true);
this.addWindowListener(new WindowListener());
}
public void mouseClicked(MouseEvent e) {
JOptionPane.showMessageDialog(this,father.child1.jt.getText());
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
}
class WindowListener extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
public static void main(String[] args){
CSDN csdn = new CSDN();
}
}
这行看见了没?
去找老爹的另一个儿子的某属性,不是很清楚吗