Cannot change JToggleButton background color when Windows XP theme is used

I wanted to change the background of a JToggleButton when it's pressed. I tried a few things, such as
UIManager.put("ToggleButton.select", Color.RED);
setting button's background, button's UI.
but nothing worked.
so I tried changing desktop theme from Windows XP to Windows Classic, then i was able to set button's background.
The following is a simple test program, by switching theme, the toggleButton looks differently.
Does anyone know how I can change JToggle button's background color under Windows XP theme?
Thank you in advance!
import javax.swing.*;
import java.awt.*;
public class ToggleTest {
    public static void createGUI(){
        JToggleButton button = new JToggleButton("Test");
        button.setBackground(Color.BLUE);
        JFrame testFrame = new JFrame("Test Frame");
        testFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        testFrame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
        testFrame.getContentPane().add(button);
        testFrame.pack();
        testFrame.setVisible(true);
    public static void main(String[] args){
        try{
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            //UIManager.put("ToggleButton.select", Color.RED);
        catch(Exception ex){
            ex.printStackTrace();
        SwingUtilities.invokeLater(new Runnable(){
            public void run(){
                createGUI();
}

class myToggleBtn extends JToggleButton {
  String s;
  public myToggleBtn(String str, Boolean sel) {
    super(str, sel);
    s = str;
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (this.isSelected()) {
         int w = getWidth();
         int h = getHeight();
         g.setColor(Color.green); //selected color
         g.fillRect(0, 0, w, h);
         g.setColor(Color.darkGray); //selected foreground color
         g.drawString(s, (w - g.getFontMetrics().stringWidth(s))/2 + 1, (h + g.getFontMetrics().getAscent())/2 - 1);
}

Similar Messages

  • Can I change the background color when I'm in a brochure layout?

    can I change the background color when I'm in a brochure layout? I've tried making a box in desired color but cannot push it to the back(not an option, it's greyed out)

    Then you are in a Layout template and the shape is already the back most object.
    Peter

  • How to change the background color of a cell in datagrid using flex3

    i want to change the background color of a cell.....how can i achieve this.....and also i want to know how a spacing cane be done between cells in a datagrid...plzzz help me???

    The only way I can see to do this is to use an item renderer for your cells.  This is really scruffy and would need tyding up, and maybe with a little more time could do better or someone else may have an idea but none the less this works.
    Define a custom component as below;
    This has logic to see what the value of the data is proveided by the dataprovider for the row, and if it matches the conditions in this case is equal to 5 sets the background color.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="88" height="26" dataChange="doColor()" borderColor="#000000" borderStyle="solid"
        backgroundAlpha="1">
        <mx:Script>
            <![CDATA[
                private function doColor():void {
                    if (data.value == 5) {
                        setStyle('backgroundColor', 0xcccccc);
                    } else {
                        setStyle('backgroundColor', 0xffffff);
            ]]>
        </mx:Script>
    </mx:Canvas>
    Now just apply the item renderer in the datagrid and that will do it.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  xmlns:ns1="*">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable]
                private var ac:ArrayCollection = new ArrayCollection([
                    {value : 1},
                    {value : 2},
                    {value : 3},
                    {value : 4},
                    {value : 5},
                    {value : 6},
                    {value : 7},
                    {value : 8},
                    {value : 9},
                    {value : 10}
          ]]>
        </mx:Script>
        <mx:DataGrid x="40" y="36" width="408" height="193" dataProvider="{ac}">
            <mx:columns>
                <mx:DataGridColumn headerText="Column 1" dataField="value" itemRenderer="MyComp"/>
                <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
                <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
            </mx:columns>
        </mx:DataGrid>
    </mx:Application>
    I hope this helps
    Andrew

  • Changing the background color when opening an image?

    I just installed Firefox on my new Windows laptop, and when I open an image in a new tab the background around the image is a dark gray. On my old computer the background is white, which I much prefer. How do I change this setting?

    It is a new feature in Firefox 11+ versions to display a single image centered with an almost black background.
    It is added by this stylesheet:
    * resource://gre/res/TopLevelImageDocument.css
    You can look at this extension to set your preferred background color and remove the centering.
    * Old Default Image Style: https://addons.mozilla.org/firefox/addon/old-default-image-style/
    See also these forum threads for other solutions (e.g. userContent.css):
    *[[/questions/923127]]
    *[[/questions/923431]]

  • Is it possible to change the background color when publishing as EXE Full Screen?

    I often publish Captivate projects as EXE - FullScreen. I would l like to set the background color outside of the EXE frame. Is that possible. When running my Captivate published .EXEs at full screen at a resolution greater than the project, a tan color background color appears and I would like to change it to black, or some other color. I tried the Skin - HTML background color, but that had no effect.
    Thanks
    Jack
    Captivate 7 / Windows 7

    Hi,
    it is - use the oItem.BackColor property
    BackColor PropertyDescription
    Returns or sets a value specifying the background color of text or graphics in an item.
    Property type
    Read-write property
    Syntax (Visual Basic)
    Public Property BackColor() As Long
    Remarks
    RGB value in long representation. You can use the standard Visual Basic colors, for example, vbBlue, vbYellow, etc.
    The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF).
    lg David

  • I cannot get the same colors when I print an image using Elements 12 (way off) and iPhoto (Close to Monitor color)

    My image colors are over saturated and off in tone when I try to print with Elements 12 but if I take the same image in to iPhoto the colors are much closer to what I see on the monitor.  There does not seem to be a way to match the color profile of iPhoto .
    Do you have a suggestion?

    Epson replied
    Thank you for contacting Epson regarding your Epson Stylus Photo R2880.
    We have seen an increase in calls of users using 10.7/10.8 with darkness or color issues. We do know this issue is coming from Adobe programs and they are aware of it and have told customers to test this by printing a photo from Apples Preview program, something other than an Adobe program. So if you right click on a jpeg file and select "open with", choose Preview and make settings here and print, the print should come out more like you are used to seeing. If it comes out normal, then this will tell you the program is the issue and you will need to contact Adobe for a fix or an update.
    I subsequently did a color test print with Preview  from an exported photo from Lightroom 4. I used Color Sync to manage the color with my icc profile to match the paper. The color came out perfectly. I then printed the picture with LR  having the application manage the color and the reds remain washed out with an unacceptable print.
    So it looks like the problem is with Adobe, not Epson.

  • Can you change the background colors in templates on Pages?

    I love the newsletter templates in Pages, but I can't figure out a way to change the background color. I am supposed to use specific colors so I was hoping there was a way to change the background colors in some of the tables. Is there a way?

    Hi, yes, I clicked the box that I wanted to change the background in. I made sure that the correct box was selected and not the text box on top of it. Then I clicked Fill on the top bar and selected the color that I wanted to change it to. I only wanted to change the color in certain boxes - I didn't want to change the entire background of the newsletter template. I hope I explained this ok

  • 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 fullscreen background color, so that it is the same when viewing on mac and iPad? I want this to be able to use MathType in widget text.

    How can I change fullscreen background color, so that it is the same when viewing on mac and iPad? I want this to be able to use MathType in widget text.
    As an example, html widget has white background on iPad, and black on mac. The same goes for interactive widget.
    The MathType text inserted is inserted as a image, and will have the same color when in fullscreen as when not. So I need the textcolor to be the same in both views. Anyone know how to fix this?

    We're still not communicating. This is why I wanted an example .iba.
    Here's a re-creation of my own, going off what you described. You said "all html widgets and all gallery widgets" have this problem. So I inserted a blank HTML widget and a blank Gallery widget, and typed into both. Inserted a MathType equation into both. I don't see any difference when I preview it on my Mac compared to the preview on the iPad. I want to help, but I can't help if I can't duplicate the issue.
    I've attached the screen shots and the .iba file [link to .iba file].
    Feel free to email me directly at bobm at dessci dot com. If you're uncomfortable giving some information here, tell me anything you want in email. I work for the "MathType company", Design Science.

  • Hi there, I want to change the background-color of the browser, when a popup-picture is shown. This picture pops up by clicking a hyperlink in the text...can anyone help me please...thanks a lot

    Hi there, I want to change the background-color of the browser, when a popup-picture is shown. This picture pops up by clicking a hyperlink in the text...can anyone help me please...thanks a lot

    Hi,
    CSS is interpreted by your browser, so server cache seems unlikely in htis case. There is however some hierarchy in CSS, so parts of the APEX CSS, theme CSS or page CSS might overwright or block yours.
    Does changing the CSS on runtime affect your page? Eg, run the following in your browser console and see if your page turns black: $('#uBodyContainer').css("background-color","black")
    Also try moving up your css in the hierarchy labeling it as important:
    div#uBodyContainer { 
      background-color:#000000 !important;  
    See:Assigning property values, Cascading, and Inheritance
    Regards,
    Vincent
    http://vincentdeelen.blogspot.com

  • 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>
    -------------------------------------------

  • Why can't I change the background color of my UIView in IB?

    I have a rootController which controls several other ***ViewController's and I have been doing the usual thing by changing the background color in IB.  However, for one controller, I cannot change it's background color from the default no matter what I do.
    To be clear, each new controller created has been done in the same manner using the UIViewController subclass with nib file.
    I have cleaned the project and deleted the app from my iPhone countless times and still no change.
    Any suggestions will be greatly appreciated.
    Thanks!

    @ KT
    I'm replying to myself because I cannot see your post ??????
    From my email- KT said:
    "Typically, when a same-only different controller acts up like this, the first thing to do is to rewire - sounds like you've gone down that path tho.
    Can you duplicate one of the cooperative controllers, add it to the mix and see if things change there?"
    I've tried all of that several times.  I have no idea.  Maybe some sleep will help it and me.
    Thanks for your comments and suggestions.
    Edit
    As soon as I posted this - your post appeared.  Again??????

  • How do you change the background color & font in a text-only popup?

    It has been ages since I did this and I can't seem to remember how. I tried to edit the style sheet but it only has options to change the text-only popup hotspot/link and I need to change the background color and font style within the popup itself. Tried Adobe's help but it had no answer for me. Any one out there know how to do this? I am running RoboHelp 7.

    By Popup do you mean a link that when clicked causes a separate topic to be displayed in a seperate window (popup) or Drop Down text?
    For Popups that are displayed in a new window then the font and colour is changed in the topic that is displayed. Simply open the topic and change colours / features as required
    If you are using drop down text and confusing this with a popup then the font and colour is changed when creating the drop down text. Right click the text and select Font to change colour etc.

  • How can i change my background color in "albums" mode back to black in iTunes 11

    how can i change my background color in albums mode back to black in iTunes 11?

    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>
    -------------------------------------------

  • Why can't I change the background color on title slides in 10.0.2?

    I can change the font color, but the background only seems to be able to be black. any truth in that?  Seems like the older version I had let me change the background color.

    @ KT
    I'm replying to myself because I cannot see your post ??????
    From my email- KT said:
    "Typically, when a same-only different controller acts up like this, the first thing to do is to rewire - sounds like you've gone down that path tho.
    Can you duplicate one of the cooperative controllers, add it to the mix and see if things change there?"
    I've tried all of that several times.  I have no idea.  Maybe some sleep will help it and me.
    Thanks for your comments and suggestions.
    Edit
    As soon as I posted this - your post appeared.  Again??????

Maybe you are looking for

  • All my mp3s were moved to trash and iTunes still sees them!

    I have a rather odd situation regarding the most current version of iTunes and my mp3s. Recently, I was having trouble getting my ipod nano to be recognized by iTunes. After doing much reading on this site, I found that one of the problems had to do

  • I deleted all my songs off my hard drive and I went to download them again, and i can't, is this normal?

    I deleted all my songs because for some reason they were all duplicated on my list, so i had to listen to every one of them twice so I didn't want to have the same problem when I redownloaded it. I'm new to the digital era so you can only download th

  • Is there a maximum size for an internal hard disk ?

    I just bought an 2.5" 160 Gb HD to replace my internal 120 Gb. Presently I only tried to mount it as an external disk, but it is recognized as a 128 Gb disk, not a 160 Gb. As it is a pain to change the internal HD, I would like to be sure the disk wi

  • Problem with system_moving_window

    Hi all, I have  a problem with the performance view of in the enterprise manager 11g: the graphs do not show any lines of , just axes  and when switched to tabular view, the  Time column shows Invalide Date  instead of a date.

  • E65 losing the network

    I have a new E65 since december 2007 and it loses the network every now and then for 30 minutes or even some hours. This happens almost every day and I am not able to make any calls or receive calls. This happens in places where the network is surely