Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2006

Tip: Looking for answers? Try searching our database.

UIDefaults.getUI() failed for JInternalFrame$JDesktopIcon

Thread view: 
Ike - 27 Jan 2006 17:49 GMT
I am using a particular Look and Feel, and a class derived from
JInternalFrame. Whenever the JInternalFrame class is invoked, it generated
an exception (please see stack trace at the bottom of this message).

I know that to correct this exception, I must do something along the lines
of the following:

UIManager.put(XXX, YYY);// Where XXX is the String used to identify the
JInternalFrame$JDesktopIcon's UIand YYY the ui class for it.

However, I do not know how to go about discerning the values for XXX and
YYY. How can I find those out? I have tried:
UIManager.getLookAndFeelDefaults().put("ClassLoader",
getClass().getClassLoader());
UIManager.put("JDesktopIcon",
javax.swing.JInternalFrame.JDesktopIcon.class.getName());
UIManager.put("JInternalFrame",
javax.swing.JInternalFrame.class.getName());
updateUI();

With no luck at al. Can someone please help me to find out what parameters I
need to pass here? Thanks, Ike

--------stack trace-----------------------
UIDefaults.getUI() failed: no ComponentUI class for:
javax.swing.JInternalFrame$JDesktopIcon[,0,0,0x0,invalid,hidden,alignmentX=0
.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=]
java.lang.Error
at javax.swing.UIDefaults.getUIError(Unknown Source)
at javax.swing.MultiUIDefaults.getUIError(Unknown Source)
at javax.swing.UIDefaults.getUI(Unknown Source)
at javax.swing.UIManager.getUI(Unknown Source)
at javax.swing.JInternalFrame$JDesktopIcon.updateUI(Unknown Source)
at javax.swing.JInternalFrame$JDesktopIcon.<init>(Unknown Source)
at javax.swing.JInternalFrame.<init>(Unknown Source)
at RalphVince.Controls.JScrollableDesktopPane.BaseInternalFrame.<init>()
Vova Reznik - 27 Jan 2006 18:47 GMT
> I am using a particular Look and Feel, and a class derived from
> JInternalFrame. Whenever the JInternalFrame class is invoked, it generated
[quoted text clipped - 8 lines]
> However, I do not know how to go about discerning the values for XXX and
> YYY. How can I find those out? I have tried:

For MetalLookAndFeel:
DesktopIconUI    javax.swing.plaf.metal.MetalDesktopIconUI
Ike - 28 Jan 2006 01:57 GMT
Vova,

But how can you find that out ? Is there a way programatically to do so?
Shouldn;t there be any iterator of some sort to iterate through these values
? -Ike
Arnaud BERGER - 28 Jan 2006 16:23 GMT
Hi Ike,

Well, usually you don't have to do those things yourself, the "installation"
of a L&F does it for you.

But in your case, it clearly seems that your L&F doesn't provide anything
for this component, so you will have to do this part yourself.

In what you've already tried, you did specify names of classes that actually
are not "DesktopIconUI" classes .

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/plaf/DesktopIconUI.html

Indeed, UIManager.put expects a valid "ComponentUI" class, and more
specifically, a "DesktopIconUI" class in your case.

Look at the javadoc link provided, you will see examples of subclasses of
DesktopIconUI

BasicDesktopIconUI for instance, and you will see that MetalDesktopIconUI
inherits from this one) that are provided in the JRE, and that you may use.

If you want to know which UI is used with the default L&F, just print the
result of UIManager.get("JDesktopIcon") .

Cheers.

Arnaud

> Vova,
>
> But how can you find that out ? Is there a way programatically to do so?
> Shouldn;t there be any iterator of some sort to iterate through these values
> ? -Ike
Ike - 29 Jan 2006 02:35 GMT
So would I specify this, then, as:

UIManager.put("JDesktopIcon",
javax.swing.plaf.metal.MetalDesktopIconUI.class.getName());

or:

UIManager.put("JDesktopIcon",
"javax.swing.plaf.metal.MetalDesktopIconUI");

And would I specify this in the contructor of my JInternalFrame? Thank You,
Ike
Arnaud B. - 30 Jan 2006 06:59 GMT
Both would yield the same, but you ought to do this prior to instanciate any
JInternalFrame.

Try it in your main method.

Arnaud

> So would I specify this, then, as:
>
[quoted text clipped - 8 lines]
> And would I specify this in the contructor of my JInternalFrame? Thank You,
> Ike
Ike - 30 Jan 2006 14:03 GMT
Arnaud,

My JInternalFrame is in an Applet. I am doing it in the Applet.start() which
is called after .init() which is called after it is created, as such:

UIManager.setLookAndFeel("com.l2fprod.gui.plaf.skin.SkinLookAndFeel");
                   UIManager.put("DesktopIconUI",
"javax.swing.plaf.metal.MetalDesktopIconUI");

If I immediately do

System.out.println(UIManager.get("DesktopIconUI"));

It prints out

javax.swing.plaf.metal.MetalDesktopIconUI

HOWEVER, If I then do it in the constructor of my JInternal Frame (which is
NOT created when the applet is instantiated, rather, is only created later
when the user calls for it), this is no longer the value. Any ideas why that
may be the case -- I am not changing anything in UIManager after the two
lines in .start();

-Ike
Vova Reznik - 30 Jan 2006 15:03 GMT
> Vova,
>
> But how can you find that out ? Is there a way programatically to do so?
> Shouldn;t there be any iterator of some sort to iterate through these values
> ? -Ike

UIDefaults defaultHashtable = UIManager.getLookAndFeelDefaults();
(UIDefaults is sub of Hashtable)
This map will contain pairs like:
DesktopIconUI    javax.swing.plaf.metal.MetalDesktopIconUI
or
List.timeFactor    1000


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.