比如我在面板里面添加了一个按钮,想通过鼠标单击按钮以后改变按钮上面的标签,应该怎样实现?我知道改变按钮标签的方法是 ButtonObject.setLabel(),但是在
public void actionPerformed(ActionEvent e)
{}
中怎样才能得到“按钮”对象呢?
public void actionPerformed(ActionEvent e)
{}
中怎样才能得到“按钮”对象呢?
解决方案 »
- 制作exe安装程序问题
- 一个jni问题:)
- 谁能告诉我jbuilder9和SQL2000怎么连起来呢?上那找驱动啊?
- 在Applet里的弹出对话框怎么到后面去了?
- 这样写程序对吗?
- 我想去考SCJP,但不知道具体的流程和花费,请过来人和知情人指点指点
- 有经验的请进:发布applet问题
- 关于线程池里的线程执行结果如何返回给程序的问题
- 很可气的问题:double a=20011130;System.out.println("实际是:"+a); 显示结果是2.00111E7
- JAVA怎样实现SNMP?
- 请问JComboBox中setEnabled(boolean enable)
- 如何获取当前程序文件的路径
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
((JButton)e.getSource()).setText("我好");
}
});//button.setLabel(); //该方法已经不推荐使用,用button.setText()方法替代。
button.addActionListener(new SymAction());
class SymAction implements ActionListener
{
public void actionPerformed(ActionEvent e) {
Object object=e.getSource();//得到事件源
if(object==button){
button.setText("Hello EveryOne!");
}else if(){
}//多个事件源时
}
}