How can I change the 'selected' color of one JToggleButton only.

Hi,
This seems like a simple / trivial question, but I just can't figure it out. Is there a way that I can create a JToggleButton and change the selected color of only that JToggleButton.
I'm trying to create a simple sidebar like component for navigation within my app. A group of JToggleButton[s] added to a ButtonGroup (with the proper layout / sizing) works great, but the default JToggleButton colors don't suit my needs. I know that I can change the colors using the UIManager / UIDefaults, but I don't want to change the defaults for every JToggleButton in my app. I only want to change the defaults for a few select JToggleButton[s].
For example, I can do this:
UIManager.put("ToggleButton.select", UIManager.getColor("Table.selectionBackground"));
UIManager.put("ToggleButton.background", UIManager.getColor("Table.background"));but I'd rather do something like this:
JToggleButton jtb = new JToggleButton("Toggle Button Text");
jtb.setSelectedColor(UIManager.getColor("Table.selectionBackground"));
jtb.setBackground(UIManager.getColor("Table.background"));The only thing is, I can't find any method that is the equivilant of 'setSelectedColor(Color)' for JToggleButton.
I know I could do it by adding some listeners to the JToggleButton[s], but that seems a little complicated for something like changing a color.
I'd also seen a solution in the forums where someone had extended the ButtonUI of the pluggable look and feel they were using. I'm not interested in modifying the look and feel I'm using. As far as I'm concerned, that would defeat the purpose of having a pluggable look and feel as I would have to duplicate my efforts for every look and feel I want to use.
Any help would be appreciated,
Ryan

try this
import javax.swing.*;
import java.awt.*;
class Testing extends JFrame
  public Testing()
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(250,75);
    setLocation(400,300);
    JPanel jp = new JPanel();
    JToggleButton jtb = new JToggleButton("Toggle me");
    jtb.setUI(new MyUI());
    jp.add(jtb);
    getContentPane().add(jp);
  public static void main(String args[]){new Testing().setVisible(true);}
class MyUI extends javax.swing.plaf.metal.MetalToggleButtonUI
  public Color getSelectColor(){return Color.BLACK;}
}

