/[classpath]/classpath/javax/swing/UIManager.java
ViewVC logotype

Diff of /classpath/javax/swing/UIManager.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by brawer, Thu Jun 19 07:02:52 2003 UTC revision 1.8 by mkoch, Wed Jul 2 05:21:52 2003 UTC
# Line 50  import javax.swing.plaf.metal.MetalLookA Line 50  import javax.swing.plaf.metal.MetalLookA
50    
51  public class UIManager implements Serializable  public class UIManager implements Serializable
52  {  {
53    static final long serialVersionUID = -5547433830339189365L;    public static class LookAndFeelInfo
54      {
55      static class LookAndFeelInfo      String name, clazz;
     {  
         String name, clazz;  
56                    
57          LookAndFeelInfo(String name,      LookAndFeelInfo(String name,
58                          String clazz)                      String clazz)
59          {      {
60              this.name  = name;        this.name  = name;
61              this.clazz = clazz;        this.clazz = clazz;
         }  
         String getName()      { return name;  }  
         String getClassName() { return clazz; }  
62      }      }
63    
64            String getName()      { return name;  }
65      static LookAndFeelInfo [] installed = {      String getClassName() { return clazz; }
66          new LookAndFeelInfo("Metal",    }
                             "javax.swing.plaf.metal.MetalLookAndFeel")  
     };  
67    
68      private static final long serialVersionUID = -5547433830339189365L;
69    
70      static LookAndFeelInfo [] installed = {
71        new LookAndFeelInfo ("Metal", "javax.swing.plaf.metal.MetalLookAndFeel")
72      };
73    
74      static LookAndFeel[] aux_installed;
75      
76      static LookAndFeel look_and_feel = new MetalLookAndFeel();
77            
78      static LookAndFeel[] aux_installed;    public UIManager()
79          {
80      static LookAndFeel look_and_feel  = new MetalLookAndFeel();      // Do nothing here.
81          }
82    
83      UIManager()    public static void addPropertyChangeListener (PropertyChangeListener listener)
84      {    {
85      }      // FIXME
86      }
87    
88      public static  void addPropertyChangeListener(PropertyChangeListener listener)    public static void removePropertyChangeListener (PropertyChangeListener listener)
89      {      // Remove a PropertyChangeListener from the listener list.
90          //      Add a PropertyChangeListener to the listener list.    {
91      }      // FIXME
92      }
93    
94      public static  void addAuxiliaryLookAndFeel(LookAndFeel l)    /**
95      {     * @since 1.4
96          //          Add a LookAndFeel to the list of auxiliary look and feels.     */
97          if (aux_installed == null)    public static PropertyChangeListener[] getPropertyChangeListeners ()
98              {    {
99                  aux_installed = new LookAndFeel[1];      // FIXME
100                  aux_installed[0] = l;      throw new Error ("Not implemented");
101                  return;    }
102              }  
103      public static void addAuxiliaryLookAndFeel (LookAndFeel l)
104      {
105        // Add a LookAndFeel to the list of auxiliary look and feels.
106        if (aux_installed == null)
107          {
108            aux_installed = new LookAndFeel[1];
109            aux_installed[0] = l;
110            return;
111          }
112                    
113          LookAndFeel[] T = new LookAndFeel[ aux_installed.length+1 ];      LookAndFeel[] T = new LookAndFeel[ aux_installed.length+1 ];
114          System.arraycopy(aux_installed, 0,      System.arraycopy(aux_installed, 0, T, 0, aux_installed.length);                      
115                           T,             0,      aux_installed = T;
116                           aux_installed.length);                        aux_installed[aux_installed.length-1] = l;
117          aux_installed = T;    }
         aux_installed[aux_installed.length-1] = l;  
     }  
