Adding images to a ListBox in Applet

Hi,
I wanted to add images to an Listbox as that of an Yahoo IM or AOL (IM) has. Do any one have any idea? Here is my code for Java, Please tell me where should I have to correct my code so that I can achieve such a thing. or if you do have time, please help me by giving that code..
Thanks in advance.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class AddImage extends Applet
     Image im,im1,im2 =null;
     Panel p;
     List l;
     Choice choice;
     Button b,b1,b2;
     public void init()
          l = new List();
          p = new Panel();
          choice = new Choice();
          im = getImage(getCodeBase(),"yahoosad.jpg");
          im1 = getImage(getCodeBase(),"yahoobye.jpg");
          im2 = getImage(getCodeBase(),"yahoodevil.jpg");
          MediaTracker mt = new MediaTracker(this);
          mt.addImage(im,0);
          mt.addImage(im,1);
          mt.addImage(im,2);
          try
               mt.waitForID(0);
          catch(Exception e)
               e.printStackTrace();
     public void paint(Graphics g)
          if(im != null)
               g.drawImage(im,0,0,this);
               g.drawImage(im1,20,20,this);
               g.drawImage(im2,40,40,this);
Regards
Uma

here is a snippet of a program that I used to add a .gif image to my applet screen. Hope this helps
public void paint(Graphics g){
     Toolkit kit = Toolkit.getDefaultToolkit();
     Image imageA = kit.getImage("d:\\\\javaproj\\javalab\\abbott.gif");
     g.drawImage(imageA, 555, 5, 50, 50, this);
[email protected]

Similar Messages

  • Images in Multicolumn Listbox doesn't work as expected

    In the attached example, the symbols are getting displayed in the correct order but missing the symbol for the first row. I can manually select the symbol but by default only the 2nd symbol from the provided array list appear.
    Any idea what's the issue?
    How to display correct symbol?
    Thanks in advance.
    Cross-post from LAVA: http://lavag.org/topic/15788-images-in-multicolumn-listbox-doesnt-work-as-expected/page__pid__95584#...
    Solved!
    Go to Solution.
    Attachments:
    Images & Multicolumn ListBox.vi ‏10 KB

    Hello, Vidula
    It seems that index 0 is reserved for the empty symbol, no matter what custom symbol you provided. Adding one image in front before setting symbols array and incrementing ItemSyms indexes solves this problem. However, I can't find any information about this in documentation, which would be nice
    Attachments:
    Images & Multicolumn ListBox.vi ‏12 KB

  • Error while adding Image: ORA-00001: unique constraint

    Dear all,
    I have an error while adding images to MDM I can´t explain. I want to add 7231 images. About 6983 run fine. The rest throws this error.
    Error: Service 'SRM_MDM_CATALOG', Schema 'SRMMDMCATALOG2_m000', ERROR CODE=1 ||| ORA-00001: unique constraint (SRMMDMCATALOG2_M000.IDATA_6_DATAID) violated
    Last CMD: INSERT INTO A2i_Data_6 (PermanentId, DataId, DataGroupId, Description_L3, CodeName, Name_L3) VALUES (:1, :2, :3, :4, :5, :6)
    Name=PermanentId; Type=9; Value=1641157; ArraySize=0; NullInd=0;
    Name=DataId; Type=5; Value=426458; ArraySize=0; NullInd=0;
    Name=DataGroupId; Type=4; Value=9; ArraySize=0; NullInd=0;
    Name=Description_L3; Type=2; Value=; ArraySize=0; NullInd=0;
    Name=CodeName; Type=2; Value=207603_Img8078_gif; ArraySize=0; NullInd=0;
    Name=Name_L3; Type=2; Value=207603_Img8078.gif; ArraySize=0; NullInd=0;
    Error: Service 'SRM_MDM_CATALOG', Schema 'SRMMDMCATALOG2_m000', ERROR CODE=1 ||| ORA-00001: unique constraint (SRMMDMCATALOG2_M000.IDATA_6_DATAID) violated
    Last CMD: INSERT INTO A2i_Data_6 (PermanentId, DataId, DataGroupId, Description_L3, CodeName, Name_L3) VALUES (:1, :2, :3, :4, :5, :6)
    Name=PermanentId; Type=9; Value=1641157; ArraySize=0; NullInd=0;
    Name=DataId; Type=5; Value=426458; ArraySize=0; NullInd=0;
    Name=DataGroupId; Type=4; Value=9; ArraySize=0; NullInd=0;
    Name=Description_L3; Type=2; Value=; ArraySize=0; NullInd=0;
    Name=CodeName; Type=2; Value=207603_Img8085_gif; ArraySize=0; NullInd=0;
    Name=Name_L3; Type=2; Value=207603_Img8085.gif; ArraySize=0; NullInd=0;
    I checked all data. There is no such dataset in the database. Can anybody give me a hint how to avoid this error.
    One thing I wonder: The PermanentId is allways the same but I can´t do anything here.
    BR
    Roman
    Edited by: Roman Becker on Jan 13, 2009 12:59 AM

    Hi Ritam,
    For such issues, can you please create a new thread or directly email the author rather than dragging back up a very old thread, it is unlikely that the resolution would be the same as the database/application/etc releases would most probably be very different.
    For now I will close this thread as unanswered.
    SAP SRM Moderators.

  • Image does not appear in applet.

    I am reading the book, Teach Yourself Java in 21 Days.
    There is an example in Ch.11 that shows how to load an image into the applet.
    I have tried to use the code provided as is along with an image as defined in the code. I have also uploaded the html, class and image to a folder on the web. Unfortunately, the image does not appear in the applet. The image does have an image that I created using ms paint.
    Here is the code I am currently using from the book:
    import java.awt.Graphics;
    import java.awt.Image;
    public class LadyBug2 extends java.applet.Applet {
         Image bugimg;
         public void init() {
             bugimg = getImage(getCodeBase(),
                 "ladybug.gif");
         public void paint(Graphics g) {
             int iwidth = bugimg.getWidth(this);
             int iheight = bugimg.getHeight(this);
             int xpos = 10;
             // 25 %
            g.drawImage(bugimg, xpos, 10,
                iwidth / 4, iheight / 4, this);
             // 50 %
             xpos += (iwidth / 4) + 10;
             g.drawImage(bugimg, xpos , 10,
                  iwidth / 2, iheight / 2, this);
             // 100%
             xpos += (iwidth / 2) + 10;
             g.drawImage(bugimg, xpos, 10, this);
             // 150% x, 25% y
             g.drawImage(bugimg, 10, iheight + 30,
                 (int)(iwidth * 1.5), iheight / 4, this);
    }I tried placing the image in an images folder and I also tried changing the code to getImage(getDocumentBase(), "ladybug.gif")
    as well as tried getImage(getCodeBase(), "ladybug.gif") in order to try and grab the image from the same directory as the class file and the html file.
    The image file's name is: ladybug.gif
    The code in the html file:
    <HTML>
    <HEAD>
    <TITLE>Lady Bug</TITLE>
    </HEAD>
    <BODY>
    <P>
    <APPLET CODE="LadyBug2.class" WIDTH=1024 HEIGHT=500>
    </APPLET>
    </BODY>
    </HTML>
    I have gotten previous applet examples from the book to work. One of them did have an error in the author's code which I fortunately was able to overcome. This time, I am afraid, the error eludes me.
    Thanks in advance.
    I do see that there is no start/stop/run in this version, but I believe this should still work because of the init. I am guessing that maybe the problem lies somewhere in there.
    Message was edited by:
    gnikollaj

    According to the javadoc:
    getImage
    public Image getImage(URL url,
    String name)Returns an Image object that can then be painted on the screen. The url argument must specify an absolute URL. The name argument is a specifier that is relative to the url argument.
    This method always returns immediately, whether or not the image exists. When this applet attempts to draw the image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally paint on the screen.
    Parameters:
    url - an absolute URL giving the base location of the image.
    name - the location of the image, relative to the url argument.
    Returns:
    the image at the specified URL.
    I am confused as to how to use the name after the url.
    Should it read something like:
    bugimg = getImage("http://g.jtrusty.com/JavaApplet/", "LadyBug.gif");
    EDIT: I still get the same error, cannot find symbol at getImage.
    Message was edited by:
    gnikollaj

  • Apple have a big flaw adding images to Apple TV coding error.

    Hi all, it seems Apple have a big flaw in there new version of itunes 8.2.0.23.
    So heres the problem if you have a Apple Tv system. Adding images is great however the softwares flaw is when you have a lot of images. i have over 3000, and tick boxes apear half way in the list, for know reason.
    i have add a link to show you guys and girls a screen shot...
    can anyone from apple sort this out?
    it really bugging me. as it happens of vista, xp, windows 7, and osx.
    Cheers
    Adam
    null

    apple don't monitor the forums for bug reports... this is a user-to-user support forum.
    you should report it via the official method - http://www.apple.com/feedback/appletv.html

  • Adding Images to the List component

    Adding Images to the List component while using the FLV
    PLayback
    All, ( i can send you my source files if it would help)
    I'm using the FLV Playback component and loading videos into
    it from an external xml file. I also have a list component tied to
    the FLV playback that when you click on one of the elements in the
    list, it plays that movie.
    QUESTION:
    My question is how do I add an image to the list component?
    Below is the xml file and the actionscript. I've added the image
    attribute to the XML file as img="time_square.jpg" and added the
    element of the array when calling/creating the list. Did I do this
    right?
    Any direction would be very much appreciated.

    Adding Images to the List component while using the FLV
    PLayback
    All, ( i can send you my source files if it would help)
    I'm using the FLV Playback component and loading videos into
    it from an external xml file. I also have a list component tied to
    the FLV playback that when you click on one of the elements in the
    list, it plays that movie.
    QUESTION:
    My question is how do I add an image to the list component?
    Below is the xml file and the actionscript. I've added the image
    attribute to the XML file as img="time_square.jpg" and added the
    element of the array when calling/creating the list. Did I do this
    right?
    Any direction would be very much appreciated.

  • Image does not display in Applet

    Hi people,
    I'm trying to display an image (gif image) in an applet,
    however, it does not show up when the applet is run.
    Here is my code:
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.Image;
    // An applet that loads an image and
    // displays it.
    public class DrawImage extends Applet
    Image image; //an 'Image' object
    //initialise applet
    public void init()
    //Load Image into object 'image'
    //URL url , String file
    image = getImage(getCodeBase(), "gifpic.gif");
    //applet's paint function
    public void paint(Graphics g)
    if(image != null)
    { //if image is found then drawImage()
    g.drawImage(image, 0, 0, this);
    else
    {     //if image is not found, then display message
    System.out.println("image not found");
    -----------------------------------------------------------------------

    Applets cannot access the system resources. To come out of the sand box of the applet you need to create policy files and certificate for the applet.
    Please refer this site for further details.
    http://java.sun.com/developer/technicalArticles/Security/Signed/
    Regards,
    EclipseOrg

  • Adding images and buttons without a frame appearing

    I would like to add images to some of my pages without having them appear in a frame. I would like to place some transparent gifs on the page to use as buttons for hyperlinks. I would also like to have some photos (with transparent backgrounds that appear on the page and are not surrounded by a picture frame. Any Suggestions

    iWeb seems to default to stroking newly-added images and shapes. Pages (iWeb's close relation) includes a way to change the default appearance, but I can't find anything similar in iWeb. You can, of course, remove the stroke using the Graphic Inspector (just set Stroke to None). Transparency in gifs and photo images is supported. Just drag into iWeb or use Insert > Choose... Again, remove the stroke if this appears.

  • Background layer seizes added images.

    I am trying to create a photo collage by scratch (not using "Collage"). First I create a new blank page for the background and save it. It is shown as "locked" with a padlock. Then I open an image file (.jpg) to add to the background layer, and I get a message that I need to unlock the background layer so I click to unlock it. However the added image locks onto the background layer and doesn't make a new layer. If I open another image file it locks on top of the others.

    The Layers panel only shows the layer(s) belonging to the currently active file. You need to arrange your image windows so that you can see your composite image as well as the source. With the source image active the Layers panel will show the source - click and drag that layer to the composite.
    So in the following, the violet image is the active image and I drag its layer to the white image I've created for my collage. In the composite image with the new layer selected I can position it where I want. Select each of the other images in turn and do the same. Refer to my previous note, you can also do this with Copy & Paste.
    When finished, your composite image and its Layers panel will look like this:
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • Adding Image to Search Results

    Hi
    I am dire need of adding images to search results, particularly the thumb of the resulting product(s). The tags TAG_NAME and TAG_DESCRIPTION work, but TAG_SMALLIMAGE doesn't. Any help would be much appreciated.
    Thanks, Teejay

    The CSS in http://dandeliongiftshop.businesscatalyst.com/StyleSheets/ModuleStyleSheets.css is causing that overlap.
    Search for the below style rule in the above CSS file and make suggested modifications:
    .cataloguetitle {
        color: #732772;    font-family: Arial,Helvetica,sans-serif;
        font-size: 14px;
        font-style: normal;
        font-weight: normal;
        position: fixed;          --remove this
        display: block;          --add this
        text-align: center;     --remove this
        text-align: left;          --add this
    Should look better.

  • Adding Image problems

    Having some problems adding images.
    I was able to add the Ubuntu server image mentioned in the install guide and it is working 
    It appears on the nodes palette and I can create a topology with it and boot it.
    I was also able to add CSR image csr1000v-universalk9.03.13.00a.S.154-3.S0a-ext.qcow2 to the server.  
    However the CSR icon isn't available on the node palette.  How do I fix this?
    How to add other vmdk or ovf style images?  
    I have a network emulator that runs as a VM and comes as a vmdk.   I tried installing it and I get the following message ...  -Cannot create image "server-DummyCloud": Failed to convert image to QCOW2: Command '['qemu-img', 'convert', '-O', 'qcow2', '/tmp/tmpnfp_m_', '/tmp/tmpWk3al7']' returned non-zero exit status 1
    Where can I find compatible NXos images?  

    No change.
    Still get the message ..
    Cannot create image "server-DummyCloud": Failed to convert image to QCOW2: Command '['qemu-img', 'convert', '-O', 'qcow2', '/home/virl/dc.vmdk', '/tmp/tmpmgCkzK']' returned non-zero exit status 1
    I"ll open a tac case.

  • Adding images to a slide show

    I'm sure this has been asked a bazillion times here but I'm
    so new to Flash (we're talking a couple of days) that I wouldn't
    know what to search on much less what question(s) to ask. That
    having been said I'm tasked with adding images to an existing Flash
    site that has 4 slide shows (it's for a photographer). I have all
    of the .fla files and I can successfully change an image but when
    it plays it's taller than the other existing images (even though
    they are the same height in pixels) and I'm sure fixing that is
    just a couple of clicks.
    He said with false self-confidence...
    I have other, more specific, questions but it's better to ask
    them in
    this
    image to be more clear about what I'm referring to (without
    knowing the correct terminology).
    I know Photoshop, ImageReady, Illustrator and GoLive (so I'm
    no knucklehead) but Flash is a whole new ball game so I apologize
    for my ignorance. Once I get up to speed with Flash I won't be
    asking dumb stuff like this.
    As a sidebar question what's the best way to get up to speed
    with Flash? Is Lynda.com any good?
    TIA

      I had to restart and opened the file. It asked me if I wanted to try to recover the operations in process before. I said yes. Then it gave me this error which was similar to one of the first two errors I got but did not write down.
    [SQLC/interOpen] SQLError: ‘Error #3125: Unable to open the database file.’, details: ‘Connection closed.’,operation: ‘open’, detailID:’1001’

  • Adding images files to DVD-ROM

    By adding image files to the dvd-rom when burning my slideshow and movie. Can the photos be put on a desktop for printing after burn is done?

    There's a nice option to add whatever files you choose to the DVD-ROM area using the command to Edit DVD-ROM. Here are instructions:
    http://docs.info.apple.com/article.html?path=iDVD/7.0/en/6693.html
    and a related thread:
    http://discussions.apple.com/thread.jspa?threadID=2136021
    John

  • Adding image to JDialog in Applet

    Well.. I've decided to make my Applet load via a JDialog. Which I know is possible :). And to a start I'll make a very simple Applet in the JDialog, including a background picture, which I just can't add! So to make a long story short, I want an image in my JDialog, but my code gives me a nullPointerException during the Runtime.. Here's the exact Runtime error:
    Exception in thread "main" java.lang.NullPointerException
            at applet.<init>(applet.java:16)
            at applet.main(applet.java:100)And here's my exact applet.java file:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        private ImagePanel panel;   
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String name)
            try
                buffered = ImageIO.read(new File(name));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if (buffered == null)
                g.drawString("No Image", 10, 40);
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
         MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }And I don't see any errors, but still.. Runtime error.. -.-' So a little bit of help would really be appretaiced!

    Okay I guess I spoke to soon.. :O Now I have no Runtime error but my JDialog is completly empty.. And my BlackTheme stopped working.. Not It's a blue theme instead..
    Here take a look at my applet.java:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        ImagePanel panel = new ImagePanel("background.gif");  
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String s)
            try
                buffered = ImageIO.read(new File(s));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if(buffered == null)
                System.out.println("No image to display.");
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
            MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }

  • Adding images in applet

    Hello,
    in my applet, i used 5 no of JButtons using Icon with some ".gif" file.At first ,they run well in appletviewer,But in IE,i got a security exception.After that using policy tool,i created a policy file.Then it works well in IE.But images are not displayed in button.What can i do?.This is very urgent.JButton b1=new JButton("new ImageIcon("2g.gif")");
    Kindly tell your consent.
    Inba Samuel.

    It probably can't find the files for the images. You shouldn't need to resort to changing the policy file just to load an image.
    Note that you can't access the local filesystem from an Applet (without signing it or changing the policy file). You don't need to access the local filesystem directly to load an image, though:
    URL url = new URL(getDocumentBase(), "image-1.gif");
    JButton button1 = new JButton(new ImageIcon(url));This will load the images from the same directory as the HTML page displaying the Applet.
    Hope this helps.

Maybe you are looking for

  • Forms 10g Installation issue on windows 7 Professional service pack 1

    hi I am trying to install oracle forms 10g  64 bit windows 7 Professional service pack 1 .. Below are 2 files that i am using .. ds_windows_x86_101202_disk1.zip (626,122,752 bytes) ds_windows_x86_101202_disk2.zip (236,880,881 bytes) But it failed but

  • How to FILL the Screen in iPhoto 11

    I have a 27" iMac. I want to FILL the screen in iPhoto like I can with the desktop feature to fill the screen. The full-screen option in iPhoto only fills about 2/3 of the 27" monitor with aphoto in landscape [versus portrait] orientation. Less than

  • Question about using built-in Web Authentication.

    Is it possible to use LDAP servers as an Authentication Server for webauth? I'm running code 4.2. We can use RADIUS which I know works fine, but I'm unclear on how to get it to work with just LDAP (if it's even possible). We'd like to use LDAP so tha

  • Copying or Cloning a local Oracle Database on a remote Server

    Hi, I am NOT a database administrator. A requirement came up such that I had to take up the Database Administrator role. The problem is like this... I have an oracle 10gR2 (Development) database on a Windows 2003 Server situated locally (in India). I

  • How to use two different hierarchies

    I have 1 business areas product.and i have create trw different hierarchies 1.Departments->Class->Sub class->Item 2.Dipertment->Item Now I have created two reports on that single business area. I wants Report1 have to follow the hierarchies 1 and Rep