How do i display an image on a GUI?

I am making a GUI, and I was trying to post an image(s) on it. I tried various things including turning it into an applet and using the paint(Graphics g) method, but it didn't show up.
Thanks!

calm down chief, these people work for a living. They will get to you. Here is a GUI that I did a while ago that has images in it. Maybe it will help you. Let me know.
import java.awt.*;
import javax.swing.*;
public class NestedPanels {
    public static void main(String[] args){
        ImageIcon pic1 = new ImageIcon("nasa1.jpg");
        ImageIcon pic2 = new ImageIcon("nasa2.jpg");
        ImageIcon pic3 = new ImageIcon("nasa3.jpg");
        ImageIcon pic4 = new ImageIcon("whale.jpg");
        JFrame frame = new JFrame("Nested Panels");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //first subpanel
        JPanel subPanel1= new JPanel();
        subPanel1.setPreferredSize(new Dimension(600,600));
        subPanel1.setBackground(Color.white);
        JLabel label1 = new JLabel ("pic one",pic1,0);
        JLabel label2 = new JLabel("pic two",pic2,0);
        subPanel1.add(label1);
        subPanel1.add(label2);
        //second subpanel
        JPanel subPanel2 = new JPanel();
        subPanel2.setPreferredSize(new Dimension(600,600));
        subPanel2.setBackground(Color.white);
        JLabel label3 = new JLabel("pic three",pic3,0);
        JLabel label4 = new JLabel("pic four",pic4,0);
        subPanel2.add (label3);
        subPanel2.add(label4);
        //primary panel
        JPanel primary = new JPanel();
        primary.setBackground(Color.white);
        primary.add(subPanel1);
        primary.add(subPanel2);
        frame.getContentPane().add(primary);
        frame.pack();
        frame.setVisible(true);          
}You gotta make sure that the pics are in the same folder ok bud?

Similar Messages

  • How can i display a image file which is placed in the applications server

    Hi all,
    Can any one help me how can I display a image file which is present in the application server.
    With regards,
    M.Ramana Murthy

    hi,
    *& Form TOP_OF_PAGE
    * text
    FORM F_TOP_OF_PAGE.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = IT_LISTHEADER
    i_logo = Logo name
    * I_END_OF_LIST_GRID =
    ENDFORM. "TOP_OF_PAGE
    rgds
    Anver

  • Image display - How do I display an image using an absolute path?

    How do I display an image using an absolute path in a compiled WebHelp?
    Our developers use RH8 map IDs within our in-house applications to display in a model window created using Telerik Rad Window.
    Unfortunately images disappear from these model windows because RoboHelp removes absolute links to [inserted] images and changes them to relative in the compiled WebHelp.
    How do we overcome this? Is there a solution in RH8?

    I have tried again and changed the path in the topic HTML
    from : ..\..\HelpTopics\Icon_Search.png
    to    :  \HowDoI\Help_CMS\WebHelp\HelpTopics\Icon_Search.png
    I am obviously unable to see it in RH8 as I have removed the relative link so it is "outside" of the project.
    This time, on compilation, it has not stripped out the absolute links. The developer was working with me on this last week and we did have any issue in that they did not hold the absolute link. Most odd!
    Checking the published help it appears to be working in the application, which is great.
    So my apologies for raising the issue but it really did not work last week.

  • Displaying a image in a gui

    i was wondering how i can display an image using jframe
    what steps would i need to take to get it working

