java 中的event_java 中的 event 的用法

/**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窗口的面板进行修改

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值