Setting IconImage on a few hundred JFrames at once

Hi,
I have an application with a few hundred classes and also a large amount of JFrames spread over those classes.
Now I have to have a custom IconImage displayed in the upper left corner of the JFrames.
As of the Swing Tutorial I know that with
//Ask for window decorations provided by the look and feel.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create the frame.
JFrame frame = new JFrame("A window");
//Set the frame icon to an image loaded from a file.
frame.setIconImage(new ImageIcon(imgURL).getImage());I can set the IconImage of one particular JFrame, but that would mean that I would have to do that a for all of those hundred JFrames in the app.
Is there a simpler way, to set the custom IconImage only once?
Thx!

BoBear2681 wrote:
rh---gnt wrote:
woefully inefficient ? I agree it's inneficient, but ImageIcon itself does not really cost much. It's not a component after all. Maybe calling ImageIcon "inefficient" is a slight exaggeration, but wasteful is indeed a good description, if all you want is an Image. Like Darryl said, if you want an Image, why not just use ImageIO.read() instead of creating an unnecessary object?Yes I was just pointing out the exaggeration. ImageIO.read() is fine.
And I was also pointing out some other performance related tips. Having an image in the format ready to render to screen is where you will see much greater performance improvements.
>
One other thing to be aware of is that ImageIcon uses the toolkit to load the image, this process is asynchronous.Toolkit can load images asynchronously, yes, but ImageIcon waits for the Image to be loaded. That way it can publish its width and height properly. See the ImageIcon.loadImage() method.Yep, good point.
neblaz:
Maybe your 100 screens is not the best design.
However a simple solution to your problem is to subclass JFrame as you suggest.

