473,414 Members | 1,951 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,414 software developers and data experts.

Displaying an image!!

Here is my code for displaying an image but doesnt work. It runs but displays nothing!

Expand|Select|Wrap|Line Numbers
  1.  
  2. import javax.swing.*;
  3. import java.awt.*;
  4.  
  5. public class Frame extends JFrame
  6. {
  7.     private JLabel irishrail;
  8.  
  9.     public Frame()
  10.     {
  11.         super("Frame");
  12.         Container c = getContentPane();
  13.         setSize(600,550);
  14.         irishrail = new JLabel(new ImageIcon("iarnrod.bmp"));
  15.         c.add(irishrail);
  16.         setVisible(true);
  17.  
  18.     }
  19.  
  20.     public static void main(String args[])
  21.     {
  22.             Frame frame = new Frame();
  23.  
  24.     }
  25.  
  26. }
  27.  
  28.  
Feb 12 '08 #1
1 1335
BigDaddyLH
1,216 Expert 1GB
Sun's tutorial page for Icons: http://java.sun.com/docs/books/tutor...ents/icon.html states:

Many Swing components, such as labels, buttons, and tabbed panes, can be decorated with an icon — a fixed-sized picture. An icon is an object that adheres to the Icon interface. Swing provides a particularly useful implementation of the Icon interface: ImageIcon, which paints an icon from a GIF, JPEG, or PNG image.
So no go for BMP files, which aren't that platform independent anyway -- they're more of a WINDOWS artifact.
Feb 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ralph Freshour | last post by:
My .php app displays an image on the web page, I notice that different ..jpg images display "funny" - apparently they all have slightly different image widths and heights yet in the image tag I...
1
by: Stephen | last post by:
Hi, I am using an Access database (OLE Object) and storing Image as a bytes after streaming. I am able to read it back as a stream and display it on the browser using the following code:...
3
by: Irfan Akram | last post by:
Hi Guys, I am having problems displaying an image from the database, that alreday has been uoploaded successfully. The image loads in correctly, but by default it is displayed on the whole...
18
by: John | last post by:
Hi I am trying to display an image in a dialog using the following code; Dim frm As New frmImage Dim z As System.Drawing.Bitmap z.FromFile("c:\temp\image.gif") frm.picImage.Image = z...
3
by: CD | last post by:
An application is logging faxes sent in SQL2000 image column type. I have found code on the net but what it is doing is prompting to save to local which is fine for single page image. Not good...
2
by: sj | last post by:
I am just learning to use Tkinter and am having problems displaying image files. I am able to display an image using tutorials (such as http://www.daniweb.com/code/snippet296.html) But when I try...
0
by: everdearestsunita | last post by:
hi i have to display an image whose path is stored in database.i have a table in which i have stored id,description and path of image.when i search for the path of image against the id of image...
17
sumittyagi
by: sumittyagi | last post by:
Hi! everybody! I am facing one problem. How to get data from response, where content type is image/jpg ore image/gif. normally browser do it for us, when it encounters an image tag, it sends an...
6
by: Jeff | last post by:
hi asp.net 2.0 I have a image (.jpeg) stored in sql server 2005 and now I want to display it on a webpage. So I created a webpage (Image.aspx) which just writes the buffer data to the...
0
by: techbytes | last post by:
Iam trying to display a image(Blob) from oracle database to jsp page. Iam getting error in displaying the image. the error file is attached. It shows getOutputStream() has already been...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.