Oneiros
Oneiros

Reputation: 4378

JTextPane in JToggleButton, ignore mouse events?

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 solve this? :)

Upvotes: 1

Views: 415

Answers (1)

user592704
user592704

Reputation: 3704

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

Upvotes: 1

Related Questions