开发者

Java Disabled JLabel Reports Mouse Clicked

开发者 https://www.devze.com 2022-12-27 15:53 出处:网络
colLabels[i].addMouseListener(new MyAdapter()); private class MyAdapter extends MouseAdapter { @Override
colLabels[i].addMouseListener(new MyAdapter());

private class MyAdapter extends MouseAdapter {
@Override
public void mouseClicked(MouseEvent event) {

     ColJLabel colJLabel = (ColJLabel)event.getComponent();

     System.out.println(colJLabe开发者_如何转开发l.ColID);

     setColumnHeader(false);
    }
}

colLabels[i].setEnabled(flag);

The situation is this: Mouse clicks are trapped correctly but when i have the JLabel (ColJLabel) control disabled it still reports mouse clicks.

How can I make so that mouse clicks are only reported when the control is enabled?

Thanks.

EDIT: SOLVED

colJLabel.isEnabled()


The correct solution would be to check to see if the component is enabled (or better, some kind of model) within the mouse listener.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号