• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JToggleButton background color

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic