1

I have a JTabbedPane with tabs on the top. To the right of the tabs, I add a button. This button is neither part of JTabbedPane nor is it a tab. Unfortunately, it cannot be clicked. I guess this button is covered by the JTabbedPane, because I moved the button down, it covered by the JTabbedPane.

Can anybody give me some suggestion, so that I can click that button?

This is the layout; I can't upload image, so I draw it like below:

|-------------------------------------|
|   tab   |  tab   |           button |
|-------------------------------------|
|                                     |
|               content               |
|                                     |
|-------------------------------------|
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
chenhai
  • 35
  • 4
  • 2
    no issues on my side, works as excepts, please edit your question with [SSCCE](http://sscce.org/) – mKorbel Mar 30 '12 at 06:30
  • To make a button can be clicked, you must make sure this button is inside swing tree, not just draw it in the screen. I guess what happens for you is that you did not set the parent component for the button, or just put the button in the paint() ? – chenyi1976 Mar 30 '12 at 06:34
  • Why add buttons to the tab of a tabbed pane? What do they do? – Andrew Thompson Mar 30 '12 at 06:58
  • I find the answer, I first add button to the contetPane,the add the JTabledPane to the contenPane, then it can click. – chenhai Mar 30 '12 at 08:37

1 Answers1

1

I haven't tried it, but you may be able to leverage one of approaches adduced by @camickr in the article Component Border. A custom TabbedPaneUI is a (laborious) alternative.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045