package javax.swing;
import java.io.*;
import java.awt.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import java.beans.*;
public class UIManager implements Serializable
{
static class LookAndFeelInfo
{
String name, clazz;
LookAndFeelInfo(String name,
String clazz)
{
this.name = name;
this.clazz = clazz;
}
String getName() { return name; }
String getClassName() { return clazz; }
}
static LookAndFeelInfo [] installed = {
new LookAndFeelInfo("Metal",
"javax.swing.plaf.metal.MetalLookAndFeel")
};
static LookAndFeel[] aux_installed;
static LookAndFeel look_and_feel = new MetalLookAndFeel();
UIManager()
{
}
public static void addPropertyChangeListener(PropertyChangeListener listener)
{
}
public static void addAuxiliaryLookAndFeel(LookAndFeel l)
{
if (aux_installed == null)
{
aux_installed = new LookAndFeel[1];
aux_installed[0] = l;
return;
}
LookAndFeel[] T = new LookAndFeel[ aux_installed.length+1 ];
System.arraycopy(aux_installed, 0,
T, 0,
aux_installed.length);
aux_installed = T;
aux_installed[aux_installed.length-1] = l;
}
public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)
{
if (aux_installed == null)
return false;
for (int i=0;i<aux_installed.length;i++)
{
if (aux_installed[i] == laf)
{
aux_installed[ i ] = aux_installed[aux_installed.length-1];
LookAndFeel[] T = new LookAndFeel[ aux_installed.length-1 ];
System.arraycopy(aux_installed, 0,
T, 0,
aux_installed.length-1);
aux_installed = T;
return true;
}
}
return false;
}
public static LookAndFeel[] getAuxiliaryLookAndFeels()
{ return aux_installed; }
public static Object get(Object key)
{ return getLookAndFeel().getDefaults().get(key); }
public static Border getBorder(Object key)
{
return (Border) getLookAndFeel().getDefaults().get(key);
}
public static Color getColor(Object key)
{
return (Color) getLookAndFeel().getDefaults().get(key);
}
public static String getCrossPlatformLookAndFeelClassName()
{
return "javax.swing.plaf.metal.MetalLookAndFeel";
}
static UIDefaults getDefaults()
{
return getLookAndFeel().getDefaults();
}
static Dimension getDimension(Object key)
{
System.out.println("UIManager.getDim");
return new Dimension(200,100);
}
static Font getFont(Object key)
{
return (Font) getLookAndFeel().getDefaults().get(key);
}
static Icon getIcon(Object key)
{
return (Icon) getLookAndFeel().getDefaults().get(key);
}
static Insets getInsets(Object key)
{
return (Insets) getLookAndFeel().getDefaults().getInsets(key);
}
static LookAndFeelInfo[] getInstalledLookAndFeels()
{
return installed;
}
static int getInt(Object key)
{
Integer x = (Integer) getLookAndFeel().getDefaults().get(key);
if (x == null)
return 0;
return x.intValue();
}
static LookAndFeel getLookAndFeel()
{
return look_and_feel;
}
static UIDefaults getLookAndFeelDefaults()
{
return getLookAndFeel().getDefaults();
}
static String getString(Object key)
{
return (String) getLookAndFeel().getDefaults().get(key);
}
static String getSystemLookAndFeelClassName()
{
return getCrossPlatformLookAndFeelClassName();
}
public static ComponentUI getUI(JComponent target)
{
ComponentUI ui = getDefaults().getUI(target);
return ui;
}
public static void installLookAndFeel(String name, String className)
{
}
public static void installLookAndFeel(LookAndFeelInfo info)
{
}
public static Object put(Object key, Object value)
{
return getLookAndFeel().getDefaults().put(key,value);
}
public static void removePropertyChangeListener(PropertyChangeListener listener)
{
}
public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
{
}
public static void setLookAndFeel(LookAndFeel newLookAndFeel)
{
if (look_and_feel != null)
look_and_feel.uninitialize();
look_and_feel = newLookAndFeel;
look_and_feel.initialize();
}
public static void setLookAndFeel(String className)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException,
UnsupportedLookAndFeelException
{
Class c = Class.forName(className);
LookAndFeel a = (LookAndFeel) c.newInstance(); setLookAndFeel(a);
}
}