13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.awt; 27 28 import java.awt.*; 29 import java.awt.dnd.*; 30 import java.awt.dnd.peer.DragSourceContextPeer; 31 import java.awt.event.*; 32 import java.awt.im.InputMethodHighlight; 33 import java.awt.im.spi.InputMethodDescriptor; 34 import java.awt.image.*; 35 import java.awt.datatransfer.Clipboard; 36 import java.awt.peer.*; 37 import java.beans.PropertyChangeListener; 38 import java.lang.reflect.Constructor; 39 import java.lang.reflect.InvocationTargetException; 40 import java.net.URL; 41 import java.util.Map; 42 import java.util.Properties; 43 import sun.awt.im.InputContext; 44 import sun.awt.image.ImageRepresentation; 45 46 public class HeadlessToolkit extends Toolkit 47 implements ComponentFactory, KeyboardFocusManagerPeerProvider { 48 49 private Toolkit tk; 50 private ComponentFactory componentFactory; 51 52 public HeadlessToolkit(Toolkit tk) { 53 this.tk = tk; 54 if (tk instanceof ComponentFactory) { 55 componentFactory = (ComponentFactory)tk; 56 } 57 } 58 59 public Toolkit getUnderlyingToolkit() { 60 return tk; 61 } 62 63 /* 64 * Component peer objects. 65 */ 66 67 /* Lightweight implementation of Canvas and Panel */ 68 162 throws HeadlessException { 163 throw new HeadlessException(); 164 } 165 166 public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) 167 throws HeadlessException { 168 throw new HeadlessException(); 169 } 170 171 public DragSourceContextPeer createDragSourceContextPeer( 172 DragGestureEvent dge) 173 throws InvalidDnDOperationException { 174 throw new InvalidDnDOperationException("Headless environment"); 175 } 176 177 public RobotPeer createRobot(Robot target, GraphicsDevice screen) 178 throws AWTException, HeadlessException { 179 throw new HeadlessException(); 180 } 181 182 public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) { 183 // See 6833019. 184 return 185 new KeyboardFocusManagerPeer() { 186 public Window getCurrentFocusedWindow() { return null; } 187 public void setCurrentFocusOwner(Component comp) {} 188 public Component getCurrentFocusOwner() { return null; } 189 public void clearGlobalFocusOwner(Window activeWindow) {} 190 }; 191 } 192 193 public TrayIconPeer createTrayIcon(TrayIcon target) 194 throws HeadlessException { 195 throw new HeadlessException(); 196 } 197 198 public SystemTrayPeer createSystemTray(SystemTray target) 199 throws HeadlessException { 200 throw new HeadlessException(); 201 } 202 203 public boolean isTraySupported() { 204 return false; 205 } 206 207 public GlobalCursorManager getGlobalCursorManager() 208 throws HeadlessException { 209 throw new HeadlessException(); 210 } | 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.awt; 27 28 import java.awt.*; 29 import java.awt.dnd.*; 30 import java.awt.dnd.peer.DragSourceContextPeer; 31 import java.awt.event.*; 32 import java.awt.im.InputMethodHighlight; 33 import java.awt.image.*; 34 import java.awt.datatransfer.Clipboard; 35 import java.awt.peer.*; 36 import java.beans.PropertyChangeListener; 37 import java.net.URL; 38 import java.util.Map; 39 import java.util.Properties; 40 41 public class HeadlessToolkit extends Toolkit 42 implements ComponentFactory, KeyboardFocusManagerPeerProvider { 43 44 private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() { 45 public void setCurrentFocusedWindow(Window win) {} 46 public Window getCurrentFocusedWindow() { return null; } 47 public void setCurrentFocusOwner(Component comp) {} 48 public Component getCurrentFocusOwner() { return null; } 49 public void clearGlobalFocusOwner(Window activeWindow) {} 50 }; 51 52 private Toolkit tk; 53 private ComponentFactory componentFactory; 54 55 public HeadlessToolkit(Toolkit tk) { 56 this.tk = tk; 57 if (tk instanceof ComponentFactory) { 58 componentFactory = (ComponentFactory)tk; 59 } 60 } 61 62 public Toolkit getUnderlyingToolkit() { 63 return tk; 64 } 65 66 /* 67 * Component peer objects. 68 */ 69 70 /* Lightweight implementation of Canvas and Panel */ 71 165 throws HeadlessException { 166 throw new HeadlessException(); 167 } 168 169 public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) 170 throws HeadlessException { 171 throw new HeadlessException(); 172 } 173 174 public DragSourceContextPeer createDragSourceContextPeer( 175 DragGestureEvent dge) 176 throws InvalidDnDOperationException { 177 throw new InvalidDnDOperationException("Headless environment"); 178 } 179 180 public RobotPeer createRobot(Robot target, GraphicsDevice screen) 181 throws AWTException, HeadlessException { 182 throw new HeadlessException(); 183 } 184 185 public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() { 186 // See 6833019. 187 return kfmPeer; 188 } 189 190 public TrayIconPeer createTrayIcon(TrayIcon target) 191 throws HeadlessException { 192 throw new HeadlessException(); 193 } 194 195 public SystemTrayPeer createSystemTray(SystemTray target) 196 throws HeadlessException { 197 throw new HeadlessException(); 198 } 199 200 public boolean isTraySupported() { 201 return false; 202 } 203 204 public GlobalCursorManager getGlobalCursorManager() 205 throws HeadlessException { 206 throw new HeadlessException(); 207 } |