Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

UIDefaults.put() issue

7 views
Skip to first unread message

Ike

unread,
Jan 31, 2006, 3:16:26 PM1/31/06
to
For whatever reason, I am unable to alter the value in the UIManager
LookAndFeelDefaults table. I must be doing something stupid, and would
appreciate any direction here.

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));
}

Monique Y. Mudama

unread,
Jan 31, 2006, 3:32:29 PM1/31/06
to
On 2006-01-31, Ike penned:

> For whatever reason, I am unable to alter the value in the UIManager
> LookAndFeelDefaults table. I must be doing something stupid, and would
> appreciate any direction here.
>
> 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
>

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

Ike

unread,
Jan 31, 2006, 3:52:34 PM1/31/06
to

"Monique Y. Mudama" <sp...@bounceswoosh.org> wrote in message
news:slrndtvia...@home.bounceswoosh.org...

> 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


Andrey Kuznetsov

unread,
Jan 31, 2006, 6:23:22 PM1/31/06
to
> For whatever reason, I am unable to alter the value in the UIManager
> LookAndFeelDefaults table. I must be doing something stupid, and would
> appreciate any direction here.

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


Ike

unread,
Jan 31, 2006, 10:06:25 PM1/31/06
to

"Andrey Kuznetsov" <sp...@imagero.com.invalid> wrote in message
news:drorgr$3k1$1...@online.de...

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)


Michael Dunn

unread,
Feb 1, 2006, 2:52:54 AM2/1/06
to

"Ike" <r...@hotmail.com> wrote in message
news:RAVDf.9782$vU2....@newsread3.news.atl.earthlink.net...


this post looks interesting

http://forum.java.sun.com/thread.jspa?forumID=38&threadID=407514


0 new messages