我在初始化JButton的时候设置了jb.setEnabled(false)
然后运行的时候按钮居然还能使用,我在按钮按下执行的所有动作之前插入System.out.println(jb.isEnabled()),打出来的值都是false。
不知道为什么了,我的ide是eclipse。
高手赐教阿
然后运行的时候按钮居然还能使用,我在按钮按下执行的所有动作之前插入System.out.println(jb.isEnabled()),打出来的值都是false。
不知道为什么了,我的ide是eclipse。
高手赐教阿
如果你一定要用MouseListener的话,就自己判断按钮是否enable吧public void mouseClicked(MouseEvent e) {
JButton button = (JButton)e.getSource();
if (!button.isEnabled()) {
return;
}
...
}