Similar Messages

  • I have a few hundred duplicates in my iPhoto library, but the file sizes are different.  So one is 1.3mb and one is 567kb.  I want to delete the smaller ones, but short of comparing each duplicate, is there a way to do this?

    I have a few hundred duplicates in my iPhoto library, but the file sizes are different.  So one is 1.3mb and one is 567kb.  I want to delete the smaller ones, but short of comparing each duplicate, is there a way to do this?  I've been looking at Duplicate Annhilator but I don't think it can do it.
    Thanks!

    I just ran a test with iPhoto Library Manager, Duplicate Annihilator, iPhoto Duplicate Cleaner, Duplifinder and Photodedupo.  I imported a folder of 5 photos into a test library 3 times, allowing iPhoto to import duplicates.  I then ran the 5 photos thru resizer to reduce their jpeg compression but all other aspects of the file the same.
    None of the duplicate removal apps found set that was reduced in the file resizer. That's probably due to the fact that the file creation date was being used as a criteria and the resized photo would have a different file creation date even though the Image Capture date was the same.
    They all found the 3 regular duplicates and some of them would mark two and leave the 3rd unmarked.  iPhoto Duplicate Cleaner can sort the found duplicates by file size but if the file was edited to get the reduced file size it might not be found as it would have a different file creation/modification date. 
    iPhoto Library Manage was able to find all duplicates and mark them as such if the file names were the same the the filename option was selected.  Otherwise it also missed the modified, resized version.  It allowed one to select the one photo to save before going to work on the library.
    So if a photo has been reduced in image quality or pixel size it will not be considered a duplicate.
    OT

  • How can I set a "Metal" LookAndFeel to a JFrame

    How can I set a "Metal" LookAndFeel to a JFrame?
    I�m using the JDK 5. In my pc, has that theme. I�m using Win2k

    try{
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
            } catch (Exception e) {
                System.out.println("Error changing Look and Feel");
            }

  • I am wondering what is the best way to merge a very large iphoto library (from my MBP) to my new iMac (which has a few hundred photos on it now), and then upgrade to Aperture?

    I have about 50GB of photos on my old MBP iphoto library.
    I have a new iMac with a few hundred photos that I've uploaded since I bought it last December.
    The iMac is where I want to keep everything stored as my main photo library, and manage it with a new Aperture installation. 
    Before I go and do this, and possibly muck it all up,
    I would like to figure out the proper steps.
    I am not too familiar with how to transfer files in the first place, so any help for a beginner would be much appreciated.
    Starting from how to safely move the files from the MBP to the iMac, if anyone could walk me through this process.
    I've been searching around but I have a specific goal (with getting everything into Aperture) so I don't want to get crossed up. 
    Thanks for your help!!

    I have about 50GB of photos on my old MBP iphoto library.
    To be able to merge your libraries, your Aperture version and iPhoto version must match. For basic reading see: Aperture 3.3: Using a unified photo library with iPhoto and Aperture
    and Aperture 3.3: How to use Aperture to merge iPhoto libraries
    Assuming you are running the latest Aperture and iPhoto versions:
    Before merging libraries ensure that your iPhoto Library has no issues. While still on your old mac run the "library first aid tools" on your iPhoto Library. Hold down the key combination ⌥⌘ and double click your iPhoto Library, then select "Repair database".
    Make sure you have a backup of your current Aperture Library and iPhoto library.
    Do both macs have a FireWire port? Then you could connect your macs in Target Disk Mode:
    See OS X Lion: Transfer files between two computers using target disk mode
    This way your new mac could see your old mac as an external disk and you could copy directly between the macs.
    Otherwise copy your iPhoto library by drag-and-drop to an external disk (on your old mac) and connect that disk to your new mac. Check, if the external drive is formatted for mac (MacOS X Extended (Journaled)). Otherwise reformat it, before you copy the iPhoto library to that drive.
    When your iPhoto Library has been moved to your new Mac launch Aperture and use the command "File > Import > Library" from the main menu bar. If there are duplicates in the Aperture library (if you imported earlier from iPhoto) you may be prompted if you want to "Add" or "Merge". If you have lots of duplicates, pick "Merge", otherwise "Add".
    Post back, if you need more detailed instructions.
    Good Luck.
    Léonie

  • How Do You Set the Maximum Size of a JFrame?

    Can someone show me a quick example? The JFrame can be empty, I just want to know how to set it's maximum size. I tried using setMaximumSize() and it doesn't work for some reason but setMinimumSize() works fine.
    I tried it using a BoxLayout and even using null as a layout manager and can't get it to work. I heard that the other layout managers don't allow you to set the maximum size of a JFrame so that is why I tried it with the layouts that I did.
    I tried the following code (imported the necessary classes), but it does not work...
    public class MyFrame extends JFrame
        public MyFrame()
            super("TestFrame");
            setLayout( new BoxLayout(getContentPane(), BoxLayout.X_AXIS)  );       
            setMaximumSize( new Dimension(400,200));
            setSize(300,150);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setVisible( true );                
    }// end class

    Reposted from
    {color:#0000ff}http://forum.java.sun.com/thread.jspa?threadID=5236259{color}
    @OP:
    When you repost a topic, please always provide a link to the previous post so people can check what suggestions were already offered (and didn't solve the problem).
    Better still, give a short summary of the advice you have already tried.
    I suggested setBackground(...) so you can see whether your MyFrame is actually occupying the entire real estate of the window. Looks as if trying it out (which I would have done for you if I'd been at home, where my JDK is) would have been too much effort for you.
    I'm pretty much a novice in Swing, but I can tell you this: setLayout controls the layout of components added to the JFrame, not the layout of the frame with respect to its parent container.
    Luck, Darryl

  • How to set the cell size in a JFrame

    Hello. Is there any way of setting the cell size in a JFrame. The reason why I want to set the cell size is that I want to be sure of their location that when I am placing components on the JFrame. So is there any way of setting the cell size beforehand. Also for the following code.
    JFrame frame = new JFrame("Window");
    frame.setSize(100,100);is the size 100 by 100 is he size of the cell?

    smithbrian wrote:
    When I am placing a component on the grid I want to be sure the component is exactly where I place it. In order to do that I would need to know what is the size of the gird and how to change the size of the gird in the JFrame.What grid?? You're assuming that we know much more about your program than we actually do. We actually know zip. Please read this help site which will help you to avoid similar errors in posting questions here. It has helped me in the past: [smart questions|http://www.catb.org/~esr/faqs/smart-questions.html]

  • My question is to anyone that can help..I downloaded 2-300 photos on my iPad and want to reload a few hundred more. The last time I did this I lost the first batch of photos I loaded a week before. How do I just add without losing what is already on iPad?

    My question is to anyone that can help..I downloaded 2-300 photos on my iPad and want to reload a few hundred more. The last time I did this I lost the first batch of photos I loaded a week before. How do I just add without losing what is already on iPad?

    You need to add the new photos to the ones that are currently on the iPad and (re-)sync them all - only the most recent photo sync remains on the iPad, not including photos in a subsequent sync is how you delete them from the iPad (as you've found out).
    You can use third-party apps such as Simple Transfer which can copy photos to the Photos app via your wifi network, but they will only go into the Saved Photos/Camera Roll album, and not into a 'proper' album.

  • I synced my iphone to a new pc and it updated and a few hundred photos seem to be lost. Is there any way to get them back?

    Hi i synced an iphone to a new pc and it updated and restored the iphone to its original settings. some photos were still there after but a few hundred are now missing. Is there any way to get them back?

    restore from a backup dated prior to when you synced to the new computer.
    ideally... were you backing up to icloud?  if so, erase all content and settings and restore from a backup in icloud dated prior to when you synced.  Camera roll backs up I believe and those photos will show back up

  • NTPD sometimes sets my clock a few seconds off

    Hi, whenever I look through my system logs on Console I have noticed a few times that NTPD seems to sometimes set my clock a few seconds off. I have a couple snapshots of the log files if it helps. I also ran an extended apple hardware test and told me that my mac had passed the test. What do you guys think and is there something wrong with my mac? I have a 15-inch macbook pro running Mac OS X  10.7.5

    Close all apps in the multitasking bar. (press the home button 2x, hold an app and tap the minus symbol)
    Restart/Reset/Restore your iPod.

  • How do I delete the few hundred records that I have double or triple of

    how do I delete the few hundred records that I have double or triple of

    is there a way to delete thse extra files

  • Getting error SBL-ODU-01006 after few hundred requests.

    I'm trying to get all the Company records and the users associated to each company. I'm quering the company first and for each company calling the user service to ge the user information.
    I'm getting the following error after few hundred requests (this is happening randomly)
    <fault>
    <bpelFault>
    <faultType>0</faultType>
    <remoteFault>
    <part name="summary">
    <summary>Server</summary>
    </part>
    <part name="detail">
    <detail><ErrorCode>SBL-ODU-01006</ErrorCode> </detail>
    </part>
    <part name="code">
    <code>soap:Server</code>
    </part>
    </remoteFault>
    </bpelFault>
    </fault>

    Hi,
    Few things you might want to check.
    1. Are you excedding any of the service allotments for web services?
    2. Are you using more than 5 requests concurrently? This might reach maximum web service concurrent request limit.
    3. Requests being sent through proxies require re-authentication after every certain period of continuous requests.
    Regards,
    Sumeet K.

  • How do I set up devices to access my mobile hotspot once its on?

    How do I set up devices to access my mobile hotspot once its on?

        Great question Bnrybtch019. It's important to have access to all your features, I can help you with that. Since you didn't specific a phone model, these are the steps for a popular Android-Operating Phone http://vz.to/1yrBX0e .
    AdaS_VZW
    Follow us on Twitter at @VZWSupport 

  • How can I set my time capsule to back-up only once a day?

    How can I set my time capsule to only back-up once a day.  It appears to be backing up several times a day.  Not sure there is a set schedule for the back-ups and they take a great deal of time; over an hour each.

    tdenny2 wrote:
    Not sure there is a set schedule for the back-ups and they take a great deal of time; over an hour each.
    Then something is wrong.  Changing the schedule will only deal with the symptom (and give up one of the better features of Time Machine's usually quick and unobtrusive hourly backups).
    See if the size of the backups makes sense, considering what you've changed since the previous one.  If it seems much too large, that may be the problem.  See #D4 in Time Machine - Troubleshooting for some common culprits and ways to see just what's going on.
    If the sizes seem reasonable, see #D2 in the same link for things that can cause extra-slow backups.

  • I am setting up up my new ipad 2. On the email icon I set up my work address thru Microsoft Exchange once I did that it did does noy give me an opportunity to see the other mail venues such as AOL or Gmail it automatically opens to my work address.

    I am setting up my new ipad 2. On the mail icon I set up my work address thru Microsoft Exchange once I did that the mail icon automatically goes to my work address and it does not give me the choice of the mail icon again how do I get that back?

    If you mean when you are reading email in the mail app.....
    Tap on the word "Mailboxes" in the upper left corner of the mail app - next to the name of your Exchange email account. That will take you back to the list of all of the Mailboxes on your iPad.
    The mail app will always go back to where you were when you left the app. So if you were reading mail in your Exchange account and then you leave the app (without quitting the app) it will take you back to that email that you were reading when you come back.

  • Hi, I hope someone can help.... When I open a new user account, which I want to set parental control on, the screen keeps freezing once the account is open. The wee rainbow circle appears and I can't do anything. Does anyone know how to fix this? Thanks

    Hi, I hope someone can help.... When I open a new user account, which I want to set parental control on, the screen keeps freezing once the account is open. The wee rainbow circle appears and I can't do anything. Does anyone know how to fix this? Thanks

    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at the top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair. Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    Report any errors it found for Disk Repair, don't need the ones for Permissions Repair.
    Try it again & see if anything changed, but have Activity Monitor open & Show All Processes & sorted on CPU%, also have Console open if we can... maybe not when switching, but we'll see.
    Does this happen if you just try to create a new admin user???

Maybe you are looking for

  • Oracle BPM Composer Authentication Failing.

    Hi, I have installed the Oracle BPM in our server,but facing some problem while login.. 1)Installed Software. Database Oracle 119 version (11.1.0.7.0) ---64bit Release1 and (11.2.0.1.0) ---64bit Release2 Weblogic Server wls1033_oepe111150_win32 Repos

  • Problem with social apps.

    yes mee too . i cant open my social applications , and i download facebook but it closing down. i try to reset all. but nothing happens. Solved! Go to Solution.

  • I want to change my iPod mini's name!

    See subject. Have had a rethink, and now want to change the name of my iPod mini. But how? Nothing when I selected iPod Options... after right-clicking Hynzy's iPod mini (the name of my iPod mini) in iTunes 4.9 for Windows. Help me please!

  • OPEN DATASET in ECC6.0

    Hi Guys, We are upgrading from 4.6c to ECC 6.0 and a lot of our programs are giving unicode compliance error on the OPEN DATASET statement. Even though we are moving to a unicode system, the systems we talk to are not unicode compliant yet so we dono

  • Web Template Publishing in the Portal

    Hi All, I have created web template in Web Application Designer. I can execute it from WAD to the portal. If I need to open it directly from Portal, How will I be able to open it? How can I save a web template in the portal. I tried to braodcast it f