/**a1.java**Createdon2008年11月22日,上午8:22**Tochangethistemplate,chooseTools|TemplateManager*andopenthetemplateintheeditor.*/packagetest;importjavax.swing.*;importjava....
/*
* a1.java
*
* Created on 2008年11月22日, 上午8:22
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package test;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
*
* @author Administrator
*/
public class a1 extends JFrame implements ActionListener{
private JPanel pan_main=new JPanel();
// a3 a=new a3();
/** Creates a new instance of a1 */
public a1() {
super("欢迎光临学生管理系统");
this.setSize(800,600);
this.setLocation(250,150);
this.setLayout(new BorderLayout());
this.setDefaultCloseOperation(3);
this.setBackground(Color.GRAY);
pan_main.setLayout(new GridLayout(3,1));
a2 a=new a2();
pan_main.add(a.pan1());
pan_main.add(a.pan2());
pan_main.add(a.pan3());
this.add(pan_main);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
}
public static void main(String args[]){
new a1();
}
}
/*
* a3.java
*
* Created on 2008年11月22日, 上午8:25
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package test;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import test.a1;
/**
*
* @author Administrator
*/
public class a3 extends JFrame implements ActionListener{
/**
* Creates a new instance of a3
*/
public a3() {
}
public JPanel pan1(){
JPanel pan1=new JPanel();
JButton btn1=new JButton("拉萨看到飞机阿克顿来访");
btn1.addActionListener(this);
pan1.add(btn1);
return pan1;
}
public JPanel pan2(){
JPanel pan2=new JPanel();
JButton btn2=new JButton("我iejfa拉萨");
btn2.addActionListener(this);
pan2.add(btn2);
return pan2;
}
public JPanel pan3(){
JPanel pan3=new JPanel();
JButton btn3=new JButton("我拉萨");
btn3.addActionListener(this);
pan3.add(btn3);
return pan3;
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand()=="拉萨看到飞机阿克顿来访"){
// a1 aa=new a1();
// aa.add(pan3());
}
}
}
如何在a3中的actionPerformed中对a1窗口的面板进行修改
展开