118            
119      public static  boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)    public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)
120      {    {
121          if (aux_installed == null)      if (aux_installed == null)
122              return false;        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;  
     }  
123    
124      public static  LookAndFeel[] getAuxiliaryLookAndFeels()      for (int i=0;i<aux_installed.length;i++)
125      {   return aux_installed;    }        {
126            if (aux_installed[i] == laf)
127              {
128                aux_installed[ i ] = aux_installed[aux_installed.length-1];
129                LookAndFeel[] T = new LookAndFeel[ aux_installed.length-1 ];
130                System.arraycopy (aux_installed, 0, T, 0, aux_installed.length-1);
131                aux_installed = T;
132                return true;
133              }            
134          }
135        return false;
136      }
137    
138      public static  LookAndFeel[] getAuxiliaryLookAndFeels()
139      {     return aux_installed;    }
140    
141      public static  Object get(Object key)    public static  Object get(Object key)
142      {   return getLookAndFeel().getDefaults().get(key);    }    {     return getLookAndFeel().getDefaults().get(key);    }
143            
144      /**    /**
145       * Returns a border from the defaults table.     * Returns a border from the defaults table.
146       */     */
147      public static  Border getBorder(Object key)    public static Border getBorder(Object key)
148      {    {
149          return (Border) getLookAndFeel().getDefaults().get(key);      return (Border) getLookAndFeel().getDefaults().get(key);
150      }    }
151            
152      /**    /**
153       * Returns a drawing color from the defaults table.     * Returns a drawing color from the defaults table.
154       */     */
155      public static  Color getColor(Object key)    public static  Color getColor(Object key)
156      {    {
157          return (Color) getLookAndFeel().getDefaults().get(key);      return (Color) getLookAndFeel().getDefaults().get(key);
158      }    }
   
     /**  
      * this string can be passed to Class.forName()  
      */  
     public static  String getCrossPlatformLookAndFeelClassName()  
     {    
         return "javax.swing.plaf.metal.MetalLookAndFeel";  
     }  
159    
160      /**    /**
161       * Returns the default values for this look and feel.     * this string can be passed to Class.forName()
162       */     */
163      static  UIDefaults getDefaults()    public static  String getCrossPlatformLookAndFeelClassName()
164      {    {    
165          return getLookAndFeel().getDefaults();      return "javax.swing.plaf.metal.MetalLookAndFeel";
166      }    }
167    
168      /**    /**
169       * Returns a dimension from the defaults table.     * Returns the default values for this look and feel.
170       */     */
171      static  Dimension getDimension(Object key)    static  UIDefaults getDefaults()
172      {    {
173          System.out.println("UIManager.getDim");      return getLookAndFeel().getDefaults();
174          return new Dimension(200,100);    }
     }  
175    
176      /**
177       * Returns a dimension from the defaults table.
178       */
179      static  Dimension getDimension(Object key)
180      {
181        System.out.println("UIManager.getDim");
182        return new Dimension(200,100);
183      }
184    
185    /**    /**
186     * Retrieves a font from the defaults table of the current     * Retrieves a font from the defaults table of the current
# Line 189  public class UIManager implements Serial Line 195  public class UIManager implements Serial
195      return (Font) getLookAndFeel().getDefaults().get(key);      return (Font) getLookAndFeel().getDefaults().get(key);
196    }    }
197    
198      static  Icon getIcon(Object key)    static Icon getIcon(Object key)
199      //      Returns an Icon from the defaults table.      // Returns an Icon from the defaults table.
200      {    {
201          return (Icon) getLookAndFeel().getDefaults().get(key);      return (Icon) getLookAndFeel().getDefaults().get(key);
202      }    }
203      static  Insets getInsets(Object key)    
204      //      Returns an Insets object from the defaults table.    static Insets getInsets(Object key)
205      {      // Returns an Insets object from the defaults table.
206          return (Insets) getLookAndFeel().getDefaults().getInsets(key);    {
207      }      return (Insets) getLookAndFeel().getDefaults().getInsets(key);
208      }
209    
210      static LookAndFeelInfo[] getInstalledLookAndFeels()    static LookAndFeelInfo[] getInstalledLookAndFeels()
211      {    {
212          return installed;      return installed;
213      }    }
214    
215      static  int getInt(Object key)    static  int getInt(Object key)
216      {    {
217          Integer x = (Integer) getLookAndFeel().getDefaults().get(key);      Integer x = (Integer) getLookAndFeel().getDefaults().get(key);
218          if (x == null)      if (x == null)
219              return 0;        return 0;
220          return x.intValue();      return x.intValue();
221      }    }
     static  LookAndFeel getLookAndFeel()  
     {  
         return look_and_feel;  
     }  
222    
223      static  LookAndFeel getLookAndFeel()
224      {
225        return look_and_feel;
226      }
227    
228    /**    /**
229     * Returns the <code>UIDefaults</code> table of the currently active     * Returns the <code>UIDefaults</code> table of the currently active
# Line 227  public class UIManager implements Serial Line 234  public class UIManager implements Serial
234      return getLookAndFeel().getDefaults();      return getLookAndFeel().getDefaults();
235    }    }
236    
237      static String getString(Object key)
238        // Returns a string from the defaults table.
239      {
240        return (String) getLookAndFeel().getDefaults().get(key);
241      }
242      
243      static String getSystemLookAndFeelClassName()
244        // Returns the name of the LookAndFeel class that implements the native systems look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.
245      {
246        return getCrossPlatformLookAndFeelClassName();
247      }
248    
249      static  String getString(Object key)    public static ComponentUI getUI(JComponent target)
250      //      Returns a string from the defaults table.      // Returns the L&F object that renders the target component.
251      {    {
252          return (String) getLookAndFeel().getDefaults().get(key);      ComponentUI ui = getDefaults().getUI(target);
253      }      //System.out.println("GET-UI-> " + ui + ", for " + target);
254      static  String getSystemLookAndFeelClassName()      return ui;
255      //      Returns the name of the LookAndFeel class that implements the native systems look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.    }
     {  
         return getCrossPlatformLookAndFeelClassName();  
     }  
256    
257      public static void installLookAndFeel(String name, String className)
258        // Creates a new look and feel and adds it to the current array.
259      {
260      }
261    
262      public static  ComponentUI getUI(JComponent target)    public static void installLookAndFeel(LookAndFeelInfo info)
263      //      Returns the L&F object that renders the target component.      // Adds the specified look and feel to the current array and then calls setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]).
264      {    {
265          ComponentUI ui = getDefaults().getUI(target);    }
         //System.out.println("GET-UI-> " + ui + ", for " + target);  
         return ui;  
     }  
266    
267      public static Object put(Object key, Object value)
268        // Stores an object in the defaults table.
269      {
270        return getLookAndFeel().getDefaults().put(key,value);
271      }
272    
273      public static  void installLookAndFeel(String name, String className)    public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
274      //      Creates a new look and feel and adds it to the current array.      // Replaces the current array of installed LookAndFeelInfos.
275      {    {
276      }    }
277      public static  void installLookAndFeel(LookAndFeelInfo info)    
278      //      Adds the specified look and feel to the current array and then calls setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]).    public static void setLookAndFeel(LookAndFeel newLookAndFeel)
279      {    {
280      }      if (look_and_feel != null)
281      public static  Object put(Object key, Object value)        look_and_feel.uninitialize();
     //      Stores an object in the defaults table.  
     {  
         return getLookAndFeel().getDefaults().put(key,value);  
     }  
     public static  void removePropertyChangeListener(PropertyChangeListener listener)  
     //      Remove a PropertyChangeListener from the listener list.  
     {  
     }  
     public static  void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)  
     //      Replaces the current array of installed LookAndFeelInfos.  
     {  
     }  
     public static  void setLookAndFeel(LookAndFeel newLookAndFeel)  
     {  
         if (look_and_feel != null)  
             look_and_feel.uninitialize();  
282    
283          //      Set the current default look and feel using a LookAndFeel object.      // Set the current default look and feel using a LookAndFeel object.
284          look_and_feel = newLookAndFeel;      look_and_feel = newLookAndFeel;
285          look_and_feel.initialize();      look_and_feel.initialize();
286                    
287          //      revalidate();      //revalidate();
288          //      repaint();      //repaint();
289      }    }
   
     public static  void setLookAndFeel(String className)  
         throws ClassNotFoundException,  
                InstantiationException,  
                IllegalAccessException,  
                UnsupportedLookAndFeelException  
     {  
         //          Set the current default look and feel using a class name.  
         Class c = Class.forName(className);  
         LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception  
         setLookAndFeel(a);  
     }  
   
290    
291      public static void setLookAndFeel (String className)
292        throws ClassNotFoundException, InstantiationException, IllegalAccessException,
293        UnsupportedLookAndFeelException
294      {
295        //          Set the current default look and feel using a class name.
296        Class c = Class.forName(className);
297        LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception
298        setLookAndFeel(a);
299      }
300  }  }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26