Article View: borland.public.jbuilder.java.swing
Article #13279Re: Problem with JButton and Icons
From: Greg Hamer
Date: Tue, 18 Aug 1998 00:00
Date: Tue, 18 Aug 1998 00:00
47 lines
2408 bytes
2408 bytes
The designer does not handle the Icon property in version 2.0 There are no
real workarounds.(Actually, I think that if the image file and the class
under design can be found on the IdeClasspath as defined in
bin\jbuilder.ini, then
ImageIcon icon1;
.
.
.
private void jbInit() throws Exception {
icon1 = new ImageIcon(this.getClass().getResource("the.gif"));
widget.setIcon(icon1);
will work. Note that the automatic bean reloading feature of the designer,
where the new versions of recently compiled classes get automatically used
by the designer, does not work when the class is found on the IdeClasspath )
Actually setting the property by hand will often result in a null pointer
exception in the designer when trying to paint the component that the icon
was set for. Until the fixes get released, I suggest placing the setIcon
property settings in the constructor, after the call to jbInit the way that
the Application wizard generated code does when the swing toolbar is
included.
jdutton wrote:
> I have the following problem:
>
> When I define a JButton component with the designer tool and go to the
> Icon property of the Inspector I get a combo box with no items. If I
> define myself an Icon object in the source code of my application and go
>
> back to the Inspector, when I click the combo box of the Icon property n
> I get the <none> item as above and the name of my newly created Icon
> object but there's no way to select this item and this field always
> stays in blank...
> I found that the only way for me to add an Icon to a JButton is doing it
>
> by myself, even there the icon does not appear on my design screen, only
>
> when I run my application.
>
> How do I populate the combo box for such Icon property?
> Is there a repository or something like this to do it?
>
> Many thanks
>
> JORGE
Technical Details
Message-ID:
<35DA10BC.7390B31B@inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35D177CD.A26918B@cgspain.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,678ca93472729773 X-Google-Attributes: gid111d45,public From: Greg Hamer <ghamer@inprise.com> Subject: Re: Problem with JButton and Icons Date: 1998/08/18 Message-ID: <35DA10BC.7390B31B@inprise.com> X-Deja-AN: 382457915 Content-Transfer-Encoding: 7bit References: <35D177CD.A26918B@cgspain.net> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing