Change Button selection color

Hay Guys,
Is there a way to change a button's background color using UIManager when it is presses or selected ?
Thanks a lot,

hi,
UIManager.put("Button.foreground", new ColorUIResource(new Color(26,67,92)));.
thanks
daya

Similar Messages

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

  • Change Highlight Selection Color

    The default color when a cell or item is selected is a light cyan. On my computer it is very hard to discern text because the light cyan highlight color and the white text run together. How can I adjust the highlight/selection color so that text is legible?

    The selected item color is actually determined by your OS. To change it in Windows XP:
    Right click on your desktop
    Properties
    Appearance Tab
    Advanced
    Item Drop down: Chose "Selected Items"
    Change the color to whatever you like

  • JPopup selection of menuitems: how to change the selection color?

    Greetings =)
    I dont want the items of my JPopup to be highlighted blue, is there a way to set the selection color for JPopup or MenuItem to a custom color ?

    U can use
    javax.swing.plaf.basic.BasicMenuItemUI for making your own UI for menu item
    then set this UI through this method:
    setUI(MenuItemUI ui) of JMenuItem

  • Changing lead Selection Color

    Hello,
    After applying themes which property do i need to to change so that the color of the row will change from from dark yellow to some light color when ever i select that perticular record
    in table UI Element.
    Thanks & Regards
       Kiran

    Hi,
    Use
    node.setLeadSelection(x)
    regards
    Ayyapparaj

  • Change Button Label Color?

    Hi --
    I am working on creating my own skin for the button component
    and I would
    like the text on the button to be white rather than black.
    How can I change
    this?
    Thanks
    Rich

    Code:

  • Change selective color(pixels) of an image.

    I want to change the selective color of an image to another desired color. I want to this in pixel's scope. If there is an image with three colors red(FF0000), green(00FF00) and yellow(FFFF00); in this case i want to change the color of red to blue, then the program should change all red pixels to blue(0000FF).
    I have to do this in an applet. Till date, i tried to implement the library function getRGB and setRGB but failed to do it completely.
    Any help (algorithm, approach, or code) will be appreciated.
    Thanks

    Use the class RGBImageFilter. The API documentation has an example of use.
    http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/RGBImageFilter.html

  • Selection Color of a text box

    As one of the project requirements, I have to provide a
    functionality in my application to be able to change the selection
    color of the text box. Having no provision in Flash, I searched on
    the net and found one good example of doing that with
    flash.geom.ColorTransform and TextFormat classes. It works fine
    with windows. However, it doesn't work on Mac OSX. I am using Flash
    8 with AS 2.0 for development.
    I am seeking some support from all the brilliant developers
    here. Can somebody help me with a solution to this problem?

    Create 4 radio buttons, all called the same name, but with export values of cent.grn, cent.amb, cent.red, cent.blk.
    Then use this as the custom calculation script for the text field:
    var v = this.getField("myRadioButtons").value;    //Replace myRadioButtons with the name of your radio button group
    if (v=="cent.grn"){
    this.getField("tf.assmnt.stat").fillColor = color.green;    
    else if (v=="cent.amb"){
    this.getField("tf.assmnt.stat").fillColor = [ "RGB", 1,.5,0 ];
    else if (v=="cent.red"){
    this.getField("tf.assmnt.stat").fillColor = color.red;
    else if (v=="cent.blk"){
    this.getField("tf.assmnt.stat").fillColor = color.black;

  • Setting JToggleButton's select color a real pain - any suggestions?

    Hi,
    I'm starting to get a bit frustrated trying to set the select color of a JToggleButton. I feel like I've wasted hours on something that should be a one liner, so I figured it's time to ask for help (again).
    I'm trying to create a very simple panel of about five toggle buttons, in a ButtonGroup, with a grid layout (1 column, 5 rows). Basically I want to create a little navigation panel that resembles the left side of the preferences dialogs in Firefox / Thunderbird (if you've seen it). However, I'm having trouble setting the select color of the toggle buttons. I know it's possible to set the color using the UIManager / UIDefaults (I don't use orange, it's just an example)...
    UIManager.put("ToggleButton.select", Color.ORANGE);... but I don't want to change the select color for every toggle button in my application.
    I've also seen posts that recommend extending the ButtonUI of the look and feel that is being used. I don't think this is a good solution because I don't intend to extend the ButtonUI of every look and feel I want (or may want) to use.
    Although I try to be picky about using quality code that is reusable, I'm at the point where I'm pretty much willing to use anything that will work, no matter how ugly. If you want to share in my frustration, try the following:
    Create a tiny app with two JToggleButtons. Label one of them "Go" and the other "Stop". Add the Go and Stop buttons to a button group so that only one may be selected at a time. Make it so when the Go button is pushed it toggles on and is green. Make it so when the Stop button is pushed it toggles on and is red.
    In fact, here's a quick hack of my tiny application. Just modify it to set the select color of stop to red and the select color of go to green.
    import javax.swing.*;
    import java.awt.*;
    public class StopAndGo
         public StopAndGo()
              JFrame mainFrame = new JFrame("Stop And Go");
              JPanel contentPanel = new JPanel(new FlowLayout());
              JToggleButton stopButton = new JToggleButton("Stop");
              JToggleButton goButton = new JToggleButton("Go");
              ButtonGroup group = new ButtonGroup();
              group.add(stopButton);
              group.add(goButton);
              contentPanel.add(stopButton);
              contentPanel.add(goButton);
              mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              mainFrame.add(contentPanel);
              mainFrame.pack();
              mainFrame.setVisible(true);
         public static void main(String[] args)
              SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        new StopAndGo();
    }As far as I'm concerned setting the select colors shouldn't be more than two 'setSelectColor(Color.SOMETHING)' lines. After all, one of the first things anyone will tell you about a toggle button is that it changes colors when it's pushed on.
    BTW, I'm using Java 1.5 on Linux.
    Thanks in advance for any help,
    Ryan

    This is a problem with the way the look and feels work and the simplest solution is to bypass it altogether.
    The code below takes each button and uses some GIFs to define what the icons are for the buttons. One is for the normal Icon for the button and the other is for when the button is selected.
    You can create your own GIFs with the colours you want. So a Red Stop button selected icon and a green go button selected icon. Two not selected icons are need to show the button when it is not pressed.
    Using the border just stops the normal button being drawn. Just the icon is seen.
    import javax.swing.*;
    import java.awt.*;
    public class StopAndGo
         public StopAndGo()
              JToggleButton stopButton = new JToggleButton("");
              JToggleButton goButton = new JToggleButton("");
              JFrame mainFrame = new JFrame("Stop And Go");
              JPanel contentPanel = new JPanel(new FlowLayout());
              ButtonGroup group = new ButtonGroup();
        stopButton.setSelectedIcon(new ImageIcon("whiteCross.gif"));
        stopButton.setIcon(new ImageIcon("blackCross.gif"));
        stopButton.setBorder(BorderFactory.createEtchedBorder());
         goButton.setSelectedIcon(new ImageIcon("whiteCircle.gif"));
        goButton.setIcon(new ImageIcon("blackCircle.gif"));
        goButton.setBorder(BorderFactory.createEtchedBorder());
              group.add(stopButton);
              group.add(goButton);
              contentPanel.add(stopButton);
              contentPanel.add(goButton);
              mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              mainFrame.add(contentPanel);
              mainFrame.pack();
              mainFrame.setVisible(true);
         public static void main(String[] args)
              SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        new StopAndGo();
    }

  • Selection Color of JSlider

    I am making a GUI for a little software game.
    But i have a problem with my slider. I want to change the selection color from the tumb from the standard "beautiful" purple to another color.
    I've tried following settings , with UIManager.put("Slider.background",new ColorUIResource(Library.SETCOLOR)):
    Slider.background
    Slider.focus
    Slider.foreground
    Slider.highlight
    Slider.horizontalThumbIcon
    Slider.majorTickLength
    Slider.shadow
    Slider.trackWidth
    Slider.verticalThumbIcon
    SliderUI
    Slider.border     
    Slider.focusInsets     
    None of these settings worked.
    I also tried all the settings listed on the following URL :
    http://forums.e-plus.com.au/thread.jsp?forum=3&thread=93
    But they did'nt work either.
    Please help me out??

    Look in the documentation in the styles section.
    Sincerely,
    Michael
    El 15/05/2009, a las 5:26, kRizzl0r <[email protected]> escribió:
    >
    hi there,
    >
    i was wondering why the TextField's selection color in AIR is 
    different from the one in the flashplayer - and if there is a way to 
    change it?
    who chose a grey tone as highlight color, and an even lighter grey 
    when the TextField lost its focus? seems like a strange decision to 
    me..
    >
    cheers
    >

  • How to change button colors in a loop?

    I am working on a task that should imitate an elevator. I have two vertical
    rows of round buttons "Up" and "Down" When a circle is selected randomly by
    the program, the circle becomes yellow and the elevator moves to that
    button.
    Here is what I did:
    1. created a class Circle where I save buttons' parameters
    2. saved Circle objects in an array
    3. drew the buttons depending on their parameters
    4. generated a random number, matched it with an array index and assigned
    the object color to yellow.
    Everything is fine except that I can't figure out how to change colors of my
    buttons in a loop.
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class Elevator3 extends JPanel
    private int n = 40;
    private int width = 200;
    private int floors = 10;
    private int interval = 1000;
    private boolean selected = false;
    private Circle[] buttons = new Circle[2*(floors-1)];
    public Elevator3()
    build();
    JFrame frame = new JFrame("Elevator3");
    setBackground(Color.WHITE);
    setFont(new Font("SansSerif", Font.PLAIN, Math.round(n/3)));
    frame.getContentPane().add(this);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(width, n*(floors+2) );
    frame.setVisible(true);
    public void build()
    Random r = new Random();
    int buttonPick;
    int timeUntilNextButton = r.nextInt(interval);
    for (int k =0; ; k++)
    if (timeUntilNextButton-- ==0)
    buttonPick = r.nextInt(2*(floors-1));
    //populate my buttons array here - how??
    timeUntilNextButton = r.nextInt(interval);
    //adding "Down" buttons
    for (int i=1, count=0; i < floors; i++, count++)
    if (count == buttonPick)
    selected = true;
    else
    selected = false;
    buttons[count]= new Circle(n*2, n*i, selected, Math.round(n/2));
    //build an array of "Up" circles
    for (int i=2, count=floors-1; i < floors+1; i++, count++)
    if (count == buttonPick)
    selected = true;
    else
    selected = false;
    buttons[count]= new Circle(n, n*i, selected, Math.round(n/2));
    public static void main(String[] args)
    new Elevator3();
    protected void paintComponent(Graphics g)
    super.paintComponent(g);
    //draw buttons
    for (int i=0; i < buttons.length; i++)
    g.setColor(buttons.getColor());
    g.fillOval(buttons[i].getX(), buttons[i].getY(), buttons[i].getWidth(), buttons[i].getWidth());
    class Circle
    private int x;
    private int y;
    private Color c;
    private boolean pressed;
    private int width;
    public Circle(int xCoordinate, int yCoordinate, boolean selected, int diameter)
    x = xCoordinate;
    y = yCoordinate;
    pressed = selected;
    width = diameter;
    if (pressed)
    c = Color.YELLOW;
    else
    c = Color.LIGHT_GRAY;
    public Color getColor()
    return c;
    public int getX()
    return x;
    public int getY()
    return y;
    public int getWidth()
    return width;

    hi,
    am sorry, i couldn't make out what exactly the problem, but as ur subject line says...
    may be the code give below will help you to change button colors in a loop..
              for(int i = 0; i < button.length; i++){
                   int color1 = (int)(250*Math.random());
                   int color2 = (int)(250*Math.random());
                   int color3 = (int)(250*Math.random());
                   Color c = new Color(color1,color2,color3);
                   button[i] = new JButton("button name");
                   button.addActionListener(this);
                   //to check the r, g, b combination.
                   //System.out.println(c);
                   button[i].setBackground(c);
                   button[i].setForeground(Color.white);
    //adding into the panel
                   panel.add(button[i]);
    hope this would help you.

  • Roadmap : color change of selected step

    Hi All,
            I am using roadmap in my application.... but in that when my step changes,then its color does not change i.e. i am not able to differentiate the selected step from the rest of steps.
           I have binded the selected step property with the context node.
          Thanks in advance...

    Hey Vishal these r the steps ,
    1.Define a node with attributes Step & Next Step.
    2.When ever you click on next Button , in event handler call this method .
    wd_Comp_Controller->Continue(  ).
    3. In Method Continue() code this.
    Node_Roadmap = wd_Context->get_Child_Node( Name = IF_COMPONENTCONTROLLER=>wdctx_Roadmap ).
    * get element via lead selection
      Elem_Roadmap = Node_Roadmap->get_Element(  ).
    * get single attribute
      Elem_Roadmap->get_Attribute(
        exporting
          Name =  `STEP`
        importing
          Value = Item_Step ).
    CASE Item_Step.
    **Set Next step
    When 'STP_DIMENSION'.
    Stru_Roadmap-STEP = 'STP_INPUT'.
    Stru_Roadmap-NEXT_ENABLED = abap_true.
    *set next step
    When 'STP_INPUT'.
    Stru_Roadmap-STEP = 'STP_RESULT'.
    Stru_Roadmap-NEXT_ENABLED = abap_false.
    When others.
    Stru_Roadmap-NEXT_ENABLED = abap_false.
    Endcase.
    Node_Roadmap->set_static_attributes( Stru_Roadmap ).
    wd_this->fire_navigate_evt( Stru_Roadmap-STEP  ).

  • How do I change the text color of footers on select pages? (InDesign CS6)

    Good afternoon,
    Months ago, I worked with a graphic designer to put together a 100-page workbook for my training company. He turned all of the files over to me and I'd like to make a small change before we print another run for a new client. Specifically, I'm having trouble changing the text color on select pages. Since a picture says 1,000 words, let me give you an example:
    As you can see, the copyright information on the right side of the page is difficult to read here when placed over the photo (you may have to look closely, but it's along the guy's sleeve). What I'd love to do is change that part of the footer (not the left, page number side) to white text. This would make it quite a bit easier to read. There's a number of other pages in the book that I want to make this change to. I'm not sure why I never noticed it or mentioned it to the designer. I suppose I've become more discerning since then.
    Let me tell you what I've tried to do:
    I learned how to override master pages by CTRL+SHIFT clicking on the footer. However, this has not worked for me. It allows me to change the page number part, but not the copyright side. Additionally, sometimes when I override the master the formatting of the footer goes goofy. For instance, the left side and right side come together and end up in the middle of the page I'm working on.
    I'm looking for a quick way to go through and make the footers easier to read on pages where they are backed by a photo. Hoping you can help me. Please let me know if you need any other information.
    Best,
    Taylor

    I think you should have left it as it was. It seems like what you had was single pages flowing as spreads within InDesign. Like below. That is the correct way, and when you changed it to all single, it did create your footer problems.
    Will you be sending the file as a PDF to your online printer? If so, then leaving the InDesign file set as below is fine. The PDF output will separate the pages.
    All you have to do is make sure that Pages, not Spreads, is chosen when you output the PDF

  • How to change the default color of the selected row

    hi all,
    I need to know how to change the default color(yellow) of the selected row in a table component.whether i need to change anything in the stylesheet.If so, where should i make the changes in the stylesheet.
    thanks and regards,
    rpk

    The chart colors are being referred to *'palette.cxml'* file in these directories
    BI_HOME\web\app\res\s_oracle10\chartsupport
    BI_HOME\oc4j_bi\j2ee\home\applications\analytics\analytics\res\s_oracle10\chartsupport
    you can change to your custom colors.
    Restart OC4J and PS to make the new ones work..
    Regards,
    Raghu

  • How to change the background color of a button when the button is emphasized

    Hi,
    I have a button that is in the "emphasized" state, I realized there is a default color "light blue" when the button is emphasized. is there any way I can change this default color? so if mu button goes to emphasized state I can control which color it should be
    I am using "Halo" for the theme, and I was not able to change the Focus color through the "Appearance Window" in Flash Builder 4
    any help would be appreciated

    Take a look at the accentColor flag of <s:Button>. It looks like you can do it there. But, it also looks like emphasized needs to be "true" and that you may need to interrupt the button's automatic update event... I've never tried to do this though. And, I imagine you only need to listen to button state changes if you want to dynamically control the emphasized color. If you just want to set a static value other than the default, it looks like setting emphasized to true and the uint of the accentColor will do the trick...

Maybe you are looking for