I want to show labels having images one by one in Panel

i want to show labels having images one by one in Panel through a while loop...
I made an ImagIcon array.
It doesn't work properly.
It shows only first image while the variable is incrementing. :(
This is my code...(Plz check it....)
import java.awt.*;
import javax.swing.*;
public class test extends JFrame
ImageIcon imgIco = new ImageIcon("mylogo.jpg");
ImageIcon imgIco1 = new ImageIcon("mylogo1.jpg");
ImageIcon imgIco2 = new ImageIcon("mylogo2.jpg");
ImageIcon imgIco3 = new ImageIcon("mylogo3.gif");
ImageIcon imgIco4 = new ImageIcon("mylogo4.gif");
ImageIcon[] a = {imgIco,imgIco1,imgIco2,imgIco3,imgIco4};
JButton b1 = new JButton("Add");          
JLabel l1;
JPanel p1 = new JPanel();
public test(String title)
super(title);
int s = 0;
while(s<=4)          
     try
          Thread.sleep(100);
          System.out.println(s);
          l1 = new JLabel(a[s]);
          repaint();
     /*if(s==1)
          p1.remove(l1);     
     catch(Exception e)
     System.out.println("Error Occured!!!");
     p1.add(l1);     
System.out.println(s);
s++;                              
     setContentPane(p1);          
public static void main(String args[])     
     test t = new test("Title");
     t.setSize(900,470);
t.setVisible(true);
t.setResizable(false);

You are sleeping the thread used to perform the repaint.
Calling repaint only marks a component as needing painting, and AWT will paint it later. If you continue to loop in the mainthread then you will not see the changes.
You have to move your loop to another thread.

Similar Messages

  • I tried linking the facebook contacts to my phone but for some reason the contacts doesnt wants to show the FB images even thought it says that it was sync. What could be the issue? How can it be fixed so i could get my facebook lined up to my contacts?

    I tried linking the facebook contacts to my phone(iPhone4s) but for some reason my conatcts doesnt wants to show the FB images in my contacts even though it said facebook contacts were sync. What could be the issue? How can it be fix so I could sync my contacts with Facebook?

    Firefox will not appear in the Market for most phones with incompatible hardware. You can check if your phone is supported here:
    https://wiki.mozilla.org/Mobile/Platforms/Android
    Even on some supported devices, a bug in the Market software prevents Firefox from showing up. This may be related to the fairly recent Android Market app update. If you go to Settings/Applications/Market and choose "Uninstall" you can uninstall the update, and then search for and install Firefox from the marketplace.
    Or, if you have a supported phone, you can download the app directly by typing this address into your phone's browser: http://bit.ly/fxbeta3
    (Note: To download the app directly for an AT&T phone, you will have to search for instructions on "sideloading" the APK file, since AT&T disables the option to install from non-Market sources.)

  • Show label text in front of image always

    I have text in a label that I want to show over an image. Sometimes the text shows sometimes it is hidden by the image. Is there a way to force the text to show above the image? Thanks....

    Or do this:
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class X {
        public static void main(String[] args) throws IOException {
            BufferedImage image = ImageIO.read(new URL("http://today.java.net/jag/Image1-large.jpeg"));
            String title = "James Gosling";
            LabelIt(image, title, new Font("Lucida Sans", Font.PLAIN, 12));
            JFrame f = new JFrame(title);
            f.getContentPane().add(new JLabel(new ImageIcon(image)));
            f.pack();
            f.setLocationRelativeTo(null);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
        public static void LabelIt(BufferedImage image, String text, Font font) {
            Graphics2D g = image.createGraphics();
            Rectangle2D bounds = font.getStringBounds(text, g.getFontRenderContext());
            float x = (float)(image.getWidth() - bounds.getWidth())/2;
            float y = (float)bounds.getHeight();
            g.setColor(Color.WHITE);
            g.setFont(font);
            g.drawString(text, x, y);
            g.dispose();
    }

  • I have recently transferred data from my old Mac to my new one. The result was good, but I have 2 users now, whose data I want to merge into 1 single user, so to avoid having to switch from one user to the other to view and use certain files. How to do it

    I have recently transferred data from my old Mac to my new one. The result was good, but I have 2 users now, whose data I want to merge into 1 single user, so to avoid having to switch from one user to the other to view and use certain files. How to do it?

    Here's an easy way:
    Pick the user that you want to eliminate (making sure that the remaining user has administrator privileges) and move all of the data that you want to keep into the Shared folder. Reboot or log out and login to the user you want to keep. Copy all the data from the Shared folder into your account - placing it neatly in folders (Documents, Music, Movies, etc.).
    Once the data is moved, log into the account you want to delete just once more to make certain that you've grabbed all the data you want to keep. Log out and log back into your admin account and go to System Preferences>Users & Groups and delete the 'old' user.
    That should do it.
    Clinton

  • I want to show movable image on form like data loding symbol

    Dear All, I am working on developer2000 6i version I want to show movable image on form like data loding symbol.currently i have taken .GIF Image but it is not moving so is there any way to do the same. oracle 10g forms 6i version Faizan

    Hi Faizan,
              Even i work on D2K (Forms 6i). I have tried this below & found the result.
         Its true that you can not add animated image. But you can definitely show a data loading symbol in code.
         Add 2 different contrast colours and choose a striped pattern.
    1) Create a text item with a lengthy rectangle (width minimum of 300).
    2) Create a visual attribute for it with desired colours.
    3) Finally add the following in between your code.
    Your Code
    set_item_property('YOUR_BLOCK.TEXT_ITEM',visible,property_true);
       set_item_property('YOUR_BLOCK.TEXT_ITEM', width,2);
    Your Code
    tot_wid:= get_item_property('YOUR_BLOCK.TEXT_ITEM', width);
    Your Code
    set_item_property('BLOCK3.PROGBAR', width,100);
    Your Code
    set_item_property('BLOCK3.PROGBAR', width,300);
    Message('Data Loading is completed');
    Try this out and let me know if its working as you expected & also let me know if there is a problem.

  • Im having problems with contacts on my iPad. One of my contacts names shows up when I choose any one of 36 contacts. the email goes to the correct email address that I've chosen but the incorrect name shows up in the To: area of the email

    I'm having problems with contacts on my iPad. One of my contacts names shows up when I choose any one of 36 contacts. the email goes to the correct email address that I've chosen but the incorrect name shows up in the To: area of the email. Has anyone else experienced this...if so I hope there is a fix

    Hello there erika274,
    It sounds like no matter what contact you put into the 'To' field, a different name appears, but the email makes it to the intended recipient. I would recommend a few things here. First, close all the open apps on the device:
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Double-click the Home button.
    Swipe left or right until you have located the app you wish to close.
    Swipe the app up to close it.
    When you have done that restart the phone:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    If the issue persists, I would next backup your device to iTunes, and restore it:
    iOS: How to back up and restore your content
    http://support.apple.com/kb/HT1766
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • I have 1200 bookmarks, want to delete all of them without having to select one by one...

    hello,
    I found how to delete bookmarks, but by selecting one by one... isnt' there a way to select all of them in once ? (I have 1200).

    You can reset all bookmarks on the [[Safe mode]] start window.
    You would have to select all three main (root) folders one at a time (Toolbar, Menu, Unsorted) and select all bookmarks and folders in the right pane for each of them if you want to delete them in the Bookmarks Manager (Library).

  • Learning Filtering: Smart Collections doesn't show all filtered images

    I'm studying using Classroom In A Book so this test is small and only using the few images provided on the CIAB CD.
    It says in the book that a Smart Collection is a selection filtered according to whatever rules you specify.
    This is fine, but when I click the down arrow to the left side of the screen to see the listings under Smart Collections only some of the filtered images are shown. Images that I marked with red are shown as a Smart Collection. Images that I marked with Green (only one) does not show. A single image that I marked with five stars shows up as a Smart Collection, so it can't be that you need more than one item marked before it shows up as a Smart Collection. I made sure that I have highlighted the folder that contains the images (made it local) and that they are displayed in Library Mode and in Grid View.
    What might cause some of the images I have applied filter attributes to not to show up in Smart Collections?
    TIA,
    Ken

    dorin_nicolaescu wrote:
    Images that I marked with red are shown as a Smart Collection. Images that I marked with Green (only one) does not show. A single image that I marked with five stars shows up as a Smart Collection
    What does the book say? It says "a Smart Collection is a selection filtered according to whatever rules you specify." It means the rules you specify for you r smart collection. These are default "canned" lightroom collections. The first happens to have the rule "show labelled with red", the second — "show 5-star images". Images tha match the rules defined in a SC - are displayed in that SC.
    Double-click any smart collection to see its rules.
    To create a new smart collection with your own rules, click Library>New Smart Collection.
    The Smart Collections I have were created without me double-clicking on anything. The book just told me to try out some of the ways to mark images and to try out each way. All of a sudden, Smart Collections appeared with some of the marked images. I was just wondering why it stopped at some but did not do them all? Also, what if I don't want Smart Collections at this point? How do I turn it off from making arbitrary Smart Collections without my prompting?
    Don't get me wrong dorin_nicolaescu, I am a beginner and know nothing. You sound like you have a good grip on what Smart Collections are and how they work. What you have writtenis helpful, especially the part about "To create a new smart collection with your own rules, click Library>New Smart Collection."
    I am still in a Fog about why Smart Collections starts collections on its own.

  • How do I show multiple rollover images on a page inserted dynamically (pulled out of a sql database

    How do I show multiple rollover images on a page inserted dynamically (pulled out of a sql database table) using Dreamweaver’s Repeat Region. Example: I have different products each one associated (through their productID) with two images (one that’s showing in the page and one for the rollover effect) that are pulled from a database using Dreamweaver’s Recordset. So I want to end up with a page containing row after row of images(one for every product).When moused over each image will reveal the second (rollover) image for the same product which in turn can be a link(the image itself ) that when clicked leads to a detailed page with more information about the product the image is associated with. To show row after row with images for the different products in the database table I am using Dreamweaver’s Insert Rollover Image command and then the  Repeat Region – I have no problem to complete the steps, to insert the image and the rollover one at once and set the paths so they are pulled dynamically depending on the productID they are associated with .I have also no problem to apply the Repeat Region so not only the first image associated with the first product in the table is shown but all of them-a routine and standard procedure when using the Repeat Region to dynamically generate and display multiple rows of data. However, when I preview the page the rollover effect is lost –the images are shown but when moused over the second  image does not  show. The problem is caused when the Repeat Region is applied-once again I am allowed to apply it but the rollover stops working, a kind of interference. ANY SOLLUTION PLEASE, ANY WORK AROUND.

    I gotta tell you, using multiple images for rollover effects is going to be a big challenge in your dynamic scenario. 
    If this were my product page, I would use thumbnails with a bit of CSS opacity or filters to desaturate and make them full opacity/color on mouse over.  Nice effect with much less bandwidth. Easily done globally with CSS code.
    Two examples:
    http://alt-web.com/GALLERY/GalleryTest.php
    http://alt-web.com/TEMPLATES/CSS-Semi-liq-photo-sheet.shtml
    Nancy O.

  • How do I get my purchased movies from iTunes to show in my Library without storing all the GBs on my hard drive?  [I want to show the Cloud Purchases.]

    Hey Hey! 
    Running OSX 10.9.4 and iTunes 11.3
    I am pretty sure that this has been addressed somewhere, but I could not find it - so thanks up front!!!
    How do I get my purchased movies from iTunes to show in my iTunes Library without storing all the GBs on my hard drive?  I want to show the Cloud Purchases without having hundreds of GBs taking up my HD space. 
    Thanks!

    Deborah,
    You cannot import contacts from your Nano to your PC via iTunes.  The syncing process is only one way.  However, if you enable disk mode on your iPod, open it up in a Windows Explorer window, you should see a Contacts folder.  From there you can copy them back over to your PC. 
    Even though this article is talking about adding contacts to the PC, it should walk you through some of the steps mentioned above.
    http://support.apple.com/kb/HT2419?viewlocale=en_US
    B-rock

  • How to stop the dock from showing all hidden images when hiding then showing applications

    How to stop the dock from showing all hidden images when hiding then showing applications

    It's not really something to snap a screen shot of. I believe it would need to be a video clip. For instance, when I am working on multiple images in Photoshop, I often need many images open at the same time, but I only have one image viewable and active. The hero image is active on screen while I hide the other images in the dock by hitting the yellow - button on the images. Then I "Hide" Photoshop to do something in the Finder. When I go back to Photoshop, every image that is hidden in the dock will pop open again in the active window, not just the image I was currently working on. I want these images to stay in the dock until I need them, no matter how many times I Hide the Show Photoshop.

  • Problem in displaying images one by one in JList

    I have a problem in displaying images one by one in Jlist. I want to show 100 images as a thumbnailview in jlist but it is talking too much time to show all the images after scalling 100 images to thumbnail view and making it into ImageIcon. So, i thought that it would be better way to show one by one after scaling it into thumnailview. But my renderer is getting calling after 100 images scaled down and setting into list. I have posted my code 2 days back but there is no reply.
    http://forum.java.sun.com/thread.jspa?threadID=789943
    I donno where i am missing in this code.
    Plz suggest me some solution for it.

    Where is the scaling done? In the ListCellRenderer? Regardless of where that is being done, I assume you are caching the scaled images after you scale them, right? If not, consider adding some sort of caching.
    This should do the trick...
    Rework your ListCellRenderer to check to see if a scaled version of the image is available. If not, start a thread to do the scaling and create an ImageIcon. In the meantime, while that thread is running, have the renderer return some sort of stock icon, like a little generic image icon. When the scaling thread completes, make a call to repaint() on the JList so the cell renderer gets re-asked for the icons. This time around, the renderer should notice that a scaled version (the ImageIcon) is available. Return that. So, this method doesn't guarantee that the images will be produced in order, 1...2...3..., but it will return images as they become available, and the overall JList rendering won't wait until all 100 are ready. If you want them returned in order, just do all of the scaling in a single thread and queue up the images to be scaled, in order.
    I hoped this helps. (If it does, please throw me some Duke Dollars.)

  • HT1937 in general setting for itunes wifi sync some how i got two folder first one the one i want :apps,movie, music, and tones some how i got second one is photo only, when i plug in it's only sync on 2nd one and not first one, i tried delete ituns and d

    i had problem for my itunes wifi sync, in general setting itunes wifi sync, i got 2 folder name 1st one is one i want sync for app, movie,music and tones, somehow i got second one folder i dont want is photos only when plug into it only sync for photo the rest are gone on itunes screen and not sync, please help me how can i delete second one folder? i tried click on first one not moved and syns only sync on second one folder
    thanks. i did try delete itunes and download back but still there, i tried restore iphone to itunes a few months back but itunes screen still on new second folder not the first one
    mjphu
    [email protected]

    I own the movies and I want them to stay in my iTunes library basically forever.
    But in both cases the file name no longer shows in the movie list, so I don't know how to re-download it from the Cloud.
    iTunes prefs > Store > Show iTunes in the Cloud purchases.
    This will show all your iTunes purchases in your library with a cloud icon down arrow. Click the icon to redownload or click on Play to stream without downloading.
    Also see this , -> Download past purchases
    and techncially, you don't "own" the movie, You simply have a license to use it.
    Yet the first thing iTunes does when you hit the delete key is tell you that it will remove the movie forever from all devices and the library.
    Actually, no it does not tell you that.
    FYI: You should keep copies of all yoru iTnue spurahses as the labels/movie studios/copyright owners can pull their product at anytime and it won't be available to redownload.
    Suggestions here -> http://www.apple.com/feedback/

  • I want to show tick mark in oracle..

    Dear all,
    i want to show tick mark in my report.
    (Means i'm having table 'Table1' with two column 'col1, col2', the col2 is 'Y','N' check constraints , if i'm selecting the value of 'Y' in col2, i want to show with tick mark(instead of 'Y') in my report... )
    Is ther any oracle functions? could u help me any one pls?
    Thanks in advance
    Regards,
    RengarajR

    This depends on your reporting tool.
    Which are you using?
    Do you use jdeveloper at all? if yes which version?
    Timo

  • 1131 AP Shows as having "other" antenna in the WCS

    I just installed 5 lightweight 1131 ap's, two of them show up as having " other " as the antenna type in my WCS , the others show as having Ajax-Omni. They all have the same code and were installed at the same time. Also I can't get a het map profile from the " other " listed AP's. Can anyone help?
    Thanks
    Bill

    1. You can go to Monitor Map ---> Campus ---> Select Building ---> Select Floor ---> From the drop down menu select command, choose "Position AP" and Go .
    2. Click on the problematic AP's 1131 and select the correct Antenna type as being "AJAX-OMNI" which the image should match for AIR-LAP1131AG-A-K9.
    3. Click Save and the heat map should start to populate.
    4. From Floor Settings, select Access Points --> Protocol "802.11b/g/n" or 802.11a/n but not both. It's has to be one or the other else the heat maps will not display.
    5. From Floor Settings ---> AP Heatmaps --> Contributing APs, Select ALL the APs and OK.
    -nael

Maybe you are looking for