This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm trying to use a ButtonGroup of JToggleButtons and a CardLayout to simulate the function of a JTabbedPane with a different look & feel. To do that I need to have the selected JToggleButton be the same color as the selected panel in the CardLayout. My problem is this - no matter what I do I can't get the selected JToggleButton to match the panel. I've tried setting the background color in the button to the exact color of the panel and then verifying that the colors are the same RGB color (in this case 204,204,204) but even then the button is darker than the surrounding area. What gives? I've also tried setOpaque(false) to no avail. Any help is appreciated. Thx. Another solution to this problem would be changing the appearance of the tabs in a JTabbed Pane (I'm assuming in the TabbedPaneUI), but I don't know how to do that. If someone has an answer to this I would LOVE to hear it. -Kevin
if you set the JButton to setOpaque(true) it *should* have the same backgound as its parent where its placed. From little experience trying to change the appearance of buttons I think they have some additional color layer. But you could check that simply by reading through the original source. Same for JTabbedPane and its UI class. this should shed some ligth on your question. another solution could be to just use JLabel, Border, and MouseListener (in fact I'd say JButtons aren't anything else?!). cheers