JLabel (icon Image) without picture?

I am make applet containing JLabel (Icon Image). When I run this applet from server and used image-file "middle.gif" (from tutorial) - there was all Ok. After this I changed color of image on MS Photo Editor and now I get JLabel without icon and there is no errors. I don't understand what happens? Anybody know what is it?

Of course. In directory "Images" I have follow files:
green.gif
middle.gif
red.gif
Files green.gif and red.gif are middle.gif but pictures on them have respective colors. This colors I get using MS Photo Editor.
import javax.swing.*;
import java.awt.*;
import java.net.*;
public class tLabImage extends JApplet{
public void init () {
JFrame f=new JFrame();
URL url=null;
try {
// url=new URL("http://10.1.1.6/Images/middle-1.gif");
url=new URL("http://10.1.1.6/Images/green.gif");
catch (MalformedURLException e) {System.out.println (e.getMessage());}
Image image=getImage(url);
ImageIcon icon=new ImageIcon(image);
JLabel l=new JLabel ("text", icon, JLabel.LEFT);
f.setLocation(200,300);
f.getContentPane().setLayout(new GridLayout(0,2));
f.getContentPane().add(l);
f.pack();
f.setVisible(true);
When I run this programm I get JLabel without icon (only text). Why? Who can answer?

Similar Messages

  • Putting JLabel icon images in .jar

    I'm trying to make my program display JLabels with icons. This works successfully, however it relies on local files. I want to distribute the jar file only, so I was hoping there was a way I could put the images in the package or subfolder within the jar file and have the code reference the pictures there. Is there a way to do this. The code I'm using now is as follows :
    if(status.equals("good")){
         return (new JLabel(new ImageIcon("images/OK.gif")));
    }else //if(status.equals("bad"))
    return (new JLabel(new ImageIcon("images/FAIL.gif")));
    Thanks for any advice you my have.

    Putting both the class files and the images files in the same jar definitely works.
    I do it all the time. The simplest thing to do is to put the images in the same folder
    as the class file that accesses them, then jar up the lot. Your code should look like:
    URL url = this.getClass().getResource("your_image.jpeg");
    Icon icon = new ImageIcon(url);
    //etc...In fact, you should always code in this way: this code works will a jarred or unjarred program.
    Because with file names, however: jar file names are always case sensitive.

  • I have connected my macbook pro to my tv via MDP to HDMI port cable, all that is showing up is the basic desktop image without any icons, what do i do to correct this

    i have connected my macbook pro to my tv via MDP to HDMI port cable, all that is showing up is the basic desktop image without any icons, what do i do to correct this

    Your MBP is running in "extended desktop" mode, where the two screens together make one larger area to display windows. You can drag one or more windows from the primary (internal) screen to the secondary (TV) screen. By default, the secondary screen is off to the right of the primary screen.
    If you would prefer the two screens show the same image, you want to switch to "mirroring" mode. You will have to pick a single resolution for both screens, which may look poor on one or the other.
    Both the relative positions of the two screens in extended desktop mode and the switch to mirroring mode can be set in System Preferences > Displays > Arrangement.

  • Icon/Image display

    Hello!
    This is my code, and my problem is that I put 2 images to the same place, the second picture is smaller than the first but if I put the second I can't see the first... How can I solve this problem? I want to see each image in same time. Can this be solved with swing? And if yes, can you guys show a little code of how? And sorry for my bad english...
    package kep;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class kep {
        private JScrollPane getContent(BufferedImage image) {
            ImageIcon icon = new ImageIcon(image);
            JLabel label = new JLabel(icon);
            label.setHorizontalAlignment(JLabel.CENTER);
            return new JScrollPane(label);
        public static void main(String[] args) throws IOException {
            String path1 = "100.png";
            String path2 = "1016.png";
            URL url1 = kep.class.getResource(path1);
            URL url2 = kep.class.getResource(path2);
            BufferedImage image1 = ImageIO.read(url1);
            BufferedImage image2 = ImageIO.read(url2);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(new kep().getContent(image1));
            f.setContentPane(new kep().getContent(image2));
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

    You are trying to set the content pane to two different things when it can only have one. If you want the images overlapping, draw one on top of the other:
        public static void main(String[] args) throws IOException {
            String path1 = "100.png";
            String path2 = "1016.png";
            URL url1 = kep.class.getResource(path1);
            URL url2 = kep.class.getResource(path2);
            BufferedImage image1 = ImageIO.read(url1);
            BufferedImage image2 = ImageIO.read(url2);
            Graphics imageG = image1.getGraphics();
            imageG.drawImage(image2, 0, 0, this);
            imageG.dispose();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(new kep().getContent(image1));
            //f.setContentPane(new kep().getContent(image2));
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
        }

  • How to make an icon image using Photoshop

    I found out how to do this recently so I decided that I wanted to make a tut for those who don't know how to make an icon image. This icon image is for the libraries tab on your computer. Under the libararies tab there is Music, Pictures, Documents, and Photos
    First you will need the ICO (Icon image format) Format extension for photoshop which can be downloaded here:
    http://www.telegraphics.com.au/svn/icoformat/trunk/dist/README.html
    The download link and tutorial on how to install it is all in the link above.
    Once you have that all set you can now launch photoshop to create your icon image. Once you have launched it, create a new document with the size as in the image below.
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/256x256_zpsbf3dcf8e.png~original[/IMG]
    Create the image you want. I used a simple one by using the custom shape tool by pressing "U" on your keyboard and with the
    basic blending options.
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/IconImage_zpsd788c709.png~original[/IMG]
    The reason why the image is pixelated is because it is an icon image. Since the image is only 256x256 pixels when you zoom in on it that will get you the pixely result. The reason why I zoomed  in is so you can see it. But don't worry this is no the end result. Just continue reading and you will see.
    So once you have created the icon go ahead and press
    file>save as>(under format choose the ICO)>and choose the name that you want to name it. And save it in your C: drive. You will see why to save it in your C: drive in a sec.
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/SampleicoPic_zpsd252bfba.png~original[/IMG]
    So now that you have created the icon and saved it now you can create the new library.
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/NewLibrary_zps8ca703b2.png~original[/IMG]
    Name the library whatever you want I named it "Sample" for tutorial purposes. Notice how it gives you a default boring icon image for your library.
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/Sample1_zpsb5472840.png~original[/IMG]
    So now once you have created and named your library now it is time to get the icon image into place.
    Go to computer/c: Drive/users/YOU/ And now once you have reached this area you will need to access a hidden folder named "appdata" to do so press "Alt" then a menu bar will show. Click
    tools>folder options>and view. Find the option to view hidden folders then press apply then ok. Now we shall continue so AppData>Roaming>Microsoft>Windows>Libraries
    Now you should see all the libraries including the one you just created.
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/showhiddenfolder_zpsad4a3c94.png~orig inal[/IMG]
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/Libraries_zpsf6243bc0.png~original[/IMG]
    Once you have reached your destination then open a new text document with notepad and drag the library you just created in notepad. The result should look like this:
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/Notepad_zps251a86f0.png~original[/IMG]
    once you have reached this point click at the end of the second to last line down then press enter and enter in this information
    <iconReference>c:\"NAME OF ICO FILE YOU CREATED IN PS".ico</iconReference>
    Example:
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/iconreference_zps1c1a3eca.png~origina l[/IMG]
    Once you have entered that information go to file>save and the icon image should appear on the library you created.
    [IMG]http://i1297.photobucket.com/albums/ag25/dusty951512/Finished_zps267f893a.png~original[/IMG]
    Now you are officially finished. Go and spread the news and joy. Bye for now
    -Dusty951512

    It is Windows only because all those screen shots are exclusively Windows, the file structure and paths do not resemble those of the Mac in the least.  As a Mac user, there's nothing I could take from your tutorial.  Sorry, 
    No drives named with letters like C: on the Mac, for instance.  No backward slashes either, ever.  No such paths either.  No "Notepad" on the Mac, we use TextEdit; but such a text editor is not remotely needed on the Mac to make and/or edit icons.  Etc.
    Those folders are not even called "Libraries" on the Mac…  Nothing resembling your tutorial at all.
    The icons in the Finder's Sidebar are not customizable at all in recent version of OS X.
    =  =  =
    You can edit any post of yours only until someone replies to it.  At this time your post is not editable by you any longer.

  • How can I attach an image without the image is in the email body? (using the new mail the Lion)

    How can I attach an image without the image is in the email body? (using the new mail the Lion)
    I want in attachment, not in the body mail.

    I think your only solution is to zip the image files first and then attach them.
    Read this from a site I found:
    Sending Graphical Attachments -- When you attach a graphical image to your message, the recipient of your message sees the image inline (that is, in the body of the message) if her email client supports inline display. ("Take Control of Email with Apple Mail" contains a table listing the capabilities of popular Mac and PC email clients.) If a client does not support inline display (or the recipient has turned off the inline display option), the file appears as an attachment that must be opened in a separate program.
    On the one hand, an inline image is easier for the recipient to see - all she has to do is look at it. On the other hand, inline images can be frustrating to scroll through. If you do not wish to send a graphical image inline, you must compress the file before attaching it - Mail, sadly, lacks a built-in compression option, though fortunately for Panther users, the Finder offers Zip compression without requiring a separate application.
    Note that when you compose a new message, Mail always shows attachments in the body of your message. You can manually drag them somewhere else, but many email clients display all attachments in a separate list, regardless of where you place them in the message body.
    If you paste an image into a message or drag & drop an image from another window (say, a Web browser), Mail converts the raw image data to an attachment in TIFF format. On the other hand, if you drag & drop the icon of an image file (or use the Attach button to locate the file using the file browser), Mail leaves the attached image in its original format. This difference is significant, because although most email clients can display JPEG images just fine, support for TIFF - especially in non-Mac email clients - is less common. If possible, I suggest attaching image files as opposed to pasting or dragging in raw image data.

  • My new Photoshop Elements 12 has a RAW file plug-in, but when I try OPEN to select a photograph, there are only generic icons instead of pictures-- I can't tell one photograph from another! How can I fix this so I can tell which photograph I want to open?

    My new Photoshop Elements 12 has a RAW file plug-in, but when I try OPEN to select a photograph, there are only generic icons instead of pictures-- I can't tell one photograph from another! How can I fix this so I can tell which photograph I want to open? Thank you!

    Thanks R_Kelly:
    Adobe Photoshop Elements Version: 12.0 (12.1 (20140303.12.1.49334)) x32
    Operating System: Windows Vista 32-bit
    Version: 6.0 Service Pack 2
    System architecture: Intel CPU Family:6, Model:15, Stepping:11 with MMX, SSE Integer, SSE FP, SSE2, SSE3
    Physical processor count: 4
    Processor speed: 2400 MHz
    Built-in memory: 3069 MB
    Free memory: 1631 MB
    Memory available to Photoshop Elements: 1598 MB
    Memory used by Photoshop Elements: 69 %
    Image tile size: 128K
    Image cache levels: 8
    Video Card: ATI Radeon HD 4800 Series
    Video Mode: 1680 x 1050 x 4294967296 colors
    Video Card Caption: ATI Radeon HD 4800 Series
    Video Card Memory: 512 MB
    Application folder: C:\Program Files\Adobe\Photoshop Elements 12\
    Photoshop Elements scratch has async I/O enabled
    Required Plug-ins folder: C:\Program Files\Adobe\Photoshop Elements 12\Required\
    Primary Plug-ins folder: C:\Program Files\Adobe\Photoshop Elements 12\Plug-Ins\
    The first thing I did was UPDATE. I have all the latest updates available (according to the updater). The Camera Raw Plug-in says it is version 8.0.
    The RAW files are from a Canon T3i. It's a very common camera, I can't believe it wouldn't be supported.

  • How to extract the mouse cursor image without using JNI

    I want to get the image of the mouse cursor of the system using java. The Robot class captures the screen only, but the mouse icon image is not the part of the screen, so it is not easily detected. But we can get the mouse cursor position using API, but how to get the exact image icon, without using JNI. I don't want to generate my own cursor at that position.

    I am building a Remote Desktop kinda app using java..... I want the screen of the remote comp to be viewed on my screen and generate events from my machine to the remote machine. So, I am capturing the screen images of the remote machine. But the cursor is not part of the screen object. i want to extract the cursor image icon from the remote machine to my machine and render the image.

  • JLabel Icon Updates

    I am running a MYSQL query and assigning the values to Jlabels. Like this:
    jLabel2.setText ( nameVal );I want to be able to assign the icons of the jLabels as well. Is this possible?

    Same result. Here is the whole thing right from the tutorials:
    //package components;
    import java.awt.GridLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.ImageIcon;
    import javax.swing.UIManager;
    import javax.swing.SwingUtilities;
    * LabelDemo.java needs one other file:
    *   images/middle.gif
    public class LabelDemo extends JPanel {
        public LabelDemo() {
            super(new GridLayout(3,1));  //3 rows, 1 column
            JLabel label1, label2, label3;
            ImageIcon icon = createImageIcon("http://duke.kenai.com/iconSized/duke4.gif",
                                             "a pretty but meaningless splat");
            //Create the first label.
            label1 = new JLabel("Image and Text",
                                icon,
                                JLabel.CENTER);
            //Set the position of its text, relative to its icon:
            label1.setVerticalTextPosition(JLabel.BOTTOM);
            label1.setHorizontalTextPosition(JLabel.CENTER);
            //Create the other labels.
            label2 = new JLabel("Text-Only Label");
            label3 = new JLabel(icon);
            //Create tool tips, for the heck of it.
            label1.setToolTipText("A label containing both image and text");
            label2.setToolTipText("A label containing only text");
            label3.setToolTipText("A label containing only an image");
            //Add the labels.
            add(label1);
            add(label2);
            add(label3);
        /** Returns an ImageIcon, or null if the path was invalid. */
        protected static ImageIcon createImageIcon(String URL,
                                                   String description) {
            java.net.URL imgURL = LabelDemo.class.getResource(URL);
            if (imgURL != null) {
                return new ImageIcon(imgURL, description);
            } else {
                System.err.println("Couldn't find file: " + URL);
                return null;
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event dispatch thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("LabelDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Add content to the window.
            frame.add(new LabelDemo());
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event dispatch thread:
            //creating and showing this application's GUI.
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
              //Turn off metal's use of bold fonts
                 UIManager.put("swing.boldMetal", Boolean.FALSE);
              createAndShowGUI();
    }

  • HT4519 how do i get my server email to send pictures.  Email works without pictures, but when attaching a picture the mail will not send

    Email works without pictures, but when attaching a picture the mail will not send

    Hi,
    In Mail > Preferences > Accounts to can find out which STMP server you are using for outgoing items.
    This can be one account.
    I do this with a dial Up account I still have access to.
    I can "fetch" mail over DSL and now Fibre.
    However I have to be Logged in via Dial up to actually use their Servers to Send.
    As a Consequence I "send" via one of the other Accounts STMP servers.  (I tend to add a signature that reflects this account change)
    The other thing that might explain what you are seeing is the Full Name Box.
    8:38 PM      Monday; April 8, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Embedding images without explicit style definitions

    I'm designing an app with a big row of buttons.  They are all identical except for the label and icon.  Ideally I would like to be able to define them via ActionScript using a for loop.  I'm stuck on how to embed the icon images though without doing a separate style entry for each button.
    example code:
    var labels:Array = ["hello", "interior", "exterior", "photos", "videos", "accessories", "games"];
                for each (var s:String in labels) {
                    var b:Button = new Button();
                    b.label = s;
                    buttonBox.addChild(b);
    For each button I've got graphics called name.png and name-b.png.  So how would I set the skin and over-skin properties of each button programmatically, as if I had made a separate style for each button ala:
    .hello {
       skin: Embed(source="assets/hello.png");
       over-skin: Embed(source="assets/hello-b.png");

    [Embed(source="assets/hello.png")]
    public var buttonskin:Class;
        b.setStyle("skin", buttonskin);

  • Apple, please fix this bug.  Sending scanned images to "Pictures" is not what I want nor what I was able to do in every previous operation system.   I want to save all scanned items in a specific folder - NOT "PICTURES"  Please fix this bug NOW!

    Apple, please fix this bug.  Sending scanned images to "Pictures" is not what I want nor what I was able to do in every previous operation system.   I want to save all scanned items in a specific folder - NOT "PICTURES"  Please fix this bug NOW!

    I only use Image Capture, so I can't speak for other software.
    Here is how I select a Scan To destination:
    If you are using the minimal details screen, you should have the same submenu to the left of the page size.

  • How Do I get icons image directory to work in a JAR file?

    Yes, I must admit after going through the tutorial and other stuff I am stiil stumped
    I have an application that uses the jlfgr icons for the toolbar, and it works fine as long as i actually run it from the directory that it is in.
    I would like to put in into a jAr file, and be able to execute it from other places.
    I have a Directory named PhoneBook
    in that are the classes I use
    AddressBook - the main class
    PersonEntry - The 'data class'
    and various other things like FileFilters.....
    inside that directory there are two more:
    images - contains all the icon images
    Data - where the default 'database' entries are stored.
    I use code like this:
         private void fillToolBar( JToolBar bar )
              Dummy = new JButton(new ImageIcon("images/New16.gif"));
              Dummy.setActionCommand("New");
              Dummy.addActionListener(this);
              Dummy.setToolTipText("New");
              bar.add( Dummy );
              // etc etc
    to get all the icons into the toolbar
    I have made a Jar file that has all the classes and all the directorys with the icons in it
    and so the program runs, but does not get the icons for the toolbar, I just get a whole load of 'dud' buttons.....
    AS this is the first time i've ever got the GUI to look right rather than just the code functioning properly
    I'd like to get the whole thing in a working Jar file
    So Could someone show me Step By Step, How I get my classes and images into a Jar file
    so that i can from a different directory go
    java - jar Phone.jar
    and have the GUI come up with all the images, assuming I'm totally thickheaded when it comes to Jar files.?
    I also can't get the images to show up if I merely run the 'program' from another directory than the one it is compiled in
    I can get the program to run, just not access the images with something like
    java -cp blah/blah/blah AddressBook
    {the main class is AddressBook }
    the data directory can be anywhere as I use a JFileChooser to allow the user to open and save desired files.
    I really would appreciate some clear workable help. {though I'm running out of Duke Dollars...}

    What you need is a correct path to the directory
    inside of the jar. This can be accomplished by adding
    a line to your main program like this:
    URL
    url=myProgram.class.getResource("images/New16.gif");
    Dummy = new JButton(new ImageIcon(URL));
    where myProgram.class is the name of the class
    file that contain the main method.
    Hope this helps....
    ;o)
    PS: I don't want your dukes...I got them coming out of
    my ears!
    O.K, that works thank you.
    I put something like:
    for all the 'buttons' in the toolbar
    URL url = null;
    Class ThisClass = this.getClass();
    url=ThisClass.getResource("images/New16.gif");
    Dummy = new JButton(new ImageIcon(url));
    Dummy.setActionCommand("New");
    Dummy.addActionListener(this);
    Dummy.setToolTipText("New Database");
    bar.add( Dummy );
    etc for all the rest of the 'buttons'
    After Reading the API docs on URL's etc I'm still not sure as to why it works, but it does....
    I am able now to place the class files in a jar along with the images and it all works fine
    although now I don't quite follow all my code....................
    I assume that
    url=ThisClass.getResource("images/New16.gif");
    returns some sort of 'relative url ' ???
    Thanks for the help though.

  • How to load an image without a gui? big problems...

    Hey guys, I usually try my best to not ask for help and figure stuff out myself. But this last week i've been having big problems with this work project.
    My goal is to load images from disk, and append them to each other to create one big image.
    The images are 0-9.jpg each file containing a number in it. then i create one big file with 4 numbers in it. called final.jpg.
    so far i can do all this, but whenever the program is finished, the application just keeps running. the program has literally gone through all the steps... i have a system.out.println printed on the last line after the main, after the class instantiation... and still it stays running.
    how do you guys load images without a gui? This program will probably be running under unix, so i can't create a (for component example)
    Panel() and media track the file load... so i'm pretty much stumped
    any help you guys can provide would be really incredibly helpfull at this point. I have searched these threads for a few hours without luck. I found only 1 real post related to my problem, but eventually they said use MediaTracker = new Mediatracker( new Panel() ); which i can't use. :(
    Thanks a lot guys.
    :D

    yeah tried doing that, didn't work either.
    UPDATE
    I FINALLY found a way...
    and here it is for others to find!
    public BufferedImage getImage(String filename) throws Exception {
    FileInputStream input = new FileInputStream( filename );
    JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder( input );
    BufferedImage image = decoder.decodeAsBufferedImage();
    return image;
    it returns an image buffer, but it's better than nothing! :)
    atleast this functions under unix.

  • Can I delete all of the images in "All Images" without losing any originals?

    Can I delete all of the images in "All Images" without losing any original photos? Thank you.

    Simply: iPhoto is a database. Like all databases it requires that you manipulat the data via the tools provided and not through backdoors. If you delete matter managed by iPhoto (or for that matter, any database) through some other means then the database will be unaware of the deletions. The database will not reflect the changes and you'll have significant issues going forward with iPhoto.
    So, to be really, really clear: if you delete Photos managed by iPhoto via the All Images search you will corrupt your Library.
    It's your computer, your images and your iPhoto. You have the information, you decide how to use it.
    Regards
    TD

Maybe you are looking for

  • XML File and in Studio - How to Code

    Hi all. I have the following code in my Method, it's code will be part of an .xml file that I am producing from the system: content = "<?xml version='1.0' encoding='utf-8'?>" +"\n<Documents>" +"\n<Document>" +"\n<Images>" +"\n<Image Location='\\\\SrM

  • BI Source System connection to ECC

    Hi experts, I have a BI 7.0 fresh install and I'm trying to connect ECC 6.0 client dev100 (golden client) to BI so I can activate BI Content. However, the client 100 goes to the BI folder instead of the SAP folder when I create source system in AWB.

  • Guid Guide Extension not installing saying its already installed for Photoshop CC 2014

    1) I have tried uninstalling and reinstalling the extension manager cc multiple times. 2) I have uninstalled Photoshop CC 2014 and reinstalled it 3) and yes both are up to date

  • Need a scrollbar that WORKS

    Since your 'geniuses' installed the retrograde Mavericks "free upgrade" that is nothing short of awful, my scroll bar does not work in any application. <Edited by Host>

  • New MBP won't mount some CD/DVDs; why?

    When i insert certain CD/DVDs the optical drive clicks and buzzes three times before spitting the disk out again. Even the Leopard install disk that came in the box won't mount. Strangely every type of blank media that i have tried works without any