Re: Images in TabbedPane
"Paul Johnson" <[email protected]> Fri, 10 Sep 2004 15:34:41 -0500
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
Well, I am not sure if I was creating the images correctly, but this
is what i noticed stepping through the code.
The localizer in the ImageIconConverter was being set to null when it
was called with a list of icons.
When that happend it was sent directly to the catch.
-----------------------------
icon = new ImageIcon( localizer.getClassLoader().getResource(
attr.getValue() ) );
-----------------------------
So, this is what I did...I would rather not do this, but I am not sure
if this is a bug.
If the icon is in a list, then it will go into the catch and look for
it in your classpath.
Please let me know if this is a bug, or I just did not create teh tabs
correctly.
Thanks,
Paul Johnson
public static Object conv( final Class type, final Attribute attr,
Localizer localizer )
{
ImageIcon icon = null;
if (attr != null)
{
if (Parser.LOCALIZED_ATTRIBUTES.contains(
attr.getName().toLowerCase() ))
{
if (attr.getAttributeType() == Attribute.CDATA_TYPE)
{
attr.setValue( localizer.getString( attr.getValue() ) );
}
}
try
{
icon = new ImageIcon(
localizer.getClassLoader().getResource( attr.getValue() ) );
}
catch (Exception e)
{
java.net.URL imgURL = Converter.class.getResource(
"/"+attr.getValue() );
icon = new ImageIcon( imgURL );
}
}
return icon;
}
"Paul Johnson" <[email protected]> wrote in message
news:[email protected]...
> Hello again,
>
> I an trying to add images to a tabbedpane.
>
> This is what I have so far. The images are being shown on my buttons, and
> they are in the classpath.
> Am I doing something wrong? Also, can you specify the Titles as the panel
> gets added?
>
> Thanks in advance,
>
> Paul
>
> <tabbedpane id="tp_left" Titles="Tabs,Favorites,Search"
> Icons="chords.png,fav.png,find.png" ToolTipTexts="Guitar
> Tabs,Favorites,Search">
>
> <panel layout="borderlayout"
> constraints="BorderLayout.CENTER">
> <scrollpane>
> <tree name="tree"/>
> </scrollpane>
> </panel>
>
> <panel layout="borderlayout"
> constraints="BorderLayout.CENTER">
> <scrollpane>
> <tree name="tree" />
> </scrollpane>
> </panel>
>
> <panel layout="borderlayout"
> constraints="BorderLayout.CENTER">
> <scrollpane>
> <tree name="tree" />
> </scrollpane>
> </panel>
>
> </tabbedpane>