Button Background Transparency?

Hi, I need help getting the background of a button to be transparent. This is the code I have for now:
private JPanel getWindow(){
if(window == null){
window = new DrawMenu();
window.setLayout(null);
button = new JButton();
ImageIcon ic = new ImageIcon("emptyIcon1.PNG");
ImageIcon ic2 = new ImageIcon("emptyIcon2.PNG");
ImageIcon ic3 = new ImageIcon("p3.PNG");
button.setIcon(ic);
button.setRolloverIcon(ic2);
button.setPressedIcon(ic3);
button.setContentAreaFilled(false); // This sets transparency to the background of the button only when it has not been pressed or rollover
button.setBorderPainted(false);
button.setBounds(60, 120, 65, 65);
JLabel lb1 = new JLabel("Music");
lb1.setFont(new Font("", Font.PLAIN, 20));
lb1.setBounds(64, 95, 70,20);
lb1.setForeground(Color.BLACK);
window.add(button);
window.add(lb1);
return window;
}This code shows the button with the icon I have assign it and its background is transparent. My problems is that when I rollover to the button or press it the background wants to become visible (it isn't quite the usual background of the button) again instead of staying transparent. The new icons of the button do show up either when I rollover the button or press it, but the background does not stay transparent it reappears. Also I should mention that the image of the icon is smaller than the actual button and I need it to stay this way. Please help me and thank you in advance.
Edited by: jrsanz1 on Mar 22, 2008 6:50 AM

Darryl thanks for the help. I forgot to mention that I need rollover and press to be active for the button in fact I'm changing the image of the icon every time either of those happen. Like you said I tried :
button.setFocusPainted(false);
// and also
button.setFocusable(false);unfortunately they haven't solve my problem. Please help. Thank You.

Similar Messages

  • Buttons with transparent background ?

    HEllo everyone:
    I have a background with a degrade color effect where I need
    to insert buttons with transparent back so dregrade can be
    viewed... welll I tried to create those buttons in FW and it is
    impossible in JPG, the I tried GIF but it does not show the white
    letters.. then I finally achieved it creating buttons in PNG and
    calling them as they are: PNG files... it works OK. but when I
    visited other computers, in som of them, I do not know why, the
    browser automatically adds a white or black back tpo the buttons,
    so it takes off the effect because it covers the degrade.... Does
    anyone please know how to deal with it ? I was wondering if this is
    much better to create all the buttons and headers as flash movies
    an insert them, but my customer requirements ar not flash at all in
    oreder to be seen in aall handhelds also.... thanks in
    advance...

    .oO(Sw Jiten)
    >Thanks Micha. It works great now. Just one curiosity: Why
    "definetly not" about
    >Flash ? Flash is working on most of the PC's now... isn't
    it time to be more
    >open to this friendly technology ?
    It's not a friendly technology, that's the problem. It
    creates many
    usability and accessibility problems and may even affect the
    system's
    performance (like any plugin does) and security. Additionally
    search
    engines are usually not able to read a Flash's content and to
    follow any
    links in it.
    Like JavaScript Flash is highly overrated and used too often
    (IMHO). It
    can be an advantage and add something useful to a site, but
    it should be
    used rarely and properly.
    > Another question: I am trying to find a pop-up calendary
    which lets you to
    >choose a date, and as soon as you do it, it changes the
    text field that you
    >have to your left (You have both text field and
    Calendary)
    >
    > I have looked for it and found many solutions in
    JavaScript on google, however
    >none of them change the text field values... any help ?
    thanks in advance...
    Can't help you with that at the moment.
    Micha

  • Xy graph legend background transparency

    I have a strange problem with LV2009. I put an XY Graph on my front panel. The legend looks like the attached pic. I can't figure out how to make the gray button backgrounds go away. I want to make them transparent.
    jc
    Mac 10.4
    LV7.1
    CLD

    Hi jc,
    I'm running into the same situation that you're seeing.  It seems that when we try to modify the gray button, it modifies the color of the legend for that plot instead of the gray button.  Attached are some examples of what I mean.  However, with that being said, it may not be possible to modify that portion of the control.  I'll do more investigation but I wanted to give you a heads up on my progress.
    Regards
    Che T.
    Applications Engineer
    National Instruments
    Attachments:
    1.jpg ‏47 KB
    2.jpg ‏49 KB

  • Title Background Transparency Doesn't Work

    Hello,
    I can't get the title background transparency to work. I'm running Premiere CS6 6.04. Clicking on the background button does nothing. Sometimes, I can randomly change the background settings to get it to become transparent, but that is not working now. Very frustrating.

    This is me setting up a title. The cursor is on the spot on the timeline that has a red christmas background. Everything appears normal.
    When I close this window, and move the title onto the timeline this happens. I haven't touched anything else (including the cursor location)

  • How to make button background color chnage

    Hi
    In my custom application having 12 buttons, out of  12 buttons one button should look totally differance than other buttons like button background color to red color.
    we found two solution even though  those are not adopted to my solution
    1. CSS technic for application, its changing whole application insted of one button inside a iview.
    2. client is not happy with  button design  like STANDARD/EMPHASIZED/PREVIOUS/NEXT
    Regards
    Malli

    Hello
    You can also use the imageAlt, imageFirst,imageSource properties of the image to enhance the button.
    and to change the background you can change the portal theme.
    Thanks

  • How do I cut out imported objects and make background transparent?

    Illustrator CS3.
    I have embedded a jpeg picture which I need to cut out and make the background transparent. How do I do this? An opacity mask? How do I create a mask the same shape as the object I need to cut out? The object needs central pieces cut out too. Please help!

    Opacity mask of clipping path are the two ways to do this in Illustrator. Photoshop is the ideal program for this task.

  • Want to change button background using UIManager for WindowsLookAndFeel

    Hi first i used ocean look and feel in my application. i used UIManager to change to color of the button. so all the buttons colors are change. fine
    But if i change the look and feel to windows look and feel it shows the windows look only. i sant to change the color to white. how?

    de to set the look and feel:
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");code to change button property
    UIManager.get("Panel.background");
    UIManager.put("Button.background", Color.WHITE);
    UIManager.put("Button.border", javax.swing.BorderFactory.createLineBorder(Color.black));
    UIManager.put("Button.opaque", true);change button properties are not affecting the jbutton. if i create.
    But if i remove the setLookAndFeel line properties are applying. why? remedy? is changing the ButtonUI is only option?

  • Background Transparency?

    Hi all,
    I'm working on a game project just now and I'm trying to get
    thought bubbles come out of characters' heads. I could do this via
    code and drawing a circle at runtime, but I want to be able to
    'tart it up' by creating proper nice bubbles using the normal
    drawing tools in flash.
    The problem I'm having though is that the stage is always
    rectangular and I can't see how to make the background transparent.
    Meaning that when I load my thoughtBubbles.swf into my main
    movie clips, it comes in with ugly white corners and the whole
    thing just looks daft!
    Can anyone help me here? Surely this problem has to have been
    solved a million times?
    Cheers,
    David

    and some more (think they all do transparency .. not sure
    about ScreenWeaver
    and some of the other less expensive ones .. SWiSHstudio
    certainly DOES
    handle transparency etc)...
    ScreenWeaver Open Source
    https://secure.sourcesecure.co.uk/trac/osflash/screenweaver/wiki
    SWiSHstudio
    http://www.swishzone.com
    SWF Kit Express
    http://www.swfkit.com
    Flash 'N Pack
    http://www.flashnpack.com
    FMProjector
    http://www.flashants.com
    Jugglor 1
    http://www.flashjester.com
    SWF studio
    http://www.northcode.com
    FlashProjector
    http://www.flashprojector.com
    ICE Projector
    http://www.flashants.com
    SWF Kit standard
    http://www.swfkit.com
    mProjector
    http://www.screentime.com
    Jugglor 2 std
    http://www.flashjester.com
    Zinc (formerly Flash Studio Pro)
    http://www.multidmedia.com
    ScreenWeaver
    http://www.screenweavermx.com
    SWF Kit Pro
    http://www.swfkit.com
    Jugglor 2 pro
    http://www.flashjester.com
    Jeckyl

  • Setting image background transparent

    I want to know how can I set the background of an existing images to transparent. I am a web desginer and currently i want's to change background color of one of my site http://twxdroid.com but here the problem arises that some of my used images background won't match up site background, so someone plz tell me how to change existing image background transparent. I heard about using magic wand selection tool or quick selection tool to make transparent but still can't figure out how to use them.

    • if the Layer is a Background Layer change it to a regular one by double-clicking it
    • make a Selection with whatever Selection Tool is appropriate
    • if you selected the background use Select > Inverse to invert the Selection
    • Layer > Layer Mask > From Transparency
    • if further corrections are needed paint on the Layer Mask – black to hide, white to show the Layer’s content
    • save the layered file as psd, psb or tif
    • File > Save for Web … to save a copy a format that fits your needs (png-24 for example)

  • Button background fill "Linear - to top" not showing after save.

    I've made the proper edits to make these buttons look very "cool" having the background filled to a gradient look which is called "Linear to top", but once I save this form and open the PDF the button color is solid rather then gradient or "linear to top"
    Any explination?

    If you have done the changes to your your button background color at the design time, it should retain the changes anywhere you open it.
    If you have done the changes to your button background color through Script, then you may need set the Save changes automatically.
    If your issue is not resolved, by changing the settings, you can post the form to [email protected], so I can have a look..
    Thanks
    Srini

  • How can I keep logo background transparent when flattening for web?

    Hi, I have a logo designed in Illustrator which I'm bringing into Photoshop to save it for the web. It comes into Photoshop with a transparent background, but when I save it for the web or flatten it, it gets a white background. Can you tell me how to keep the background transparent?

    File > save for web (& devices). That will give you the best and smallest web-ready graphics. With save as you're embedding all kinds of info that doesn't need to be in the image. File size can bloat ten-fold quickly. Use save for web.

  • Making the background transparent in export from cinema 4d to AE CC

    I'm using Cinema 4D to create a 3d object and then import it into AE CC.  When I import it in, the grey grid in the background is visible. I want to make the background transparent, so that all you can see is the object in AE.  How can I do this?

    This is not a matter of transparency. You are seeing what you are seeing because you are looking at the draft software rendering result.
    Choose Standard (Final) from the Renderer menu in the Cineware effect.

  • Export and re-import in to project keeping background transparent.

    Hi guys...
    I have had some joy and some no so joy... maybe I am doing something wrong..
    I have been using a smoke emmitter and "flattened" this and re-imported back into project to save ram or to duplicate the layer (for more smoke) and also again save ram. But sometimes the new import has a transparent background layer sometimes it is black. (Always I set all the other layers to not viewable) I have tried using keying to get rid of the black. But possibly there is a setting to keep any export/import back into project background transparent, if in a group above the bottom one. I am using QT animation setting for exports. DVC PRO HD 1080p
    Thanks.
    Cheers for all this great help... invaluable for neubie..

    Set your background to transparent (press apple+J to open the window you need) as it may currently be set to "solid" and render the movie out using Animation, as this preset will support transparency. That should do it.

  • How to turn logo background transparent?

    I need to change the logo background transparent so this logo integrates seamlessly on my website instead of looking like a big black box with a logo in it.
    Is it possible to remove the black background from every where except behind the lettering?
    Here is another similar variation:
    I dont mind the white letters, but I would want the green glow to be more apparent like the 1st one.
    Ideas?

    Is this the look you're going for?
    A sample layered psd file with your logo (as pixels; I didn't take the time to redraw it) and Outer Glow layer style, along with several test backgrounds, and the logo itself saved as a .png with transparency can be found here:
    http://Noel.ProDigitalSoftware.com/temp/SampleFile.zip
    Here's how the transparent .png looks over a web page background:
    http://noel.prodigitalsoftware.com/temp/ATMP_Transparency_Test/TransparencyTest.html
    -Noel

  • Can I make the background transparent?

    Can I make the background transparent?
    So when I embed a flex app on a web page the background should automatically be the same as the surrounding html web page.
    If yes: How do I specify transparency?

    Read this tutorial
    http://www.morearty.com/blog/2006/10/02/transparent-flex-apps-with-html-showing-through/

Maybe you are looking for

  • Error while adding custom fields using EEWB.

    Hi While trying to add custom fields using the transaction EEWB i got an error message 'No Logsys040 transport request exists for system workbench.Please let me know why it happens. Thanks sureshpaul

  • Remittance/Payment  advice for netoff in F110

    When we netoff the payment between the customer and vendor thru F110 payment run,will there be a  remittance advie or payment summary generated.

  • Laptop suddenly shuts down with battery at +60%

    Hey guys, So i had my laptop for a 6 month now, it is an MSI GT683DX Windows 8.1/Updated from  Win 7 HP,  but recently i did a battery calibration using the offical MSI software (it just charges and decharges the laptop) But now, my laptop would just

  • WLC license error

    Hi , One of my colleague purchased a 9 AP adder license for Cisco 2504 WLC. He has connected his Laptop directly to the WLC and trying to install the file via CLI. Connectivity between PC to WLC is fine, however he is receiving below error msg while

  • Logging facility on ASA

    I noticed when i try to specify logging facility on the ASA; it only allows specify in the range of 16-23. My problem is the syslog server doesn't seems to have local 16-23 (it only has local 0-7). My goal is to specify different devices (eg. router