How can I get an ImageIcon back from a JToggleButton...

When I create a JToggleButton I have to create an ImageIcon and pass it to the constructor.
e.g. JToggleButton toggleButtonA = new JToggleButton( new ImageIcon( "images/A.gif" ) );
But when I want to get that ImageIcon back, all I can find in the documentation is getIcon(), which is much more limited in what I can do with it.
How can I get my ImageIcon back?
I've seen some people just paint the button on a new ImageIcon, but then it's not the same image, it has the button look around the original icon, not to mention since it's a toggle button you actually get the selectedIcon() instead.
Please help. Thanks.

All you basically have to do is use getIcon() and cast it to an ImageIcon... here's an example:
import java.awt.*;
import javax.swing.*;
public class ImageIconGrab {
public static void main(String[] args) {
JFrame frame = new JFrame("ImageIcon Grabber");
JToggleButton jtb = new JToggleButton(new ImageIcon("pregoico.gif"));
ImageIcon ii = (ImageIcon) jtb.getIcon();
JToggleButton jtb2 = new JToggleButton(ii);
frame.getContentPane().add(jtb, BorderLayout.NORTH);
frame.getContentPane().add(jtb2, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);

Similar Messages

  • My computer broke down and now i bought a new  Mac,  how can i get my music back from iTunes??

    my computer broke down and now i bought a new  Mac,  how can i get my music back from iTunes??

    Unless you subscribe to iTunes Match , Apple does not keep a backup of your iTunes library.  Even then it is not the library as it exists on your computer, but some version of the media, and only media files, not playlists.  Even then not all media are definitely available since anything removed from the iTunes Store since you purchased it is not available for re-download.
    FAQ: Why iTunes Match Can Not Be Used as a Backup - https://discussions.apple.com/docs/DOC-4112
    Using Match as a backup for iTunes - https://discussions.apple.com/message/17039436#17039436
    In your case it sounds like you will have to obtain non iTunes purchases from their original source or a backup you may have made at some time in the past.

  • How can I get the data back from my game

    How can I get the data back from minecraft if I deleted the app and bought with a different Apple ID

    No, they are tied to the ID that purchased them, and cannot be transferred to anyone else.

  • How can I get specific files back from my Time Machine backup?

    I wanted to make a fresh install on my MacBook Pro, in order to only have Java 8 instead of any older Java versions. So far so good. But now I want to get specific files/libraries from my external backup (USB):
    One Parallels Virtual Machine
    My old mail
    My iPhoto Library
    I don't need any settings for these, since I can easily configure them again.
    I already used the Migration Assistent to restore all apps.
    How can I get specific data back from the backup without restoring all stuff that I don't want anymore?
    I'm now working on a new account on the fresh system, called 'Admin'. My old account was called 'Hans' (or 'hans') and I'd like to create such an account again for all my tasks.
    Hans

    How can I get specific data back from the backup without restoring all stuff that I don't want anymore?
    I'm now working on a new account on the fresh system, called 'Admin'. My old account was called 'Hans' (or 'hans') and I'd like to create such an account again for all my tasks.
    You will want to add the same User account(s) which hold the data you want to restore. So you will want to add a User account of 'Hans or hans'. Check your Time Machine back up drive to see how the User account is labeled (Hans or hans). Navigate to the Users folder and see how it's labeled.
    You can then use your Time Machine back up drive and navigate to the User Home folder to copy its data over (e.g. contents from Documents, Downloads, Music, Pictures, etc.). Repeat for other Users.

  • How can I get my photos back from icloud

    How can I get my photos back from my iPhone 4 on the icloud I got my music and my contacts but for some reason I can not get my photos. 

    Hi sadie,
    When you did the backup, were the 1500 pictures all on your camera roll? Or were they on other Albums?
    iCloud is not a storage device for your photos. You should be importing them to a computer or uploading them to a cloud storage facility like DropBox or Flickr.
    Each time you do a backup of to iCloud, it creates a backup of what is on your phone at that moment in time. So, if you had some photos on one backup, but not the other, you would only be able to "recover" the photos from one of those backups. Photos in iCloud are not aggregative.
    Also, the iCloud backup of photos only includes those photos or videos in the Camera Roll. Photos in any other album are not backed up:
    http://support.apple.com/kb/PH12519?viewlocale=en_US
    If you had PhotoStream turned on, then the last month's-worth of PhotoStream, or the last 1000 PhotoStream photos would also still be viewable.
    Can you tell us where those 1500 photos were located when you did your backup?
    Sorry that you lost your photos. Take a look at DropBox in the App Store, or check out Flickr. If you aren't importing your photos on a regular basis to a computer, then these would be your best bet to protect your photos going forward.
    GB

  • How can I get my photos back from Photoshop Album 3.2

    how can I get my photos back from Adobe Photoshop Album 3.2 edition

    This is the Phooshop forum.
    You probalby need to check the Photoshop Album forums at http://forums.adobe.com/community/ps_album_starter?view=discussions
    or the FAQ about Album at http://feedback.photoshop.com/photoshop_family/topics/what_happened_to_adobe_photoshop_alb um_starter_edition

  • HT201272 how can i get my ringtones back from itones or iclould

    how can i get my ringtones back from itones or iclould i was backup by by both new phone

    Do you have copies of them in the Tones section of your computer's iTunes library or on your backup of your downloads/library so that you can sync them back to your phone? If you haven't then you could try contacting iTunes Support and see if they will grant you a redownload

  • HT4098 How can I get my money back from app store when I did not renew my app

    I didn't not renew the app that I never really use and now the apple store charge me from my card. How can I get my money back and what number I should call because I totally lost at apple store and don't know what to do. This is really frustrated that apple have this kind of customer service... could someone help?

    These are user-to-user forums, they are not monitored by Apple (there are too many forums/threads/messages for that to happen).
    If the apps aren't working as described in the store then you could the report a problem link from your purchase history : http://support.apple.com/kb/HT1933

  • How can I get my money back from an app

    How do I get my money back from an app tht my daughter accidentally bought.

    All sales are final.
    You can try contacting itunes support and asking for an exception.
    Click Contact Us at the bottom of this page

  • How can I get my photos back from icloud after an upgrade?

    So I recently upgraded my iPhone 4s to an iPhone 5s last Wednesday. I had made sure to back it up with icloud 3 times on 3 different days prior to this. I received my new phone and it was backing up perfectly. Till I realized that my 1,500 photos hadn't uploaded and my phone wasn't letting me take pictures. It had only let me download about 300. I am devastated by the loss of these pictures. I have restored my phone multiple times and it still downloads the same pictures. I have no other problems. I called Apple and they said that the icloud only backed up these 300 pictures and my other ones were lost. But yet there were no signs of my backup being incomplete. How can I get my pictures back?

    Hi sadie,
    When you did the backup, were the 1500 pictures all on your camera roll? Or were they on other Albums?
    iCloud is not a storage device for your photos. You should be importing them to a computer or uploading them to a cloud storage facility like DropBox or Flickr.
    Each time you do a backup of to iCloud, it creates a backup of what is on your phone at that moment in time. So, if you had some photos on one backup, but not the other, you would only be able to "recover" the photos from one of those backups. Photos in iCloud are not aggregative.
    Also, the iCloud backup of photos only includes those photos or videos in the Camera Roll. Photos in any other album are not backed up:
    http://support.apple.com/kb/PH12519?viewlocale=en_US
    If you had PhotoStream turned on, then the last month's-worth of PhotoStream, or the last 1000 PhotoStream photos would also still be viewable.
    Can you tell us where those 1500 photos were located when you did your backup?
    Sorry that you lost your photos. Take a look at DropBox in the App Store, or check out Flickr. If you aren't importing your photos on a regular basis to a computer, then these would be your best bet to protect your photos going forward.
    GB

  • How can I get my game back from another phone?

    I played high school story on my old phone. (iPhone 5c) well the screen cracked so I went to try to get another screen but instead they gave me a whole other new phone.(anther iPhone 5c)   I got high school story on the App Store and logged in through Facebook but then it was wanting me to sign in via Game Center. I signed in using the same Apple ID I used on my old phone but then it made me choose a 'nickname' I remembered my old one from my phone so I tried to enter that. it said that the nickname was already taken. (yes, it was...by MY OLD NICKNAME!) My question is how do I get that nickname back in order to get my progress from that game back. or is there any way at all to get my progress back? with the new nickname it made me enter, I had to start all over on the game.

    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Otherwise we need more information to help you.

  • Microsoft outlook has blocked out the emails I had on Firefox and forced me to change my email address. How can I get my emails back from my previous email add

    My previous email was [email protected] For some reason Microsoft outlook have blocked it out and forced me to create another email address. There is a lot of information in the previous emails that I need, how can I get back to them. Microsoft have told me that I cannot reestablish the previous email address. I didn't know they could be so dictatorial.

    * If you are using the '''Microsoft Windows Live''' program;<br>
    Check the account information. On the far left top, under the icon,<br>
    press the box with the arrow. and select '''Options,''' then '''Email Accounts.'''<br>
    Select the e-mail account with one click. On the far right, press '''Properties.'''<br>
    '''General;''' check the information is correct.<br>
    '''Server;''' My Mail Server. Mine is;<br>
    http://mail.services.live.com/DeltaSync_v2.0.0/sync.aspx<br>
    '''Login Name''' and '''Password;''' re-enter the information<br>
    <br>
    * Using a web browser, go to '''Live.com''' and sign in.<br>
    At the top right, look for your name. Just to its left, click the tool icon.<br>
    Select '''Options.''' Under '''Preventing junk email,''' right click on '''Filters and reporting''' and select '''Open New.''' Look thru the settings. If there is something you need help on, just ask. Once you are done, close that page.
    Under '''Preventing junk email,''' right click on '''Safe and blocked senders.'''
    Look thru and check each listing

  • I bought a book for £10.99. When downloaded, it showed it had only 46 pages and had loads of spelling mistakes. How can I get my money back from iBooks?

    I downloaded a book from iBooks and it only had 46 pages and had loads of spelling errors. How can I claim my money back? Before the download, it did not show how many pages the book contained like it normally does.

    use the Report a Problem link on your receipt or in the purchases area of you iTunes account.

  • HT4859 I have lost my iphone how can I get my calendar back from icloud

    I have lost my iphone 4 how can i get into my calender which has been backed up on icloud with out a phone?

    Only if you had turned on find my iPhone on the iPhone itself.
    If you did not, then you can do nothing, but report it to the police and change your passwords.

  • How can I get my funds back from my itunes account?

    I purchased a season pass to a series of shows and iTunes has yet to put any more of the episodes on iTunes.  It's now going on a year.  How does one get there money back for the episodes that have yet to be add to iTunes.  What email address do I use to contact the right people to rectify this?  Please anyone, HELP!!!!

    Click Support at the top of this page, then click the link under Contact Us

Maybe you are looking for

  • Error in Recever Mail Adapter (Communication Channel)

    Hello Experts, I am getting below error in recever Adapter Communication Channel. I have given SMTP, XIALL,PLAIN parameters, i have given proper: SMTP://compnay.com & correct user id and password, i browse throug all most all related links. Exception

  • Default XI parameters in 7.1, soap sender.

    Hi, I have a quick question about Default XI Parameters in Soap sender adapter in PI 7.1. Why are they not present in PI 7.1( sender interface and sender NS )? which are mandatory parameters in 7.0. I was guessing that , this ways we can create a gen

  • Lightroom says I need ACR 6.1 when editting in CS5 but I already have it

    I have Lightroom 3, Photoshop CS5 and Windows 7 Home Premium. All are 64 bit. I have upgraded to ACR 6.1 but when I try to edit a raw image in CS5 from Lightroom I get the 'render using LR vs open anyway' dialogue saying that I may need ACR 6.1. As I

  • No "ANGLE" Option for Linear Gradients in Motion 4!

    Referring to the help section for Motion 4, there should be an "angle" tool for linear gradients, but there's not! I have a linear gradient that runs top to bottom and I want it to run left to right. Is there any other way to do this without having t

  • Web searches are being redirected to other sites

    Web searches are being redirected to alternative websites. Deleted MacKeeper but the redirects are still occuring