开发者

JTextPane in JToggleButton, ignore mouse events?

开发者 https://www.devze.com 2023-03-08 17:17 出处:网络
Hi guys I am in a strange situation: there is a JToggleButton with a JTextPane as a child component. If I click on the JTextPane, the relative button\'s events don\'t go in action (because he understa

Hi guys

I am in a strange situation: there is a JToggleButton with a JTextPane as a child component. If I click on the JTextPane, the relative button's events don't go in action (because he understands that i want to click on the JTextPane, which i'd like to set "unclickable").

How could i开发者_Python百科 solve this? :)


You can just do something like this

aJToggleButton tButton=new aJToggleButton();//contains JTextPane
tButton.getTextPane().addActionListener(this);

public void actionPerformed(ActionEvent e)
{
  ((aJToggleButton )((JTextPane)e.getSource()).getParent()).setSelected(true);
}

Anyway, it would be more helpful to see the component docs... Still I guess, the snippet touches the conception

Good luck

0

精彩评论

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