Article View: borland.public.jbuilder.java.swing
Article #491Button/Icon problem
From: Bodhi
Date: Tue, 19 Jul 2005 10:59
Date: Tue, 19 Jul 2005 10:59
57 lines
2349 bytes
2349 bytes
Hi,
I've been trying to solve my problem for days now, but with no luck. I'm new
to Swing programming, but as far as I can tell, my code should be ok. (See
below).
The problem is that I'm trying to create a button with an icon, but every
time I end up with a button without an icon. I've added the image in the
project view (it's also physically located in the same directory as the java
file) and double clicking the icon name shows the image in JBuilder. So as
far as I understand, there should not be a "path" or location problem.
Running the getImageLoadStatus() method returns a code 4, which to my
understanding indicates a loading problem.
If anyone can give me a clue of how to solve my problem, it would be greatly
appreciated.
Sincerely,
B.
package icons;
import javax.swing.*;
public class Icons extends JFrame {
ImageIcon icon = new ImageIcon("3dman.gif");
JButton button = new JButton(icon);
JPanel pane = new JPanel();
public Icons() {
setSize(400, 300);
setTitle("Icon Test Frame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//System.out.println(icon.getImageLoadStatus());
pane.add(button);
setContentPane(pane);
show();
}
public static void main(String[] arguments) {
Icons ike = new Icons();
}
}
Technical Details
Message-ID:
<42dcdd58$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!217.73.144.45.MISMATCH!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!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-Thread: 111d45,35ae0302d2702117,start X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Bodhi" <mmmm@hotmail.com> From: "Bodhi" <mmmm@hotmail.com> Newsgroups: borland.public.jbuilder.java.swing Subject: Button/Icon problem Date: Tue, 19 Jul 2005 13:59:51 +0300 Lines: 59 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 193.185.137.242 Message-ID: <42dcdd58$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1121770840 193.185.137.242 (19 Jul 2005 04:00:40 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!217.73.144.45.MISMATCH!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail