2

I am using a glasspane on the top of my application. However I want the JTabbedPane to be clickable. I know how to do it with JButton by adding a mouse listener on the glasspane and then use this method getDeepestComponentAt() from SwingUtilities. However when I do the same for JTabbedPane I am able to retrieve the JTabbedPane instance with this method, but I want to select the tab that the user clicked. I can't use the setSelectedIndex(..) (at least not directly) since I only have a point on the content pane. Anyone who knows how to allow for tab selection?

This is basically how I do it with the button: http://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html (look at the example for glasspane).

mKorbel
  • 109,525
  • 20
  • 134
  • 319
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434

1 Answers1

4

Have you tried JTabbedPane's indexAtLocation(int, int)?

splungebob
  • 5,357
  • 2
  • 22
  • 45