How to remove underlying JButton image?

Hi
I have this code to place an image over the standard JButton. But if the image is smaller or transparent, the underlying standard image is still seen. Is it possible to remove this image and just have the background of the panel showing?
public class ImageButton extends JButton {
     public ImageButton(ImageIcon icon, String text) {
          setSize(icon.getImage().getWidth(null),
               icon.getImage().getHeight(null));
          setIcon(icon);
          setMargin(new Insets(0,0,0,0));
          setIconTextGap(0);
          setBorderPainted(false);
          setBorder(null);
          setText(text);
                setHorizontalTextPosition(this.CENTER);
/code]
Thanks for any help.
Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

OK, you have to choose your own background and button image. But the button image should be transparent, as I want the background image to show through, but it's not.
Here's the ImageButton, setting the button image.
import javax.swing.*;
import java.awt.*;
public class ImageButton extends JButton {
     public ImageButton(ImageIcon icon, String text) {
          setSize(icon.getImage().getWidth(null),
               icon.getImage().getHeight(null));
          setIcon(icon);
          setMargin(new Insets(0,0,0,0));
          setIconTextGap(0);
          setBorderPainted(false);
          setBorder(null);
          setText(text);
          setHorizontalTextPosition(this.CENTER);
}Here's the ImagePanel setting the background:
import java.awt.*;
import javax.swing.*;
public class ImagePanel extends JPanel {
    private Image img;
    public ImagePanel(String img) {
        this(new ImageIcon(img).getImage());
    public ImagePanel(Image img) {
        this.img = img;
        Dimension size = new Dimension(img.getWidth(null),img.getHeight(null));
        setPreferredSize(size);
        setMinimumSize(size);
        setMaximumSize(size);
        setSize(size);
        setLayout(null);
    public void paintComponent(Graphics g) {
        g.drawImage(img,0,0,null);
}And here is the calling code. I want the background image to be visible through my transparent button image. But it looks like a normal JButton is showing instead.
import javax.swing.*;
public class ImageTest {
    public static void main(String[] args) {
        ImagePanel panel = new ImagePanel(new ImageIcon("images/background.png").getImage());
        final ImageButton button = new ImageButton("images/buttonup-blank75.png");
     button.setLocation(30,30);
        panel.add(button);
        JFrame frame = new JFrame();
        frame.getContentPane().add(panel);
        frame.pack();
        frame.setVisible(true);
}

Similar Messages

  • How to remove an existing image from panel

    hi i am working on a project and a bit confuse in images
    pls tell me how i can remove an existing image from a panel and place another one on it by clicking a single button
    pls help me and give me ur suggestions.
    thanks in advance

    pls tell me how i can remove an existing image from a panel and place another one on it by clicking a single buttonthe simplest answer is to use a JLabel to display your image, then on button click
    label.setIcon('theOtheOne');

  • How to remove a loaded image on the stage from a symbol containing a button?

    1st the setup:
    General map is loaded
    2. On a click event, an larger image of the region is loaded with the following code (thanks to Joel's demo). On mouseover the name of the county appears and on click a popup (symbol) shows some info.
    $('<img id="region1" width="310" height="475" src="images/region1.png" usemap="#region1">'+'<map name="region1">'+...
    '<area id="Dallam" shape="rect" title="Dallam" coords="29,17,97,58"/>'+.....
    3. In the popup symbol, I want the large image map to be remove on the click event of the button: "View another region" . I have the following code which does not work (the image is not removed) resulting in what you see below:
    sym.playReverse();
    sym.getComposition().getStage().stop(0);
    sym.getComposition().getStage().getElementById("region1").remove();
    So my question is how do I remove the image (large image of the region in purple here loaded as described on 2.)?

    I got it. It should be:
    $("#region1").remove();  
    // # was missing.
    I actually added that to time 0 on the main timeline so when I got back there it removes the image.
    It's not working from the symbol yet but I guess I should eventually get it working from there instead.
    Thanks for your time.

  • How to remove watermarks from images which have been inadvertently applied via the Lightroom Export function? [was: Help!]

    I put a watermark on a photo in Lightroom 5  and exported it to a file. I then had another group of images which I exported and they all had the watermark on them and I can't get rid of the watermark

    Export the photos again, but in the Lightroom Export dialog box, remove the check next to Watermark

  • How to remove background on image

    Hi I would like to make the background on the attached image white and to manipulate the silver jewellery on the image attached so that it shows up clearly against the white.
    I've tried all sorts of things but found that either the image blends into the background when white or the silver does not look metallic any more.  I have around 100 images that I need to edit in this way for my website so any advise would really be appreciated.
    Here is a link to some sample pictures
    http://littlewonders.no/index.php?page=details&prod=37&cat=43&group=
    As you can see the back ground is different on each image and does not look professional.
    Thanks in advance

    Silver on white is very much contrast dependent and the base of that starts with the original photo. I think what you are looking for is a look like this.
    This is just camera. For instance if you where taking photos of each piece, I would have the camera on a tripod and locked in position with the while layer drop to place each piece on. Each photo would be the same angle same lightness.
    This issue you have trying to remove the white background is that silver is mostly white, so removing the background is very tricky from the start, also removing the background you remove the shadows that give it a more realistic appearance.
    restaging and reshooting all the images would be much faster then trying to remove the backgrounds on a 100 images of silver pieces and make them look right.
    You may concider a black satan background behind the silver pieces too black tends to show off the silver much more brightly then white would.

  • How to remove noise on images acquire from Digital 8 VCR to PCI-1409 frame grabber ?

    I have some constant noise in the form of a discontinuous white horizontal line running accross the top of images which were grabbed from a digital 8 video signal. I have tried all the settings in MAX to remove these and have check the integrity of my connections, but to no avail ?

    Kyle,
    I found that adjusting the acqu window did the trick.
    It seems that all the video i have on Digital 8 tapes gives me the same problem. When i use the camera directly to the frame grabber there is no problem.
    In due course i'll try another camera with the Dig 8 VCR and compare these output picture quality.
    Thanks for the advice,
    Fraser

  • How to remove background from image?

    Hello folks.
    I am trying to incorporate some business logos into a brochure I am creating. The problem is, most of these logos have a white background. How can I remove this and make a transparent background?
    Thanks!

    Blend modes are your friend. always keep in mind that Multiply, screen and overlay affect the white, black and gray depending which one you choose.
    Attached is a blend mode example from photoshop using a black to white gradient.  The normal layer fills the document with.the blend layers on top with the gradient inverted.
    This example is text naming the solid color backgrounds blended over a gradient.

  • How to remove multiple iphoto images from imovie timeline?

    When I import still photos into imovie  from iphoto, and drop them on the timeline in imovie,  instead of a single picture appearing I get multiple copies of the same photo.  Can anyone suggest a cure or workaround?

    If you are draggin straight out of iPhoto into the iMovie window, I don't know what kind of reaction you will get out of iMovie. If you use the Photo Browser tool in the iMovie Toolbar, it should let you do multiple selections and still drag them to the timeline (hold down ⌘ Command key and select individually or hold down Shift and select a range).

  • Scene7 eCatalog HTML5 Viewer - how to remove bg image

    Trying to figure out how to remove the background image page divider on this viewer.
    Default style:
    .s7pageview .s7pagedivider {
        background-image: url("/s7sdk/2.4/images/sdk/divider.png");
    I tried adding a style sheet with:
    .s7pageview .s7pagedivider {
        background-image:none;
    but it broke all the other styles such as the viewer tools.
    Thanks.

    I don`t see any links in the code, could it be a default
    setting?
    And it doesn`t matter which order I put in the pictures its
    always the first three that have the link. Here is the code, could
    you look at it?
    thanks, Tibor
    <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0"
    width="850" height="500">
    <param name="flash_component" value="ImageViewer.swc"
    />
    <param name="movie" value="slideshowgallery5.swf" />
    <param name="quality" value="high" />
    <param name="FlashVars"
    value="flashlet={captionFont:'Verdana',titleFont:'Verdana',showControls:true,frameShow:fa lse,slideDelay:6,captionSize:10,captionColor:#333333,titleSize:10,transitionsType:'Fade',t itleColor:#993300,slideAutoPlay:true,imageURLs:['treework/ontop.jpg','treework/firthinning .JPG','treework/climbing.jpg','treework/bigremoval.jpg','treework/bigremoval2.jpg','treewo rk/firpruning.JPG','treework/tiborarborist.JPG'],slideLoop:true,frameThickness:2,frameColo r:#333333,bgColor:#BBBB70,imageCaptions:[],title:'Arborist
    Work'}" />
    <embed src="slideshowgallery5.swf" quality="high"
    flashvars="flashlet={captionFont:'Verdana',titleFont:'Verdana',showControls:true,frameSho w:false,slideDelay:6,captionSize:10,captionColor:#333333,titleSize:10,transitionsType:'Fad e',titleColor:#993300,slideAutoPlay:true,imageURLs:['treework/ontop.jpg','treework/firthin ning.JPG','treework/climbing.jpg','treework/bigremoval.jpg','treework/bigremoval2.jpg','tr eework/firpruning.JPG','treework/tiborarborist.JPG'],slideLoop:true,frameThickness:2,frame Color:#333333,bgColor:#BBBB70,imageCaptions:[],title:'Arborist
    Work'}" pluginspage="
    http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
    type="application/x-shockwave-flash" width="850" height="500">
    </embed>
    </object>
    I tried deleting the pluginspage part of it ,but on the
    preview it didn`t make any difference.

  • How to remove the white space that is now above the main images on each page?

    http://www.nydogworks.net
    Hello,
    I took over updating some things on my site from my web designer. The main images on each page used to be flush with the navigation bar on each page. Now there is a white space in between each one. Can you tell me how to remove the white space?
    <div id="container">
    <div id="imgholder"><img src="images/feature-aboutus.jpg" width="951" height="341" alt="" />
    </div>
    <div id="pageContentNoside">
       <div id="sideSub">
         <form action="form.php" method="post" name="form2" id="form2"> <table width="250" border="0" cellpadding="2" cellspacing="2">
           <tr>
             <td width="273"><h2>Quick Contact</h2></td>
             </tr>
           <tr>
             <td class="mainContent">Your Name</td>
             </tr>
           <tr>
             <td><span class="style9">
               <input name="forname" type="text" class="colorfieldssmall" id="forname" size="20" />
               </span></td>
             </tr>
           <tr>
             <td class="mainContent">Your Email Address* (required)</td>
             </tr>
           <tr>
             <td><span class="style7 style9">
               <input name="admail" type="text" class="colorfieldssmall" id="admail" size="25" />
               </span></td>
             </tr>
           <tr>
             <td class="mainContent">Phone Number</td>
             </tr>
           <tr>
             <td><span class="style7 style9">
               <input name="phone" type="text" class="colorfieldssmall" id="phone" />
               </span></td>
             </tr>
           <tr>
             <td><span class="mainContent">Type of Dog Training</span></td>
             </tr>
           <tr>
             <td class="mainContent"><span class="style9">
               <select name="need" class="colorfieldssmall" id="need">
                 <option value="select one">select one</option>
                 <option value="Basic Obedience">Basic Obedience</option>
                 <option value="Behavior Therapy">Behavior Therapy</option>
                 <option value="Board and Train">Board and Train</option>
                 <option value="Off Leash Training">Off Leash Training</option>
                 <option value="Puppy Training">Puppy Training</option>
                 </select>
               </span></td>
             </tr>
           <tr>
             <td> </td>
             </tr>
           <tr>
             <td><div align="left">
               <input type="submit" name="submit" id="submit"  value="Submit" />
               </div>
               </td>
             </tr>
           </table></form>
         <h2><br />
           Dog Training Services<br />
           </h2>
         <ul id="subnav">
           <li><a href="basic-obedience.html">Basic Obedience</a></li>
           <li><a href="dog-behavior-therapy.html">Behavior Therapy</a></li>
           <li><a href="board-and-train-dog-program.html">Board & Train Program</a></li>
           <li><a href="off-leash-training.html">Off Leash Training</a></li>
           <li><a href="puppy-training-program.html">Puppy Training</a></li>
           </ul>
         <br />
         <br />
         <br />
         </div>
      <div id="suggestPost"><a href="https://www.facebook.com/pages/NYDogWorks/219268038151244?fref=ts" ></a></div>
       <div id="mainContent">
         <h1 class="copyrightType">About NY DogWorks</h1><br />
         <h2> <span class="testimonal">The Owner of NYDogWorks</span>      </h2>
         <p><span class="copyrightType"><img src="images/dogpic.jpg" alt="Dog Behavior Therapy" width="183" height="275" class="h_img_float_right" /></span><strong>NYDogWorks L.L.C. is owned and operated by Master Certified Dog Trainer and Behavior Specialist Brian DeMartino. </strong><br />
           <br />
           His training is hands down the best out there. He has become one of the most sought after dog trainers throughout Long Island, Manhattan, &amp; New York.<br />
           <br />
           With over 15 years experience training and rehabilitating some of the toughest cases of dog behaviors. He’s Mastered the Art of teaching top knotch obedience and manners with outstanding results and has developed the most full proof and guaranteed system to fully housebreak any puppy or dog in the shortest amount of time.<br />
           <br />
           He is Certified in dog training and dog behavior and is an Official Evaluator for the American Kennel Club’s (C.G.C) Program.<br />
           <br />
           <br />
           <strong>All About NYDogWorks</strong><br />
           </p>
      <p><br />
      </p>
         <p>NYDogWorks Dog Education, is a Professional Dog Training Company offering dog training for puppies and older dogs through customized in-home training programs by Master Certified Trainers in Nassau County, Suffolk County, Hamptons, Long Island, Manhattan, Brooklyn, Bronx, Queens, Rockland County, Westchester County, Orange County, and Bergen County New Jersey. NYDogWorks offers obedience training, Housebreaking, Manners, socialization for your dog,  Puppy Training and Education, Behavior Therapy, Trick Training, Agility, Complete Off Leash Training, Sport Work, and Personal Protection Training. <br />
           <br />
           <strong><br />
             NYDogWorks Boarding &amp; Training Programs</strong><br />
           </p>
      <p><br />
        We offer boarding and training programs done in the home of owner, Brian DeMartino. This is a customized 2-6 week program to suit your dog's needs, great for someone who feels they do not have the time or patience to train or rehabilitate their dog at their home. This is a 100% guaranteed program. Your dog will stay with us for no additional charge if we feel that he or she has not learned all that was agreed upon. We guarantee that if there is any regression within 3 months of your dog being back home with you, he/she will come back to us for no additional charge.<br />
        <br />
        <a href="board-and-train-dog-program.html">View Boarding &amp; Training Programs</a></p>
         <p><br />
           </p>
         <p><br />
           <br />
      </div>
       <div id="breadCrumbs">
         <p><a href="index.html">Home</a> &gt;  NY DogWorks - About Certified Dog Trainer Brian DeMartino<br />
           <strong>Serving all of Long Island, Nassau &amp; Suffolk County, Manhattan, Brooklyn &amp; Queens</strong></p>
         </div>
    </div>
        <div id="footer">
          <div id="footermenu">
          <div id="footermenu1">
          </div>
        </div>
       <div class="phoneNumber" id="copyright"> Copyright © 2014  NY DogWorks</div>
         <div class="websiteDesign" id="sitedesigner">Long Island Website Design by <a href="http://www.wetribet.com" title="Wet Ribet" target="_blank" class="medlink">Wet Ribet</a>     </div>
    </div>
    </div>

    You should be able to add the following snippets of css to your stylesheet to fix that.
    In the mainstyle.css file, change...
    #imgholder {
    width: 950px;
    margin-top: 0px;
    padding: 0px;
    margin-right: auto;
    margin-left: auto;
    to
    #imgholder {
    width: 950px;
    margin-top: 0px;
    padding: 0px;
    margin-right: auto;
    margin-left: auto;
    overflow:hidden;

  • When I try to same an image under the command 'save as' it will only let me save as file types 'firefox document' or 'all files' and when I try to look at them later they dont work. How can I save an image as the same file type it is on the web site?!

    When I try to save an image under the command 'save as' it will only let me save as file types 'firefox document' or 'all files' and when I try to look at them later they dont work. How can I save an image as the same file type it is on the web site?!
    == This happened ==
    Every time Firefox opened
    == I updated to one of the firefox versions (Not sure which one it was)

    Thanks Alex, but sadly I already tried that. Neither .docx or .xlsx files show up in the content list. They both show as a Chrome HTML document so changing how Firefox addresses those doesn't help since it thinks its the same type of file. I don't think I can manually add files into the "Content Type" left side nav.

  • I read the article on how to remove Bing; however, it does not show up on my list of installed programs and it does not show up in the list of extenstions under "Tools" and "Addon" yet it is installed as an extention to the right of the addlress line.

    I read the article on how to remove Bing; however, it does not show up on my list of installed programs and it does not show up in the list of extenstions under "Tools" and "Addon" yet it is installed as an extention to the right of the addlress line. It is not my home page. Help!!!

    See also:
    *https://support.mozilla.com/kb/Removing+the+Search+Helper+Extension+and+Bing+Bar
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    *http://kb.mozillazine.org/Resetting_preferences

  • How to remove cached images in html whe going from one page to another page

    can anybody help how to remove cached images in html pages.i tried with response.setHeader("no-cache") but it is not working

    thanks,
    can u tell me how to make the browser not to cache images.since iam moving from one page which has images, into another page which having few more images both gets overlaped so how to remove images of previous page.
    thanks in advance

  • Does anyone know how to remove images from google

    i had instagram and i didnt upload images of myself but i only used my own image in the display picture and some how it has gone on to the google image search yesterday i deleted my account but when i checked to see if my images do appear in the google images i had some really bad regrets !! i reallywant to know how i can remove pictures off the google image search  even doe this does not kind of relate thank you .

    Does anyone know how to remove vocals from an import from I tunes...a  polyphonic stereo mix ?
    If you are talking about some "Karaoke" method using Logic I'll try to offer one. Before that I must say that most of the Karaoke methods are based on reversing the Phase of one of the stereo channel and bussing or merging the stereo into Mono. The result is: killing all Pan Centered in the mix - like Main Vocal, Bass, Kick, SN ect.
    The artifacts of the Stereo FX of the main vocal will stay in the Karaoke, cause the FX is stereo etc.
    Here is the Logic Setup I can offer to try some Karaoke trick using Logic.
    1. Import a Stereo mix into a Logic Stereo track.
    2. Create another stereo track and duplicate (copy) the Original Mix region to the duplicated track.
    3. Hard Pan L/R both stereo tracks.
    4. Insert an EQ and Gainer plugins into the duplicated track (R).
    5. Set the Output select of the both tracks to a Bus and assign the new Aux Track Switch mode to "Mono".
    6. Open the Gainer plugin and thick the "Phase Invert" Right button.
    7. To keep the "lowend" instruments like the bass and kick, open the EQ plugin and enable the Low Cut filter and try some Hz settings 80-115, or different Q which will sounds better for your Karaoke.
    P.S Click the image below to show its real resolution!
    Regards,
    A.G
    ======================================
    www.audiogrocery.com
    Author of: Logic GUI Deluxe(Free), Vox De Bulgaria s.a.g.e vocal pack for RMX, Logic Snapshot Console, RMX Power CTRL - Logic Environment Midi editor for Stylus etc.
    ======================================

  • How do I remove Canon " My Image Garden" from the desktop when turning on my computer ?

    How do I remove Canon " My Image Garden" from the desktop when turning on my computer ?  I have the icon but the program starts up and I have to delete it manually  from the desktop to clear my screen for other work...

    Are you using a Windows or a Mac? What you're seeing (the backwards L shaped menu) is probably the Canon Quick Menu. If you have a Mac you can go into your applications, select Canon Utilities, then drag Canon Quick menu to the trash and empty trash can. On Windows you'd go to the control panel, select Programs and Features (or Uninstall Program/Add or Remove Program) and uninstall the Canon Quick Menu. Not required for all the normal functions of the printer. You can do the same thing for My Image Garden. Also not required.

Maybe you are looking for

  • App removed from sale just after it is approved

    Our quiz application (ID: 455012461) which is downloaded more than 400k was removed from sale about 3 weeks ago without any information. When we sent an email about the issue someone from Apple called us over phone and told us that our quiz contained

  • Getting Focus using TAB key in TextArea

    Hi, When I move the focus into a TextArea with a TAB. The first pressed key is not displayed. Is this a bug..? if yes are there any workarounds..? I am using JDK1.4.1. I am pasting my sample program. import java.awt.*; import java.awt.event.*; public

  • Photoshop Elements 9 in Windows to Photoshop Elements 10 macbook

    I am currently using Adobe Photoshop Elements 9 in Windows. I recently brought a macbook and installed Elements 10. I am not able to transfer the back up. How can I do this. Please advise

  • Please send reply

    I am also migrating SQL Server 7.0 Databases on NT to Oracle 8i on Sun 2.6. Is there any way of having the Migration Workbench. How to do Migration? null

  • Sol man doc status search

    in solution manager, I have different documents with status "work in progress" under different solar02 nodes, how to pull a list of those documents, any standard SAP report I can use?  or other ways?