01: /*--------------------------------------------------------------------------*
02: | Copyright (C) 2006 Christopher Kohlhaas |
03: | |
04: | This program is free software; you can redistribute it and/or modify |
05: | it under the terms of the GNU General Public License as published by the |
06: | Free Software Foundation. A copy of the license has been included with |
07: | these distribution in the COPYING file, if not go to www.fsf.org |
08: | |
09: | As a special exception, you are granted the permissions to link this |
10: | program with every library, which license fulfills the Open Source |
11: | Definition as published by the Open Source Initiative (OSI). |
12: *--------------------------------------------------------------------------*/
13: package org.rapla.components.calendar.jdk14adapter;
14:
15: import java.awt.Component;
16: import java.awt.Container;
17: import java.util.Observable;
18:
19: /** This class functions as an adapter to JDK1.4 only objects. Under
20: JDK1.4 you can use the method AWTAdapterFactory.getFactory() to
21: get an implementation of the AWTAdaptorFactory. Under JDK<1.4
22: AWTAdapterFactory.getFactory() returns null.
23: */
24: public class AWTAdapterFactory {
25: // this must be the same as the package name for this class.
26: private static String PACKAGEPREFIX = "org.rapla.components.calendar.jdk14adapter";
27:
28: /** Creates a MouseWheelObservable for the specified component. When
29: the MouseWheel is moved all Observers will get notified. The value
30: passed to the observers is the result of MouseWheelEvent.getWheelRotation().*/
31: public Observable createMouseWheelObservable(Component component) {
32: return null;
33: };
34:
35: /** Creates a FocusAdapter for the specified component. */
36: public FocusAdapter createFocusAdapter(Container container) {
37: return null;
38: }
39:
40: private static boolean bFactoryInitialized = false;
41: private static AWTAdapterFactory factory = null;
42:
43: /** returns null if jdk <1.4 */
44: public static AWTAdapterFactory getFactory() {
45: try {
46: // Wheel support only works since JDK 1.4
47: if (factory == null && !bFactoryInitialized) {
48: bFactoryInitialized = true;
49: // Test if MouseWheelSupported
50: Class.forName("java.awt.event.MouseWheelListener");
51: Component.class
52: .getMethod("isFocusable", new Class[] {});
53:
54: factory = (AWTAdapterFactory) Class.forName(
55: PACKAGEPREFIX + ".AWTAdapterFactoryImpl")
56: .newInstance();
57: }
58: return factory;
59: } catch (Exception ex) {
60: return null;
61: }
62: }
63: }
|