473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

can not load some images to display in a JLabel??

Hi,
I am getting this weird behavior. I have couple of gif and jpg files
that I would like to display in JLabel. It displays one jpg image but
it does not display other gifs and jpgs. Any idea why it would do so.
Sample code is :

JPanel logoPanel = new JPanel();
logoPanel.setLayout(new BoxLayout(logoPanel, BoxLayout.X_AXIS));

ImageIcon logo = new ImageIcon(_imageFileName);
JLabel iconLabel; //label containing logo
iconLabel = new JLabel( logo, SwingConstants.LEFT);
logoPanel.add(iconLabel);

Any suggestions and ideas. In case you are wondering, I also tried
using explicit MediaTracker to make sure image gets loaded although
constructor for ImageIcon loads image using MediaTracker. Thanks.

Prabhat
Jul 17 '05 #1
1 5885
Hi Prabhat,
I solved a similar problem with JTree's using the form:

.... new ImageIcon(getClass().getResource("/coins1.gif"))

HTH

Jim

prabhat wrote:

Hi,
I am getting this weird behavior. I have couple of gif and jpg files
that I would like to display in JLabel. It displays one jpg image but
it does not display other gifs and jpgs. Any idea why it would do so.
Sample code is :

JPanel logoPanel = new JPanel();
logoPanel.setLayout(new BoxLayout(logoPanel, BoxLayout.X_AXIS));

ImageIcon logo = new ImageIcon(_imageFileName);
JLabel iconLabel; //label containing logo
iconLabel = new JLabel( logo, SwingConstants.LEFT);
logoPanel.add(iconLabel);

Any suggestions and ideas. In case you are wondering, I also tried
using explicit MediaTracker to make sure image gets loaded although
constructor for ImageIcon loads image using MediaTracker. Thanks.

Prabhat


--
! Jim Katz
! NetBeans 3.5.1
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dB | last post by:
I want to load an applet locally from the client's hard drive from an html/jsp page served by Tomcat on the local machine or a remote server. The motivation is that I need to print to the local...
2
by: Mehdi | last post by:
Hi, I have 3 small images on my page. I also have a large image which is displayed when any of the 3 small images is clicked. I do this to display a large version of each image. On page load...
4
by: jordi_ramis | last post by:
Hi, I'm currently using image.fromfile to load jpg images in my application. I've noted that this procedure is very slow compared to some aplications I have seen. Is there any way to load a jpeg...
6
sammyboy78
by: sammyboy78 | last post by:
I'm trying to display my array of objects in a GUI. How do I get JLabel to refer to the data in my objects? I've read my textbook and some tutorials online I just cannot get this. Plus all the...
3
nanhiPari
by: nanhiPari | last post by:
hello everyone i need to create DYNAMIC JLABElS(say 5)..yes i know it sounds easy but i also have to give them Events n then want to refer each of them when ever Mouse is Clicked on a Specific...
1
by: tommyny04 | last post by:
I'm kinda new to programming but I usually figure things out by myself but I need help with this. I'm trying to display an image in the Center region of a JFrame and other icons/button in the other...
2
by: vertozia | last post by:
Hey there, ive been having difficulty placing an image, this is my screenshot, and what ive done so far: http://img341.imageshack.us/img341/9894/gridwg2.jpg /** * ConnectFourGUI * Provide...
4
hemantbasva
by: hemantbasva | last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even...
2
by: Coreyja | last post by:
Im trying to display a png image by setting it as a ImageIcon and then putting that in a JLabel. I cant get it to display the image. I am using a null layout as it is the simplest way for me to get...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.