For example, if, as shown in the following lines, I set the L&F to "Motif,"
and then subsequently seek to override the "DeskTopIconUI" entry in the
table with MetalDesktopIconUI, then, iterate through the values in the
table, the DesktopIconUI value is STILL
com.sun.java.swing.plaf.motif.MotifDesktopIconUI. Why does it no accept my
override to javax.swing.plaf.metal.MetalDesktopIconUI ? Thank you, Ike
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
UIManager.put("DesktopIconUI",
"javax.swing.plaf.metal.MetalDesktopIconUI");
UIDefaults def = UIManager.getLookAndFeelDefaults();
Enumeration enum = def.keys();
while (enum.hasMoreElements()) {
Object item = enum.nextElement();
System.out.println(item +" " + def.get(item));
}
If I understand what you're doing properly,
"com.sun.java.swing.plaf.motif.MotifDesktopIconUI" is actually a key.
So what you should do is something like:
UIManager.put("DesktopIconUI",
UIManager.get("com.sun.java.swing.plaf.motif.MotifDesktopIconUI"));
>
> UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
> UIManager.put("DesktopIconUI",
> "javax.swing.plaf.metal.MetalDesktopIconUI");
> UIDefaults def = UIManager.getLookAndFeelDefaults();
> Enumeration enum = def.keys();
> while (enum.hasMoreElements()) {
> Object item = enum.nextElement();
> System.out.println(item +" " + def.get(item));
> }
>
>
>
--
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
> If I understand what you're doing properly,
> "com.sun.java.swing.plaf.motif.MotifDesktopIconUI" is actually a key.
> So what you should do is something like:
>
> UIManager.put("DesktopIconUI",
> UIManager.get("com.sun.java.swing.plaf.motif.MotifDesktopIconUI"));
No, that's not it at all. I am trying to set the key DesktopIconUI to the
value "javax.swing.plaf.metal.MetalDesktopIconUI"
But when I terate through the keys, the value has remained unchanged even
after I explicitly set it. My question is why and how do I therefore set
it? -Ike
try following:
UIDefaults def = UIManager.getDefaults();
--
Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities
Thanks Andrey -- I suppose then what I want to do is to .put a default,
rather than a LookAndFeelDefaults. Is there a way to do this? The reason I
am asking is that later on in my application I am getting an exception with
the stack trace included below, even though I am explicitly setting
UIManager.put("DesktopIconUI",
"javax.swing.plaf.metal.MetalDesktopIconUI"); //Thanks - Ike
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)
this post looks interesting
http://forum.java.sun.com/thread.jspa?forumID=38&threadID=407514