2
2
3
3
import java .awt .*;
4
4
import java .io .IOException ;
5
+ import java .util .logging .Level ;
5
6
import java .util .logging .Logger ;
6
7
7
8
/**
@@ -32,21 +33,19 @@ public static DefaultInputConfiguration configure() {
32
33
/**
33
34
* Initializes the input device provider with the default platform library.
34
35
*
35
- * @return The initialized input device provider.
36
- * @throws IOException if the input device provider cannot be initialized.
36
+ * @return The initialized input device provider or null if the initialization fails.
37
37
*/
38
- public static InputDevicePlugin init () throws IOException {
38
+ public static InputDevicePlugin init () {
39
39
return init (null , InputLibrary .PLATFORM_DEFAULT );
40
40
}
41
41
42
42
/**
43
43
* Initializes the input device provider with the default platform library and the specified owner.
44
44
*
45
45
* @param owner The owner to be passed to individual plugins, or null if running in background.
46
- * @return The initialized input device provider.
47
- * @throws IOException if the input device provider cannot be initialized.
46
+ * @return The initialized input device provider or null if the initialization fails.
48
47
*/
49
- public static InputDevicePlugin init (Frame owner ) throws IOException {
48
+ public static InputDevicePlugin init (Frame owner ) {
50
49
return init (owner , InputLibrary .PLATFORM_DEFAULT );
51
50
}
52
51
@@ -56,10 +55,9 @@ public static InputDevicePlugin init(Frame owner) throws IOException {
56
55
* Note: Some controllers don't support background mode which is why it can be necessary to pass a frame owner to the {@link InputDevices#init(Frame, String)} method.
57
56
*
58
57
* @param library The library to be used.
59
- * @return The initialized input device provider.
60
- * @throws IOException if the input device provider cannot be initialized.
58
+ * @return The initialized input device provider or null if the initialization fails.
61
59
*/
62
- public static InputDevicePlugin init (InputLibrary library ) throws IOException {
60
+ public static InputDevicePlugin init (InputLibrary library ) {
63
61
return init (null , library );
64
62
}
65
63
@@ -69,10 +67,9 @@ public static InputDevicePlugin init(InputLibrary library) throws IOException {
69
67
* Note: Some controllers don't support background mode which is why it can be necessary to pass a frame owner to the {@link InputDevices#init(Frame, String)} method.
70
68
*
71
69
* @param inputPluginClass The input plugin class to be used.
72
- * @return The initialized input device provider.
73
- * @throws IOException if the input device provider cannot be initialized.
70
+ * @return The initialized input device provider or null if the initialization fails.
74
71
*/
75
- public static InputDevicePlugin init (String inputPluginClass ) throws IOException {
72
+ public static InputDevicePlugin init (String inputPluginClass ) {
76
73
return init (null , inputPluginClass );
77
74
}
78
75
@@ -81,10 +78,9 @@ public static InputDevicePlugin init(String inputPluginClass) throws IOException
81
78
*
82
79
* @param owner The owner to be passed to individual plugins, or null if running in background.
83
80
* @param library The input library to be used.
84
- * @return The initialized input device provider.
85
- * @throws IOException if the input device provider cannot be initialized.
81
+ * @return The initialized input device provider or null if the initialization fails.
86
82
*/
87
- public static InputDevicePlugin init (Frame owner , InputLibrary library ) throws IOException {
83
+ public static InputDevicePlugin init (Frame owner , InputLibrary library ) {
88
84
return init (owner , library .getPlugin ());
89
85
}
90
86
@@ -99,10 +95,9 @@ public static InputDevicePlugin init(Frame owner, InputLibrary library) throws I
99
95
* If the class is not found or cannot be instantiated, an {@link IOException} is thrown.
100
96
* The class must have a public no-argument constructor.
101
97
* </p>
102
- * @return The initialized input device provider.
103
- * @throws IOException if the input device provider cannot be initialized.
98
+ * @return The initialized input device provider or null if the initialization fails.
104
99
*/
105
- public static InputDevicePlugin init (Frame owner , String inputPluginClass ) throws IOException {
100
+ public static InputDevicePlugin init (Frame owner , String inputPluginClass ) {
106
101
try {
107
102
if (inputPluginClass == null ) {
108
103
inputPluginClass = InputLibrary .PLATFORM_DEFAULT .getPlugin ();
@@ -114,7 +109,8 @@ public static InputDevicePlugin init(Frame owner, String inputPluginClass) throw
114
109
provider .internalInitDevices (owner );
115
110
return provider ;
116
111
} catch (Exception e ) {
117
- throw new IOException ("Could not initialize input device provider: " + e .getMessage (), e );
112
+ log .log (Level .SEVERE , "Could not initialize input device provider: " + e .getMessage (), e );
113
+ return null ;
118
114
}
119
115
}
120
116
0 commit comments