How to adapt icon colors to component's foreground color?

I want to display a transparent png-icon on a JButton. How can i change the color of non-transparent (foreground-)pixels in the png-icon to the foreground color of the JButton?

You'll need to study up some on basic CSS terms. 
CSS Tutorial
Align is invalid code.  What you probably want is:
     text-align:left;
     text-align:center;
     text-align:right;
Clear is only applicable to floated elements.   It doesn't remove colors.
footer {
     color: #FFF; /**this is white text**/
     background-color: #000; /**this is black background**/
/**or**/
     background:none;
Nancy O.

Similar Messages

  • The ackground and icon colors changed on my ipad. how do i change them back ?

    the background and icon colors changed on my ipad. how do i change them back ?

    that fixed it. thanks a bunch. what did i do to change it ? all i did was turn it off, when i turned it back on it was in "white on black " mode.

  • How to add background color in JFrame

    I have three classes, Car, CarComponent, and CarViewer. I don't know how to code background color. Do I add it to CarViewer where the JFrame is or CarComponent?
    CarViewer:
    import javax.swing.JFrame;
    public class CarViewer
       public static void main(String[] args)
          JFrame frame = new JFrame();
          frame.setSize(300, 400);
          frame.setTitle("Two cars");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          CarComponent component = new CarComponent();
          frame.add(component);
          frame.setVisible(true);
    }CarComponent
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import javax.swing.JComponent;
       This component draws two car shapes.
    public class CarComponent extends JComponent
       public void paintComponent(Graphics g)
          Graphics2D g2 = (Graphics2D) g;
          Car car1 = new Car(0, 0);
          int x = getWidth() - 60;
          int y = getHeight() - 30;
          Car car2 = new Car(x, y);
          car1.draw(g2);
          car2.draw(g2);     
    }

    What JSG said, plus I really don't think it's a good idea to instantiate new Car objects in a paintComponent override. Painting methods should be restricted to painting activities, as a matter of principle.
    One alternative is to construct your Car instances in a separate method and call repaint() when done; another is to provide a Car method say moveTo(int x, int y) OR refactor the draw(Graphics g) method of Car to draw(Graphics g, int x, int y). Both these suggest that you maintain the Car references as instance fields of CarViewer.
    In future (not this time), Swing related questions should be posted in the [Swing forum|http://forums.sun.com/forum.jspa?forumID=57]
    db

  • How to get background color of controls ?

    Hello everyone.
    How to get background color of controls ?
    When we use AWT/Swing,
    we can get background color of component by using Component.getBackground()
    It is regret that I can not find any method for such a method in JavaFX.
    And how do we detect the change of background color of controls ?
    Best regards.

    Hi Tadashi,
    try this.
    @Override
    public void start(final Stage primaryStage) {
        primaryStage.setTitle("Test ChangeListener");
        Button btn = new Button();
        btn.setText("change background");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                primaryStage.getScene().setFill(Color.rgb(
                        (int)(Math.random() * 255),
                        (int)(Math.random() * 255),
                        (int)(Math.random() * 255)));
        StackPane root = new StackPane();
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.getScene().fillProperty().addListener(new ChangeListener<Paint>() {
            @Override
            public void changed(ObservableValue<? extends Paint> arg0, Paint arg1, Paint arg2) {
                System.out.println(
                        "old color: " + arg1.toString()
                        + ", new color: " + arg2.toString());
        btn.getOnAction().handle(null);
        primaryStage.show();
    }Peter

  • How to get default color of a selected row in a JLIst

    I have a JList that I am changing the font color for based on a certian situation so I created my own MyCellRenderer to do this. However, when I select an item in the list the row is no longer highlighted. I used the isSelected method to determine if a row was selected and then change the background color of that row. However, I would like the color to be the default color that you get when you select a row in a default JList. I can't seem to figure out how to get that color. How do I obtain what that color is? I found an example where you can get the default color for the background of a button and use that color so I would guess it is something similar to that. My code is below so I hope someone can tell me how to get that color that I want.
    Thanks...Chris
    class MyCellRenderer extends JLabel implements ListCellRenderer {
         public MyCellRenderer() {
              setOpaque(true);
         public Component getListCellRendererComponent(
             JList list,
             Object value,
             int index,
             boolean isSelected,
             boolean cellHasFocus)
             int index1 = value.toString().indexOf("-");
               String errors = value.toString().substring(index1 + 1, index1 + 6).trim();
             int numErrors = Integer.parseInt(errors);
               if (numErrors > 0)
                      setForeground(Color.red);
                      setBackground(Color.white);          
             else
                  setBackground(Color.white);
                  setForeground(Color.black);
             if(isSelected)
                  //ColorUIResource col = (ColorUIResource)UIManager.getDefaults().get("JButton.background");
                  ColorUIResource col = (ColorUIResource)UIManager.getDefaults().get("Button.background");
                  setBackground(col);
             setText(value.toString());
             return this;
    }

    Swing related questions should be posted in the Swing forum.
    I would like the color to be the default color that you get when you select a row in a default JList. I can't seem to figure out how to get that colorlist.getSelectionBackground();

  • How do I modify a specific component within a active internalframe?

    I need to change an icon (toggle like) on a button within an internal frame when it is pressed.. I know what the active frame is. How do I address the specific component (wiithin a deskpane within a internalframe)?
    Thank you in advance,
    BAJH

    Here is a stripped down version of the program:
    i
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.OverlayLayout;
    import javax.swing.ScrollPaneConstants;
    import javax.swing.UIManager;
    import javax.swing.event.InternalFrameEvent;
    import javax.swing.event.InternalFrameListener;
    public class TestFrameButton extends JDesktopPane{
         private static final long serialVersionUID = 1L;
         JDesktopPane desk;
         JDesktopPane ifdesk;
         JScrollPane scrollpane;
         JInternalFrame iframe;
         JFrame frame;
         JList jList1;
         JInternalFrame currentframe;
         Integer currentframenumber;
         String currentframename;
         Boolean[] downuptracker;
         Integer deskwidth = 1000;
         Integer deskheight = 1000;
         Integer scrollwidth = 1000;
         Integer scrollheight = 1000;
         JButton DownUpButton;
         public static void main(String[] args) {
              TestFrameButton d = new TestFrameButton();
         public TestFrameButton(){
              downuptracker = new Boolean [99];
              frame = new JFrame("Test Frame Button");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              scrollpane = new JScrollPane(desk,
                        ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
              scrollpane.setPreferredSize(new java.awt.Dimension(scrollwidth, scrollheight));
              desk = new JDesktopPane();
              desk.setPreferredSize(new java.awt.Dimension(deskwidth, deskheight));
              int i = 5;
              for (int j = 0; j <= i; j++){
                   UIManager.getDefaults().put("InternalFrame.icon", "");
                   iframe = new JInternalFrame("Internal Frame: " + j, false, true, false, false);
                   iframe.setName(String.valueOf(j));
                   iframe.setBounds(30*j, 30*j,265 , 80);
                   iframe.addInternalFrameListener(new InternalFrameListener(){
                        public void internalFrameClosing(InternalFrameEvent e) {
                        public void internalFrameClosed(InternalFrameEvent e) {
                        public void internalFrameOpened(InternalFrameEvent e) {
                        public void internalFrameIconified(InternalFrameEvent e) {
                        public void internalFrameDeiconified(InternalFrameEvent e) {
                        public void internalFrameActivated(InternalFrameEvent e) {
                             currentframe = e.getInternalFrame();
                             currentframename = e.getInternalFrame().getName();
                             currentframenumber = Integer.valueOf(currentframename);
                        public void internalFrameDeactivated(InternalFrameEvent e) {
                   iframe.setTitle("Internal Frame :" + j);
                   iframe.setVisible(true);
                   downuptracker[j] = true;
                   ifdesk = new JDesktopPane();
                   iframe.getContentPane().add(ifdesk, BorderLayout.CENTER);
                   DownUpButton = new JButton("Old Icon here");
                   ifdesk.add(DownUpButton);
                   DownUpButton.setBounds(0, 0, 130, 20);
                   DownUpButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                             if (downuptracker[currentframenumber].equals(true)){
                                  // Colapse frame here and change icon
                                  DownUpButton.setText("New Icon here");
                                  downuptracker[currentframenumber] = false;
                             }else{
                                  // Expand frame here and change icon
                                  DownUpButton.setText("Old Icon here");
                                  downuptracker[currentframenumber] = true;
                   desk.add(iframe);
                   iframe.moveToFront();
              scrollpane.setViewportView(desk);
              JPanel overlayPanel = new JPanel();
              OverlayLayout overlay = new OverlayLayout(overlayPanel);
              overlayPanel.setLayout(overlay);
              this.setOpaque(false);
              desk.setOpaque(true);
              overlayPanel.add(this);
              overlayPanel.add(scrollpane);
              frame.add(overlayPanel);
              scrollpane.setVisible(true);
              frame.setSize(800,600);
              frame.setVisible(true);
    }Thank you in advance,
    BAJH - I will never multi-post again!

  • Change tooltip icon color in chart

    Hi,
    I like to change the tooltip icon colors for different dimensions (see image below).
    Using this CSS (svg.v-m-tooltip g.v-body path.tooltipsymbol {fill: white;}) I can turn all tooltip icon colors white but if possible I would like to change the each and every one of them individually.
    Any idea how do achive that?
    Thanks,
    Anders

    Got it to work using the below code.
    //Tooltip Color
    .chart1 svg.v-m-tooltip g.v-body path:nth-child(3).tooltipsymbol {fill: #334A6C;}
    .chart1 svg.v-m-tooltip g.v-body path:nth-child(5).tooltipsymbol {fill: #00B0F0;}
    .chart1 svg.v-m-tooltip g.v-body path:nth-child(8).tooltipsymbol {fill: #4F8F88;}
    .chart1 svg.v-m-tooltip g.v-body path:nth-child(11).tooltipsymbol {fill: #649B2A;}
    .chart1 svg.v-m-tooltip g.v-body path:nth-child(14).tooltipsymbol {fill: #FC9834;}

  • SP 2013 replace specific icon color

    I have a custom Css applied to the whole sharePoint sites, but what I want is that the sharePoint Icons was highlighted should come in white.
    I have not used themes in SharePoint and have applied custom CSS using custom master page.
    I have explored options to create custom themes and then apply in which SP theme engine generates the Sprite images.
    But creating theme will be a big ask and hence we want to stick to custom css, but want to replace specific images to white.
    Please suggest how this is possible.
    Thanks & Regards, Soumyadev | Posting is provided "AS IS" with no warranties, and confers no rights.

    Hi,
    According to your description, my understanding is that you want to change the specific icon color.
    I suggest you can use Jquery .css method to set the icon color , you can use SharePoint Designer to add Jquery code under the
    PlaceHolderMain tag in the document library view page.
    Here are some detailed code demo for your reference:
    Jquery CSS method
    How to set background color in jquery
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How do I add color to a photo?

    I was sent a photo (just a jpg) and want to color it in Pantox Reflext Blue. I can't figure out how to add this color. I tried to "set foreground color" and found the color but then I couldn't get it to apply.

    To give everything an overall tint you can create new fill or adjustment layer (icon in layers window).  Then choose color you want to add.  Adjust the opacity slider to get correct effect.

  • HT1338 How do I add colors to my folders? I can't do it on my new MacBook Air? ***

    How do I add colors to my folders? I can't do it on my new MacBook Air? ***

    Where do you want the color? The folders themselves (i.e. get rid of the blue folders)?
    If that is what you want, you can simply do a Command + I  (get info) on a blue folder. After downloading some other icons, do a get info on that icon, highlight the icon and copy it; after that, paste it into the blue folder icon. This is my user folder:

  • How to change the color of Menu links in obiee

    Does anyone knows how to change the colors of Menu links in obiee. With menu I mean the menu links default right top (Search, homepage, Catalogus, Dashboards, new, Open). This should be set in skin and style files, not? I searched a lot. I could not find It. It is now Oracle blue, we want to change this.
    obiee 11.1.1.5.
    Thanks

    You have to customize portal banner and portal content CSS files as needed in OBIEE server.
    below links will guide u but will will not tell you exactly but your req can be done by customizing portal content and portal banner CSS files. try to identify the exact code using firebug in mozilla.
    http://www.rittmanmead.com/2009/04/customizing-obiee-dashboard-banners/
    Customization of login page, banner,logo in obiee11g
    Thanks
    Jay.

  • How To Delete All Colors In a Swatch Palette?

    If I wanted to create a new swatch palette without the preset colors being there, how can I delete all the swatches at once. I know how to delete each color individually but, is there a way to clear the palette?
    TIA
    knightball

    I believe you can do it in the Presets Manager.

  • How to change front color in Visual composer

    Dear friend,
    i am taking numerical expression box into visual composer table view
    and try to change the front color in style tab for that field property
    but front color is  not changing in output(back ground color is changing ).
    how to change front color in visual composer?
    and can we change the symbol color too?
    thanks and regards,
    dushyant.

    Hi Vani!
    1. Unfortunately one of my requirements is that I can only get data from queries and not from Web Services or other sources, so no WS calling would be allowed in my deployed I-View, but thanks anyway for your suggestion.
    2. You are right, I was not clear enough in my first post. Let's say I have 3 rows and 12 columns, what I want is the following:
    ROW3 = ROW1 / ROW2
    obviously for each column. Do you have an idea about how it could be done??
    Thanks a lot,
    Andrea

  • How do I find out the component ID on a certain page?

    How do I find out the component ID on a certain page? problems is that I'm using some page template which I do not have source code for that.I need to find out the component id to pass to UIComponent.findComponent(id) as parameter. is there anyway?
    Thanks

    If you go to the partial trigger property of any of your page component you can open the edit partial trigger browser.
    There you can find the components of your template and their ids

  • How to change background color to JCheckBox in a JTable?

    Dear Friends,
    I have an JTable in my application. It has four columns. First, third and fourth column contains JCheckBox (JCheckBox is created using Boolean.class), secod column contains values.
    I have to change some of the cell color where JCheckBox is present.
    Could anyone please tell me how to change the color of the cell in the JTable?
    Thanks in advance,
    Sathish kumar D

    You would use a custom renderer.
    To get better help sooner, post a SSCCE that clearly demonstrates your problem.
    Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
    db
    Alternative link: SSCCE
    Edited by: Darryl.Burke

Maybe you are looking for

  • Smartband and Google+ notifications

    Hi There, just received my Z2 with bundled smartband yesterday - loving it so far! I only wonder if notifications for google+ will be added to the apps list, as this would make the smartband my perfect companion. Thanks for your answer! kind regards,

  • ITunes Match/Storage Issues

    I have a 16 GB iPhone 4, and I recently purchased iTunes Match, hoping to clear up some space on my phone to download iOS 7, since my music would now be stored in the Cloud.  Now, when I plug in my iPhone to sync, it says that I have 8.9 GB of music

  • Material Costing per sales area level

    Hi, We have requirement where we aer shiping the one material from two different sales areas.  we want to cost a material based on the sales area because the actual cost we are shipping to customer will be different between these sales areas.  Is it

  • Question on Offline Game Apps

    HI, I am new to all of this, just purchased an IPhone4 and I want to download some paid apps for solitaire type games but I want to play these games offline not online. I downloaded solitaire game but it can only be played online. Are there offline a

  • Can't Turn off 2-sided printing photosmart 7510

    The printer insists on printing 2-sided, and I can't figure out how to turn it off in Mac OS X 10.10. It seems to happen mostly in Word, but that may only be because I usually only print from Word.