Similar Messages

  • How can I change the background color in the inbox?

    The background color in my inbox (well, all mailboxes) is white. A yellow background would make the existing black text a lot easier to read. How can I change the background color in the inbox?

    Themes work in Thunderbird - duggabe was not refering to Firefox.
    Another useful addon is theme and font changer:
    * https://addons.mozilla.org/fr/thunderbird/addon/theme-font-size-changer/
    However, Thunderbird allows you to modify all sorts of things.
    Make hidden files and folders visible:
    * http://kb.mozillazine.org/Show_hidden_files_and_folders
    Help > Troubleshooting Information
    Click on 'show Folder' button
    a window opens shwoing profile folder name
    Close Thunderbird now - this is important
    In the profile name folder, Create a new folder called '''chrome''' - note the spelling
    It should be in the same place as the 'Mail' folder.
    see first image below.
    Open Notepad
    Can be located : Start > Programs > accessories
    Copy everything shown between the lines below.
    Paste into Notepad.
    Save as '''userChrome.css''' - note the spelling (edit updated - this was a typo error)
    This should be saved in the '''chrome''' folder.
    see second image below.
    Restart Thunderbird.
    I have chosen a yellow for you
    <pre>
    #f6f58c = a yellow....it is a hex code for a colour.
    </pre>
    You can change it if required. Remember when updating anything in the profile folders, you must close Thunderbird first.
    More info on colours.
    * http://www.yourhtmlsource.com/stylesheets/namedcolours.html
    <pre>
    * Do not remove the @namespace line -- it's required for correct functioning
    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
    /*Background colour for message list*/
    #threadTree > treechildren::-moz-tree-row {
    background-color: #f6f58c !important;
    </pre>
    -------------------------------------------

  • How can you change the bubble color in the message app on the iphone 5

    How can you change the bubble color in the message app on the iphone 5?

    If you are having trouble reading your texts you can increase the font size until it becomes clear. Put in a feature request for the colour change though, it won't happen unless people ask for it.

  • How can I change the text   color in pages

    Hi , how can I change the text color in pages app

    Select the text you want to change.
    Tap the i in the top bar.
    Tap Style in the top bar.
    Tap the Font name/size
    Tap Color then choose the color you want the text.

  • How can i change the background colors on my iphone. The new white is hard on my eyes. I dont care for the grey boxes either.

    how can i change the background colors on the new update? I find the white a bit much. Also is there anyway I can change the grey boxes they seem out of place.

    That makes me sad. thannk you

  • 2 different iphones have the same Apple ID, how can I change the apple ID on one of them but not delete the other iphone's data and media?

    2 different iphones have the same Apple ID, how can I change the apple ID on one of them but not delete the other iphone's data and media?

    You don't have to do anything with the first iPod that you don't use anymore. If you are planning on keeping it, put in a drawer in your house and forget about it.
    You don't need a second account to use with the new iPod. I use one Appl e ID and iTunes library for two iPods, and two iPad. I have different content on all four devices. You can select exactly what you want to sync to each device and it can be different content on all devices.

  • How can I change the background color of a chart?

    How can I change the default black background color of a chart to white?
    Thanks
    John

    Hello All,
    Another (and my preferred method) of bringing up the tools palette is to press
    <shift>+<Rt-Click>.
    Just another way to do something in LabVIEW!
    Travis M
    LabVIEW R&D
    National Instruments

  • How can i change the background color in the heading when i add a new page

    How can I change the background in the heading on a new page? When you add WELCOME page the heading color is tan, the ABOUT ME page the heading is light blue, the PHOTOS page the heading block behind the heading text is light green, etc. How do I change those colors?

    you can change iweb navbar any which way you want, as long as you know iweb widgets:
    http://iwebwidgets.cyclosaurus.com/iWebNavBar/BkgndColor.html
    you won't see the change in iweb, you only see it in published site.

  • How can I change the background color of my podcast's iTunes page?

    My RSS feed just got accepted but now I need to customize the title, author, background color, and logo of my site. Does anyone know how to do this? Thank you!

    You can't change the background colour - it's white for audio and black for video. The other data can be changed by changing the appropriate tag in the feed, or if you're using a program or online service to make your podcast,. wherever they provide for entering this information.
    The title is carried in the 'title' tag; the author in the 'itunes:author' tag, and the 'podcast image' which appears on the Store page in the 'itunes: image' tag. Republish the feed after making the amendments: it will take a couple of days for the new data to appear, though the image may take several days.
    The image which appears in some podcasts in the bottom left-hand corner of iTunes when subscribing is not referenced in the feed but has to be actually embedded into the media file: please see this page:
    http://www.wilmut.webspace.virginmedia.com/notes/coverart.html
    You may find this general page on making a podcast helpful:
    http://rfwilmut.net/pc

  • How can I change the highlight color of grid view folders in the dock?

    Using OSX 10.10 Yosemite, the highlight color for a folder in Grid view is barely noticeable.
    Can you spot the highlighted icon below?
    I've grown accustom to clicking the applications folder in the doc then typing a few letters to get me close to the app I want- now it takes an extra few seconds for me to visually find the icon that got highlighted.
    Is there a way to change the highlight color here?

    I would open up the grid spacing slightly so everything does not run together. In System Preferences > General, try setting Highlight color: Red. This won't change the grey selection background around the icon, but it will turn the background behind the icon text to red. That stands out. However, the collateral effect is that text you select in this editor, and other OS X applications, will now have a red background too. Changing colors will require a killall Finder in the Terminal. Actually set mine to #ffff00 which is a vivid yellow, which is more practical when selecting text in a document.

  • How can I change the background color of odd/even rows in a panelCollection

    Hi everyone.
    I'm using a panelCollection and I need to change the backgroung color for odd/even rows in the table,
    how can I do this, using a stylesheet, is there a special selector or property for this?
    globalResultCollection (UIPanelCollection object) , is a collection of UITable elements, and it's working fine.
    I just want to change the defaul background color for rows.
    Thanks
    <af:panelCollection id="GLOBAL_RESULT_COLLECTION"
    binding="#{admin.view.globalResultCollection}"
    styleClass="globalResultCollectionRegion"
    clientComponent="true">
    <f:facet name="menus">
    <af:menu id="GLOBAL_OPERATION_MENU"
    binding="#{admin.view.globalOperationMenu}" />
    </f:facet>
    <f:facet name="toolbar">
    <af:toolbar inlineStyle="width:100%"
    binding="#{admin.view.globalOperationToolbar}"
    id="OPERATION_TOOLBAR"/>
    </f:facet>
    </af:panelCollection>

    Hi,
    use this:
    af|table::data-row af|column::data-cell { background-color: #CCCCFF; }
    af|table::data-row af|column::banded-data-cell { background-color: #FFCCCC; }
    Regards,
    s o v i e t

  • I would like to change the project page layouts, but setup option in Project Superuser are not available. How can I change the selected page layouts?

    Hi
    I updated the page layouts for a project in Project Management. Now I woujld like to change those chosen page layouts, but the setup options for the project are no longer available for me to change. How can I update the original chosen page layouts (for performance management) to different layouts or change the chosen layouts to the default (blank) layouts?
    Thanks
    Chris van de Graaf

    AppleMan,
    It all began inside the settings of my Sanyo VPC-HD2000A when somehow the selection got switched from 1280 x 720 to that other setting with so-called 25fps. Also, I don't know whether the mishap occurred before or after I took my new footage.
    I edited the clips last night and now they are on my blog and channel and they seem ok but slightly fuzzy.
    I used a Sanyo VPC-HD2000A .7x wide angle lens with macro and I notice that when I zoomed in to the little sun conure, the picture blurred. I think that might be something that happens when one zooms the focus.
    Also, I was born and raised to a teenager in Hawaii, but now Southern California has me in its grip.
    -L

  • How can I change the red color of the news theme?

    I would prefer to use a different color for the news theme in iMovie.  Red doesn't look good with my pics.  How can I change it from red to another color?  Is that possible?

    try this
    import javax.swing.*;
    import java.awt.*;
    class Testing extends JFrame
      public Testing()
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(250,75);
        setLocation(400,300);
        JPanel jp = new JPanel();
        JToggleButton jtb = new JToggleButton("Toggle me");
        jtb.setUI(new MyUI());
        jp.add(jtb);
        getContentPane().add(jp);
      public static void main(String args[]){new Testing().setVisible(true);}
    class MyUI extends javax.swing.plaf.metal.MetalToggleButtonUI
      public Color getSelectColor(){return Color.BLACK;}
    }

  • How can i change the background color in the mobile windows adobe reader app? i want to change it from black to white but don't know how.

    really want to change the background color of my documents in the mobile app. ive tried to search the answer online, in blogs and other various 'life hacks' blogs or articles, but so far everyone is talking about the desktop version. i really want to figure this out. is there even an option for the mobile version for windows? the only editing icons when a document is open are: export, home, make public, search in document, highlight/strikethrough/underline/comment and continuous/single view. if there isnt an option to edit background color, can i suggest that the makers of the windows mobile version make one, and make it fast please! any help would be appreciated. -CHANGE BACKGROUND COLOR

    hi, thanks for helping me ...
    i have used the above url and made changes to my OAF page, but i didn't get the desired output and its also giving as the above code output .
    i kept OraBgGrayVeryDark in Css style in property inspector for every region including PageLayout and i also did some changes in cabo/styles/*.css classes.
    eventhough it is picking the color upto footer level only and it is not applying for advanced table also.
    can anyone please give your views in this..

  • How can I change the background color of a menu ring?

    Hi
    Does anybody know how to change the background color of a menu ring??? (not the backround color of the first item, the background color of the list (remains always gray))
    thanks martin

    Try Preferences>>Colors>>Menu Background, but this will change ALL menu's background color.
    Hope this helps

Maybe you are looking for