Painting background of transparent icon

I have an ImageIcon that came from a transparent gif. Is there a way to control how the background color is painted, for example setting the background to red or white? Thanks.

That's one way to do it but it may not be appropriate - eg the component may have an empty border, it may contain other content, it doesn't alter the icon when displayed elsewhere, etc.
If you want to cook a new icon then:
1. create an image of the same size
2. get the graphics object from it
3. fill the graphics with the chosen background color
4. draw the original image onto the graphics
5. create a new ImageIcon using this new image

Similar Messages

  • How to paint transparent icon on component?

    I am trying to paint a transparent image onto a swing component. The image is painted, but the transparent regions of the gif are painted as grey! How to overcome this problem?
    class PrettyComboBox extends JComboBox{
    ImageIcon imageIcon;
    public PrettyComboBox(){
    setOpaque(false);
    this.imageIcon = new ImageIcon("transparentRegions.gif");
    protected void paintComponent(Graphics g){
    super.paintComponent(g);
    imageIcon.paintIcon(this, g, 0, 0);
    Any help or comments greatly appreciated!

    Actually I've figured out how to make the combobox editable and also paint an icon. Now if only I could get the transparency of the icon working, I'd be set!
    BTW the following code is how I use a ListCellRenderer in conjunction with an editable ComboBox, the trick is to set the renderer AFTER setting the combobox to be editable.
    class PrettyComboBox extends JComboBox{
    ImageIcon imageIcon;
    public PrettyComboBox(Vector vec){
    super(vec);
    setEditable(true);
    setRenderer(new ComboBoxRenderer());
    setOpaque(false);
    this.imageIcon = new ImageIcon("hasTransparentRegion.gif");
    protected void paintComponent(Graphics g){
    super.paintComponent(g);
    imageIcon.paintIcon(this, g, 0, 0);
    public class ComboBoxRenderer extends JLabel implements ListCellRenderer {
    public ComboBoxRenderer(){
    setOpaque(true);
    public Component getListCellRendererComponent(
    JList list,
    Object value,
    int index,
    boolean isSelected,
    boolean cellHasFocus) {
    setText((String)value);
    //add image to label, if desired
    return this;
    thanks for the comments!
    how the heck do you get code snippets
    to indent properly on this messageboard?
    -Tom

  • Hi, i am really new to photoshop and i have a design which i need to have the background made transparent? can anyone assist please?

    hi, i am really new to photo shop and i have a logo design which i need to have the background made transparent from a white square? can anyone assist please?
    i have already got the image on my screen but cant seem to find the tool in which to make it transparent as i do with other softwares.

    hi aknaloku,
    is the background apart of your image or is the image on a different layer?
    if the white background is on a different layer you can simply delete the layer for the layers window which you can find in Window>Layer. you will need to delete the background layer by dragging it into the little rubbish bin icon down the bottom right of the layers window.
    i hoped this helped
    Matty

  • Background-color:transparent !important; is not working in IE

    Hi,
    In my sharepoint site i have used "background-color:transparent !important;" css. It is not working in IE but in Mozilla is working fine.
    And I am using IE 11. Please let me know is there any thing wrong in the syntax. If that is the case please provide me correct solution for that.
    Any help would be greatly appreciated. 
    Regards,
    Saya 

    Thank you for your reply.
    I have checked given links. Those are not use for this issue.
    Actually in my sharepoint site the same code "background-color:transparent
    !important;" was working fine before installing sharepoint 2010 service pack 2. After installation we got this issue. And if i change "transparent"
    with any color, it is applying that color. Only "transparent"
    background css is not working in IE.

  • When I open Firefox, the background of the icon on the bottom of my screen turns green on the left side.

    When I open Firefox, the background of the icon on the bottom of my screen turns green on the left side.

    If you want to remove saved form data from a drop down list then use these steps:
    #Click the (empty) input field on the web page to open the drop down list
    #Highlight an entry in the drop down list
    #Press the Delete key (on Mac: Shift+Delete) to remove it.
    *http://kb.mozillazine.org/Deleting_autocomplete_entries
    See also Clear Recent History
    *https://support.mozilla.org/kb/Clear+Recent+History

  • When inserting a .pdf of a document with a standard white paper color the test and images show up, but the white background is transparent. How do you also make the white paper color show up?

    When inserting a .pdf of a document into a Keynote template with a standard white paper color the text and images show up, but the white background is transparent. How do you also make the white paper color show up?

    Use the color fill option - select the inserted .pdf and assign a fill color of white to it using the Color Fill Menu on the Toolbar or the Color Picker Palette.
    Good Luck.

  • Blue background under finder icon in dock

    Hi guys, i have this problem (as you can see on screen shot - blue background under finder icon in dock), what i need to do to fix it?

    try candy bar just search it in the Mac osx software

  • Make List background color transparent

    hello all,
    i want to make my list background color transparent.
    this is my code:-
    import mx.styles.CSSStyleDeclaration;
    _global.styles.List = new CSSStyleDeclaration();
    _global.styles.List.setStyle("backgroundColor",
    "transparent")
    it is working fine but after using this code listbox
    selection listener stop working.Is there any other way to make list
    background transparent?
    thanks in advance

    I was having the same problem with a Tree Component. Just
    yesterday I found some code to let me do this. Where
    tabs.menuContent is the path to my Tree, or your List
    var mc = tabs.menuContent;
    _global.styles.ScrollSelectList.backgroundColor = undefined;
    mx.controls.listclasses.SelectableRow.prototype.drawRowFill
    = function(mc:MovieClip, newClr:Number):Void {
    mc.clear();
    if (newClr == undefined) {
    mc.beginFill(0xABCDEF, 0);
    } else {
    mc.beginFill(newClr);
    mc.drawRect(1, 0, this.__width, this.__height);
    mc.endFill();
    mc._width = this.__width;
    mc._height = this.__height;
    tabs.menuContent.border_mc._alpha = 0;

  • Textarea ...  background-color:transparent   causing problem in IE7

    hello;
    when I use <textarea style="background-color:transparent " > IE7 does not accept input ... other browsers work fine;
    is there a way to get a transparent background for a textarea such that the textarea functions correctly in IE7 ( I haven't tested it in IE8 )?
    thanks,
    Shannon

    What happens if you remove the background tag altogether?
    I do this with my overflow css for text boxes and it leaves them transparent (as in: showing the page background) in Firefox, Safari Opera and IE 5, 6, 7 and 8.

  • Imported SWFs background to "Transparent" in Presenter?

    Is it possible to set an imported SWFs background to transparent within Presenter?  I have Presenter 7, PowerPoint 2007, Flash CS4, working in Windows Vista.
    The only way I know to set SWF transparency is with the WMode parameter... so, in PowerPoint, if I right-click the imported SWF and choose "Properties" I get the Properties window which contains a field WMode.  I set this to "Transparent", but when publishing the Presenter file to "My Computer" the original SWF background (white in this case) still shows up.
    My PowerPoint has a gradient background, and my SWF file's stage is smaller than my PPT stage.  Making teh SWF BG transparent will allow me to place the SWF wherever I need to on the PPT stage without having to worry about lining up background gradients precisely.
    Any help is appreciated.

    So, not even 4 years later, and after 2 new versions of Flash can we still not produce a transparent background to be able to seamlessly go in a Powerpoint 2010 file?  I imported a single/looping file under the <Insert Tab. It had a transparent backgound and a playhead with start/stop on it. Can't remember how I did it though? 
    Thanks,

  • Combobox background displaying transparent - help

    I have 5 comboboxes in a form and I can not get them to react
    to AS at all. In addition, their backgrounds are transparent so the
    list is stepping on other information underneath it - making it
    unreadable.
    I've tried setting a styleObj and attaching it and then
    setting the style properties, but nothing seems to work. I'm in
    Flash 8.
    any help will be greatly appreciated.

    The combo boxes themselves where the problem. They came from
    another file and for some reason, they just weren't accepting the
    setStyle. I deleted them and dragged in new components to the stage
    and the new ones worked.

  • Background is transparent - HELP!!!!!

    my itunes background is transparent, when it comes up I can see whats behind, like the desktop or a website. I can barely read the songs/artists names, but the white background is gone!!! please help!!!
    I posted before and got some answers, but tried everything and didnt work.
    If it helps, I notice that something is dif when I check websites or write emails, like they are a bit shaky when I move the cursor over it, or write an email. Maybe that has something to do? some graphic issue?
    HELP HELP HELP!!!

    jaykay, the first thing i try with the "transparent" itunes is updating the DirectX on the PC. if no joy with that, try making sure that the video drivers on the PC are up to date.
    the following document is on sound issues, but down the bottom it has good links on updating both DirectX and video drivers:
    iTunes and QuickTime for Windows: Songs and other audio don't play correctly

  • Dark blue background and weird icon placement on jump list (recent files) of apps in task bar

    Hi, I recently made a factory reset of W8.1, and now I'm seeing a weird and very annoying dark blue backgound in the list of recent files that appears when you right click an app pinned to the taskbar. Also, the "pin to taskbar" and "close window" icons show sort of out of place and apparently larger than normal    I've tried looking through every possible setting but I can't find anything related to this list in particular. Any ideas?
    Thanks in advanced.

    MechPilot wrote:
    Hello @Adrianrff, I understand that a dark blue background and strange icon placement on the jump list of apps in the task bar of your computer, and I would be happy to assist you in this matter! Since this issue occurred after performing a factory reset, I suggest performing a full system recovery by following the steps in this resource on Backing Up Your Files (Windows 8), as well as Performing an HP system recovery (Windows 8). This should return the jump list and icon sizes back to factory settings.
    If the issue continues, please contact our technical support for further assistance in this matter by clicking the link below to get the support number for your region.
    www.hp.com/contacthp/
    I hope this helps!
    Regards Thanks for the suggestion, MechPilot. I did a full system recovery but unfortunately it did not work. Apparently the color of the background matches the color chosen in Windows first startup, but I don't remember having chosen white the first time, everything looked fine then. Any other suggestion?

  • Opera icon in fluxbox background not transparent

    my opera icon in iconbar background is not transparent, how to make icon background transparent?

    Dogs1985 wrote:
    SIGTERM wrote:I guess what you could do is replace "/usr/share/pixmaps/opera.xpm" with a transparent opera.xpm, right?
    but i find this file is transparent.
    Oh, well that's strange. Does that mean the WM is to blame?

  • Transparent Icon - Can't Open

    I'm running OS version 10.2.1.2141. I installed "Backgrounds (OGQ)" app from the 1Mobile Market. When I try to set a picture as a wallpaper, and choose the "Backgrounds" app to do so, it is able to set my new wallpaper. As soon as I set it as my wallpaper, I'm sent back to my home screen and the "Backgrounds" app goes to the active frame section. When I close the "Backgrounds" app and then go to find the app icon for it, it appears transparent (just like when you hold your finger over any app icon). I can't open the app when it's transparent. I've tried closing the app under "device monitor", but that doesn't reset the app. So far the only solution has been to reboot the phone. 
    I know this "Backgrounds" app is not native to BB OS; but is there an alternative solution to this? 
    Thanks

    Have you tried deleting the app, rebooting and reinstalling?
    It could just be that app is not going to be compatible.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

Maybe you are looking for

  • What to look for in free fonts?

    I want to download some free fonts (I am a student) to use for some 300ppi print pieces and am wondering what to look for in a free font to determine whether it will print nicely at a high quality. What makes a good quality font? I know there is lots

  • How to create Rules with Flex Field mapping in the bpm worklist

    I Have created a flex field label and was able to map to the flex field attributes . But when i try to create a rules , I don't see the label or the flex attributes in the task payload . Can someone please help is understanding how to create Rules wi

  • Setting Up a New Mac From Two Different Time Machine Back-ups?

    Greetings Apple People, I am planning on getting a new iMac. Right now my wife I are still using our separate MacBooks from college. Both of them have Time Machine back-ups. We would like to setup our new iMac to have two different users. Is it possi

  • What's with Skype Ignoring My Privacy Settings?

    I prefer to be invisible and not have announcements going out about when I'm online. So why are my contacts telling me they're now seeing status changes about me? I've configured all of the following: Status:  Invisible [  ] Allow my online status to

  • ZenDM7Sp1 Inventory Rollup NFG.

    Hello: I have a Zen7 SP1 DM Deployment with dedicated Zen Servers. 1 Root Server with Database and workstations Connected at one site. 2 leaf servers w/o dB and workstations connected at WAN sites WAN sites are 1) 100Mb FDX and 2) a Full T1 to the ot