Article View: borland.public.jbuilder.java.swing
Article #1163Problem getting an image to dispaly in JLabel
From: Ted Byers
Date: Fri, 19 Mar 2004 21:01
Date: Fri, 19 Mar 2004 21:01
34 lines
2069 bytes
2069 bytes
Here is the initialization code for the applet.:
//Component initialization
private void jbInit() throws Exception {
component1 = Box.createGlue();
jLabel1.setDebugGraphicsOptions(0);
jLabel1.setMinimumSize(new Dimension(700, 500));
jLabel1.setIconTextGap(4);
jLabel1.setText("");
Icon icon = new ImageIcon( "sunset.jpg" );
jLabel1.setIcon(icon);
xYLayout1.setWidth(800);
xYLayout1.setHeight(600);
this.setLayout(xYLayout1);
this.add(jLabel1, new XYConstraints(17, 23, 753, 548));
}
Although I added several jpeg and gif files to the project, and they appear
in the dropdown list for the icon of jLabel1, selecting one of them does
virtually nothing. So I added two lines of code:
Icon icon = new ImageIcon( "sunset.jpg" );
jLabel1.setIcon(icon);
Still no joy. It seems that no matter what I try, I can't get these images
to display within the applet. (NB: When the project is done, the image will
need to go into the same jar as the applet.)
What do I need to do to get this working (both from within JBuilder
9(personal) and from within a jar)?
Thanks,
Ted
Technical Details
Message-ID:
<405b5ea9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,f4a0c6583761a428,start X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2004-03-19 13:11:20 PST From: "Ted Byers" <r.ted.byers@sympatico.ca> Newsgroups: borland.public.jbuilder.java.swing Subject: Problem getting an image to dispaly in JLabel Date: Fri, 19 Mar 2004 16:01:15 -0500 Lines: 36 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 65.95.240.180 Message-ID: <405b5ea9$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1079729833 65.95.240.180 (19 Mar 2004 12:57:13 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail