java jbutton 禁用_为什么JButton不能禁用,大侠们进来看看

用eclipse编辑时,定义一个JBtton事件JButton声明是:privateJButtonbutton=newJButton();privateJButtonbutton_1=newJButton();privateJButtonbutton_2=newJButton();privateJButton...

用eclipse编辑时,定义一个JBtton事件

JButton 声明是:

private JButton button = new JButton();

private JButton button_1 = new JButton();

private JButton button_2 = new JButton();

private JButton button_3 = new JButton();

private JButton button_4 = new JButton();

如:

JButton button = new JButton();

button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

button_actionPerformed(event);

}

});

button.setFont(new Font("宋体", Font.PLAIN, 12));

button.setBackground(SystemColor.control);

button.setText("添加");

button.setBounds(10, 420, 70, 28);

getContentPane().add(button);

并在后面定义了方法:

// button 方法 增加

public void button_actionPerformed(ActionEvent event) {

button_1.setEnabled(false);

button_2.setEnabled(false);

button_3.setEnabled(true);

button_4.setEnabled(true);

}

在写代码时都没错,但是运行是点击 button 时却没有产生

禁用 button_1 button_2

也没启用 button_3 button_4

展开

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值