Reflections on Tech. Life
Friday, August 29, 2003
 
This link: Forums - What are some of the UIManager keys for changing the java look and feel? is also related to Java Swing Look and Feel issues. I'm sure it will be a useful resource in the future. In case this link goes dead though, I'll lift the code example supplied. Full credit for it goes to Alex Burton of http://www.e-plus.com.au

public static void outputUIDefaults() {
// testing only
// Get the currently installed look and feel
UIDefaults uidefs = UIManager.getLookAndFeelDefaults();

// Retrieve the keys. Can't use an iterator since the map
// may be modified during the iteration. So retrieve all at once.
String[] keys = (String[] uidefs.keySet().toArray(new String[0];

for (int i = 0; i < keys.length; i++) {
Object v = uidefs.get(keys);
System.out.println(keys + " " + v.getClass() + ":" + v.toString());
if (v instanceof Integer) {
int intVal = uidefs.getInt(keys);
}
else if (v instanceof Boolean) {
boolean boolVal = uidefs.getBoolean(keys);
}
else if (v instanceof String) {
String strVal = uidefs.getString(keys);
}
else if (v instanceof Dimension) {
Dimension dimVal = uidefs.getDimension(keys);
}
else if (v instanceof Insets) {
Insets insetsVal = uidefs.getInsets(keys);
}
else if (v instanceof Color) {
Color colorVal = uidefs.getColor(keys);
}
else if (v instanceof Font) {
Font fontVal = uidefs.getFont(keys);
}
else if (v instanceof Border) {
Border borderVal = uidefs.getBorder(keys);
}
else if (v instanceof Icon) {
Icon iconVal = uidefs.getIcon(keys);
}
else if (v instanceof javax.swing.text.JTextComponent.KeyBinding[] {
javax.swing.text.JTextComponent.KeyBinding[] keyBindsVal = (
javax.swing.text.JTextComponent.KeyBinding[] uidefs.get(keys);
}
else if (v instanceof InputMap) {
InputMap imapVal = (InputMap) uidefs.get(keys);
}
else {
// Unknown type
}
}
}
 
Comments: Post a Comment
Observations about Technology by an Information Technology 20 yr Vet.

ARCHIVES
08/01/2003 - 09/01/2003 / 09/01/2003 - 10/01/2003 / 10/01/2003 - 11/01/2003 / 11/01/2003 - 12/01/2003 / 12/01/2003 - 01/01/2004 / 01/01/2004 - 02/01/2004 / 02/01/2004 - 03/01/2004 / 05/01/2004 - 06/01/2004 / 09/01/2004 - 10/01/2004 / 10/01/2004 - 11/01/2004 / 11/01/2004 - 12/01/2004 / 12/01/2004 - 01/01/2005 / 02/01/2005 - 03/01/2005 / 06/01/2005 - 07/01/2005 / 07/01/2005 - 08/01/2005 / 08/01/2005 - 09/01/2005 / 09/01/2005 - 10/01/2005 / 10/01/2005 - 11/01/2005 / 11/01/2005 - 12/01/2005 / 12/01/2005 - 01/01/2006 / 03/01/2006 - 04/01/2006 / 04/01/2006 - 05/01/2006 / 06/01/2006 - 07/01/2006 / 08/01/2006 - 09/01/2006 / 01/01/2007 - 02/01/2007 /


Powered by Blogger