    Yes, there are several ways you can get an image icon either from local disk or network. I have used the simplest approach and shown here how to display an image in user interface.
    As suggested by DrLaszloJamf, using URL is good approach. Locate your image, construct the URL and then create the image icon using that URL.
    Sample code for creating image icon:
         * Locates the image icon at specified {@code path} using given class reference
         * and a short description of the image.
         * Once the URL is resolved it creates an image icon and returns the same.
         * @param cl The class which is used as reference to locate the image icon.
         * @param path The pathname for the image.
         * @param description A brief textual description of the image.
         * @return An image icon. It returns {@code null} if given path can not be resolved
         *               or failed to load the image icon.
        public static ImageIcon createImageIcon(Class cl, String path,
                String description) {
            // Validate inputs here.
            try {
                URL imgURL = cl.getResource(path);
                if (description != null) {
                    return new ImageIcon(imgURL, description);
                } else {
                    return new ImageIcon(imgURL);
            } catch (Exception ex) {
                ex.printStackTrace();
                return null;
        }Thanks,
    Mrityunjoy
    Edited by: mrityunjoy on 6 Feb, 2009 10:22 AM

  • How do I display blob (image) in a Portal Report

    I am using 9ias 10222 and portal 30983 and I have a table that stores an image as a blob and have a varchar field to store the mime type. I have created a form to upload the image and can then query the form to display the image.
    How do I dislay the image in a Portal Report/Dynamic Page Component. I have followed note 68016.1 but the retrieve_img_data procedure does not work it gives a wwv-11230 error.
    Any ideas? Any help would be appreciated.
    Thanks
    Belinda

    Hi,
    Can you display what code you used for this? I followed note 172045.1 and everything compiles properly but when I run the report, I just get a box with a red X in it, like it is not finding the picture. I ran the procedure that downloads the image and it works fine from there. Thanks.

  • How can I display an image from a shared-network folder?

    Hi
    Does anyone know how I can display images from within APEX that are found outside the database? What configuration have I missed?
    Within Windows-Internet-Explore I can access the following image using the below URLs, BUT I cannot access it from within APEX?
    What do I need to do so APEX can display theses images from our internal shared network folder?
    both these URLs work within Firefox (but on APEX):
    \\Saremote\UPDOWNFILES_DIR\polk_insight.gif
    file://///Saremote/UPDOWNFILES_DIR/polk_insight.GIF
    So within APEX I have created a "display as Text' Item that works with this "amazon image" syntax:
    {lessthan} IMG SRC= {doublequot} http://g-images.amazon.com/images/G/01/associates/navbar2000/logo-no-border(1).gif {doublequot} {greaterthan}
    BUT sadly not with my image:
    {lessthan} IMG SRC= {doublequot} file://///Saremote/UPDOWNFILES_DIR/polk_insight.GIF {doublequot} {greaterthan}
    Any ideas would be appreciated.
    Thanks
    Steve
    Edited by: [email protected] on Sep 12, 2008 8:30 AM
    Edited by: [email protected] on Sep 12, 2008 8:31 AM
    Edited by: [email protected] on Sep 12, 2008 8:32 AM
    Edited by: [email protected] on Sep 12, 2008 8:33 AM

    If you have a local html file, or open an image locally from the menu, then yes, it works, but with web pages that are served from a remote location (web server), security kicks in and prevents the web page from accessing local files (and files on a networked drive).
    you will either have to put the image on the web server and access it through http, or you can load it into the database/workspace images and access it that way.

  • How can I Display a Image with tiff format in Jpanel?

    How can I Display a CMYK Image with tiff format in Jpanel ? Not in ScrollingImagePanel? Thank you in advance.

    Why nobody can help me?I am very anxious!help me,please!

  • How do you display an image on a frame or panel?

    Can anyone tell me or point me towards a resource that explains how to display an image on a java fram or panel?
    Thanks,
    Eric

    You can create a JLabel with the image and then add the JLabel to the frame/panel.

  • How can I display three images in video rate succession (60 Hz)?

    For a structured illumination microscope application, I have developed a VI that creates three images and displays them in rapid succession (as fast as the loop will go) on a second monitor.
    From the naked eye it's pretty apparent that the loop is not displaying the images at video rate.  Is there a way (perhaps with some sort of buffer) to get them to display faster?  Is WinShow simply not going to be fast enough, and if not, what's an alternative method of displaying the images?  If it helps, the images need only be displayed once each (the loop was just for testing).
    Also, what is a way to measure the frame rate output of the images?
    (sorry for the sloppy code, new to LabView)
    Thanks,
    -T
    Attachments:
    illuminationpattern.vi ‏31 KB

    Hello,
    Why don't  you try drawing one window, call IMAQ WindShow once outside of the loop, then redraw that window each iteration within the loop.  Hopefully this stops the flutter of the window.  You can build a 3 element array of the 3 IMAQ images then use an index array to alternate through which image you want to be redrawn into the single window.  The constant calling of IMAQ WindShow seems messy.
    Regards,
    Isaac S.
    Applications Engineer
    National Instruments

  • How do I display an image in an APPLICATION

    I have the following code and I want to display an image. I figured that the easiest way to display an image was via a JLabel.
    import javax.swing.*;
    import java.awt.*;
    public class NewMain {
        public static void main(String[] args) {
            JFrame win = new JFrame("TestApp");
            win.setDefaultCloseOperation(win.EXIT_ON_CLOSE);
            win.setBounds(0,0,200,200);
            ImageIcon icon = new ImageIcon("ca.bmp");
            JLabel label = new JLabel("",icon,JLabel.CENTER);
            win.add(label);
            win.setVisible(true);
    }What am I doing wrong. I have the cd.bmp file in the source directory but I just get an empty frame when I run the program...
    PS: I get a lot of hate messages in other forums. I am BRAND new to programming anything (especially OOP). I realize I suck at this but that is why I am trying to learn.

    You need to become familar with Sun's tutorials, like this one about labels:
    http://java.sun.com/docs/books/tutorial/uiswing/components/label.html
    It has an example and code for what you want to do.

  • How to best display/update images in gallery??

    I'm designing a site for my photography but I'm stuck. I'm new to this and trying to learn, so I'll try to explain clearly. Usually I have problems with things that sound like they should be really simple but end up with unbelievably complex answers, so please keep my beginner status in mind with responses (the complexity itself isn't an issue since i'm sure i could learn whatever needs to be done, just that nothing is more frustrating than an answer of pure code and no plain-english explanation of what is going on).
    the overall design is simple enough: thumbnails to the right (in their own iframe so links can navigate several columns of thumbs, though i'm sure there's a better way to do this, too), large images to be displayed nearish to the center, and some other stuff to the left unrelated to this issue. If all the images were oriented the same way (all landscape or all portrait) i'd have no trouble just creating a frame/iframe of the correct size and call it good enough, but i have about half landscape and half portrait. I considered a square iframe, but then i'd have to create a new html file for every single image (to make the image centered and make the background transparent so i don't get white bits). Is there a way I can do this where i could link just the jpgs to something (centered within a frame, div, whatever) with transparency enabled and save myself the pain of creating dozens of individual html files?
    I've researched a few ideas I had: It doesn't appear to be possible to link directly to a large square div. It also doesn't seem possible to format/style an iframe to meet those requirements without the individual html pages. I've wondered if it would be possible to create two overlapping iframes (one for landscape, one for portrait) and have the link specify which one should show, but i've found nothing helpful on this issue (not even enough to know if it's possible in this context). i even considered throwing out dreamweaver completely and doing a flash-based site, but i was told that this was too hard for a beginner and to not even try (always love a vote of confidence). If I am told the same thing here I may consider scrapping the project entirely because i'm fast running out of options (and i just won't create individual html pages for dozens and dozens of images, it's not worth that kind of tediousness). And this should be obvious, but because a friend suggested it someone else might: no, my work cannot be cropped so they're all the same dimensions and i'd prefer to not modify the images in photoshop to create borders that make them all square (on a slow connection it looks really strange if the image and the "background" load together).
    I hope i gave enough info/details.

    Instead of creating x-number of html pages, just have your menu page dynamically write the html page to the main viewing frame.  If you have different layouts you can have javascript code make decisions based on information you pass to the writing functions from the menu selections.  What you'll want to do is learn how to use the document.write() javascript functionality.  You would build a variable that contains the html code for the page and then use the document.write() function to write that code into the frame.
    As a simplified example, you could have a javascript function in the menu page that you pass the image name to and write that as a page to the "main" frame...
    function createImagePage(imageFilename){
        // create the page code
         var mainCode += "<html><head><title>An Image Page</title></head><body><img src=\"";
         mainCode += imageFilename;
         mainCode += "\"></body></html>";
         // write the page code to the main viewing frame
         parent.main.document.open();
         parent.main.document.write(mainCode);
         parent.main.document.close();
    While I didn't show it, if you have two different page styles to create, then along with the filename you could pass a style number to the function to have the javascript decide which format to code.
    Sorry if that little bit of code is over your head, but you'll have to learn the languages involved in web pages if you want to create them.  Using document.write() is one of the first things you are likely to learn in a javascript course.

  • How do you display a image in apex

    I have a trouble for a long time..
    I can't load a image in apex..
    I do a lot of things but it never give result correctly
    some could help me..
    Thank u....

    Hi,
    OK - the link I gave will explain how to upload into a table and then display images from there.
    To do this through Shared Components:
    1 - Go to Shared Components
    2 - Select Images
    3 - Click Create
    4 - In the Application option, leave it as "No Application Associated" if you want any application to use the image, or select an application if the image is for that application only
    5 - Click the Browse button, locate your image file on your machine and click Open
    6 - Any any Notes you want (this is not required)
    7 - Click Upload
    On your page, decide where you want the image to appear. This can be in a region's Source, Region Header or Region Footer OR if you want you can do this on the page template you are using. Then enter in:
    For an image NOT associated with an application:
    &lt;img src="#WORKSPACE_IMAGES#filename.gif"&gt;For an image associated with an application:
    &lt;img src="#APP_IMAGES#filename.gif"&gt;Andy

  • How to dynamically display in Image Field with external pic source

    Hi Guys,
    I have the following scenario:
    I need to have a form that needs to display an x amount of images on the same page area.  I have not found any documention with regards to creating an undisclosed number of Image Field elements, so I am experimenting with using a Table to display entries of type Image Field.
    I do not know at design time which pictures will be shown in this table.  This needs to be calculated dynamically when an Incident Number is supplied to the Java WebDynpro application that uses Adobe LiveCycle Designer (Dont worry about this).
    Now, first of all: Is it possible to use the URL of images that are OUTSIDE the form structure?  In other words, usually one would imbed the image in the forms structure, but because I do not know this image's URL at design time I need to pass it dynamically?  Please comment!
    Also, what is the FormCalc syntax for accessing a field in the "Data View" view at the left side of the designer?  For example, If i want to access the following part in the "Data View"view, what syntax should I be entering in the script editor:
    I would like to access this value as I would like to append it to the end of this statement so that I can get the value dynamically:
    this.value.#image.href=  ???????

    You cannot change the url of the image on the fly for security reasons.
    In your case you have to use the dynamic image fields in the xdp form, encode the external  images with base64 encoding to be a string, populate with those strings the xml and render  your template with this xml.
    Here: http://eslifeline.wordpress.com/2008/09/05/inserting-image-in-a-xdp/#comments you have a good example by Girish Bedekar for such a process.
    Yan.

  • How do I display an image in Numbers based on the value of another cell?

    Here is the situation. I have a list of names in one table. I then have a table of pictures of corresponding to each name. I then have a drop down list in a cell with each of the names in it. I would like to be able to click the drop down list, select a name, and then have the corresponding picture be displayed in a cell. How would I go about doing this?
    Late 2013 rMBP with fully up to date software.

    not possible.  I have wanted to do this myself.  You can post feedback to Apple using the menu item "Numbers > Provide Numbers Feedback"

  • How can i display an image in a canvas where full of Graphics2D component?

    i just learn to use Graphics2D components, but my boss ask edme to replace all the rectangles by some folder image in application's canvas... Gee! i got stuck there for 2 days
    could u help me please?

    the problem is i drew some Rectangles on the canvas ("g2.draw(new Rectangle2D.Double(x, y, rectWidth, rectHeight));") and now the requirment is to replace all these Rectangles to some image (the folder icon image i made with photoshop "folder.jpg")
    what am i suppose to do?? i cant find any method to make this amendment.
    reagarding to the drawImage() method could u please send me some sample code to demonstrate how to implement that? i am trying to understand all paramaters like (BufferedImageOp/ ImageObserver ) but i still cant get it.
    i am a new guy in java programming, please help me out here, thanks a lot!

Maybe you are looking for

  • Performance problem to retrieve the report

    hi gurus i am working in BW support, i got a issue regarding reports. query  taking to much time to retrieve the report, and the same probs arise when u try to drill down in report. can anyone plz give me a solution to solve my problem. thanks in adv

  • Unable to send or receive contact info through message

    Hi, I am unable to send or receive contact info through message.How to solve this problem? thanks

  • I tunes problems

    when i try to open itunes i get a message "itunes can not be opened" -1712 what can i do?

  • How to delete logical component

    How to delete logical component in solution manger 4.0 Am deleting one system eatery in landscape components that time giving one warning? Is there any option for deleting logical components? Please give any solution for deleting system& logical comp

  • Load variables externally?

    I am fairly new to flash. Can anybody give me any advice on how to load variables from an external file on my website that I can edit with a text editor. I am making a flash intro to a website that has a pull-down panel that displays information on n