2453N/A/*
3211N/A * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
2453N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2453N/A *
2453N/A * This code is free software; you can redistribute it and/or modify it
2453N/A * under the terms of the GNU General Public License version 2 only, as
2453N/A * published by the Free Software Foundation. Oracle designates this
2453N/A * particular file as subject to the "Classpath" exception as provided
2453N/A * by Oracle in the LICENSE file that accompanied this code.
2453N/A *
2453N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2453N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2453N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2453N/A * version 2 for more details (a copy is included in the LICENSE file that
2453N/A * accompanied this code).
2453N/A *
2453N/A * You should have received a copy of the GNU General Public License version
2453N/A * 2 along with this work; if not, write to the Free Software Foundation,
2453N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2453N/A *
2453N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2453N/A * or visit www.oracle.com if you need additional information or have any
2453N/A * questions.
2453N/A */
2453N/A
2453N/Apackage sun.awt;
2453N/A
2453N/Aimport java.awt.*;
2453N/Aimport java.awt.dnd.*;
2453N/Aimport java.awt.dnd.peer.DragSourceContextPeer;
2453N/Aimport java.awt.event.*;
2453N/Aimport java.awt.im.InputMethodHighlight;
2453N/Aimport java.awt.image.*;
2453N/Aimport java.awt.datatransfer.Clipboard;
2453N/Aimport java.awt.peer.*;
2453N/Aimport java.beans.PropertyChangeListener;
2453N/Aimport java.net.URL;
2453N/Aimport java.util.Map;
2453N/Aimport java.util.Properties;
2453N/A
2453N/Apublic class HeadlessToolkit extends Toolkit
2453N/A implements ComponentFactory, KeyboardFocusManagerPeerProvider {
2453N/A
2453N/A private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
2453N/A public void setCurrentFocusedWindow(Window win) {}
2453N/A public Window getCurrentFocusedWindow() { return null; }
3127N/A public void setCurrentFocusOwner(Component comp) {}
3863N/A public Component getCurrentFocusOwner() { return null; }
2453N/A public void clearGlobalFocusOwner(Window activeWindow) {}
2453N/A };
2453N/A
2453N/A private Toolkit tk;
2453N/A private ComponentFactory componentFactory;
2453N/A
2453N/A public HeadlessToolkit(Toolkit tk) {
2453N/A this.tk = tk;
2453N/A if (tk instanceof ComponentFactory) {
2453N/A componentFactory = (ComponentFactory)tk;
2453N/A }
2453N/A }
2453N/A
2453N/A public Toolkit getUnderlyingToolkit() {
2453N/A return tk;
2453N/A }
2453N/A
2453N/A /*
2453N/A * Component peer objects.
2453N/A */
2453N/A
2453N/A /* Lightweight implementation of Canvas and Panel */
2453N/A
2453N/A public CanvasPeer createCanvas(Canvas target) {
2453N/A return (CanvasPeer)createComponent(target);
2453N/A }
2453N/A
2453N/A public PanelPeer createPanel(Panel target) {
2453N/A return (PanelPeer)createComponent(target);
2453N/A }
2453N/A
2453N/A /*
2453N/A * Component peer objects - unsupported.
2453N/A */
2453N/A
2453N/A public WindowPeer createWindow(Window target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public FramePeer createFrame(Frame target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public DialogPeer createDialog(Dialog target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public ButtonPeer createButton(Button target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2654N/A
2654N/A public TextFieldPeer createTextField(TextField target)
2654N/A throws HeadlessException {
2654N/A throw new HeadlessException();
2654N/A }
2654N/A
2654N/A public ChoicePeer createChoice(Choice target)
2654N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2654N/A }
2453N/A
2453N/A public LabelPeer createLabel(Label target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public ListPeer createList(List target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public CheckboxPeer createCheckbox(Checkbox target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public ScrollbarPeer createScrollbar(Scrollbar target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public ScrollPanePeer createScrollPane(ScrollPane target)
2453N/A throws HeadlessException {
2654N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public TextAreaPeer createTextArea(TextArea target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public FileDialogPeer createFileDialog(FileDialog target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public MenuBarPeer createMenuBar(MenuBar target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public MenuPeer createMenu(Menu target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2654N/A }
2453N/A
2453N/A public PopupMenuPeer createPopupMenu(PopupMenu target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public MenuItemPeer createMenuItem(MenuItem target)
2453N/A throws HeadlessException {
3653N/A throw new HeadlessException();
3653N/A }
2453N/A
2453N/A public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public DragSourceContextPeer createDragSourceContextPeer(
2453N/A DragGestureEvent dge)
2453N/A throws InvalidDnDOperationException {
2453N/A throw new InvalidDnDOperationException("Headless environment");
2453N/A }
2453N/A
2453N/A public RobotPeer createRobot(Robot target, GraphicsDevice screen)
2453N/A throws AWTException, HeadlessException {
2453N/A throw new HeadlessException();
3211N/A }
3211N/A
3211N/A public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
3211N/A // See 6833019.
3211N/A return kfmPeer;
3211N/A }
3211N/A
3211N/A public TrayIconPeer createTrayIcon(TrayIcon target)
3211N/A throws HeadlessException {
3211N/A throw new HeadlessException();
3211N/A }
3211N/A
3211N/A public SystemTrayPeer createSystemTray(SystemTray target)
3211N/A throws HeadlessException {
3211N/A throw new HeadlessException();
3211N/A }
3211N/A
3211N/A public boolean isTraySupported() {
3211N/A return false;
3211N/A }
3211N/A
3211N/A public GlobalCursorManager getGlobalCursorManager()
3211N/A throws HeadlessException {
3211N/A throw new HeadlessException();
2453N/A }
3211N/A
2453N/A /*
3211N/A * Headless toolkit - unsupported.
3211N/A */
3211N/A protected void loadSystemColors(int[] systemColors)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public ColorModel getColorModel()
2453N/A throws HeadlessException {
3211N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public int getScreenResolution()
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public Map mapInputMethodHighlight(InputMethodHighlight highlight)
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public int getMenuShortcutKeyMask()
2453N/A throws HeadlessException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public boolean getLockingKeyState(int keyCode)
2453N/A throws UnsupportedOperationException {
2453N/A throw new HeadlessException();
2453N/A }
2453N/A
2453N/A public void setLockingKeyState(int keyCode, boolean on)
2453N/A throws UnsupportedOperationException {
2453N/A throw new HeadlessException();
}
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
throws IndexOutOfBoundsException, HeadlessException {
throw new HeadlessException();
}
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
throws HeadlessException {
throw new HeadlessException();
}
public int getMaximumCursorColors()
throws HeadlessException {
throw new HeadlessException();
}
public <T extends DragGestureRecognizer> T
createDragGestureRecognizer(Class<T> abstractRecognizerClass,
DragSource ds, Component c,
int srcActions, DragGestureListener dgl)
{
return null;
}
public int getScreenHeight()
throws HeadlessException {
throw new HeadlessException();
}
public int getScreenWidth()
throws HeadlessException {
throw new HeadlessException();
}
public Dimension getScreenSize()
throws HeadlessException {
throw new HeadlessException();
}
public Insets getScreenInsets(GraphicsConfiguration gc)
throws HeadlessException {
throw new HeadlessException();
}
public void setDynamicLayout(boolean dynamic)
throws HeadlessException {
throw new HeadlessException();
}
protected boolean isDynamicLayoutSet()
throws HeadlessException {
throw new HeadlessException();
}
public boolean isDynamicLayoutActive()
throws HeadlessException {
throw new HeadlessException();
}
public Clipboard getSystemClipboard()
throws HeadlessException {
throw new HeadlessException();
}
/*
* Printing
*/
public PrintJob getPrintJob(Frame frame, String jobtitle,
JobAttributes jobAttributes,
PageAttributes pageAttributes) {
if (frame != null) {
// Should never happen
throw new HeadlessException();
}
throw new NullPointerException("frame must not be null");
}
public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
{
if (frame != null) {
// Should never happen
throw new HeadlessException();
}
throw new NullPointerException("frame must not be null");
}
/*
* Headless toolkit - supported.
*/
public void sync() {
// Do nothing
}
public void beep() {
// Send alert character
System.out.write(0x07);
}
/*
* Event Queue
*/
public EventQueue getSystemEventQueueImpl() {
return SunToolkit.getSystemEventQueueImplPP();
}
/*
* Images.
*/
public int checkImage(Image img, int w, int h, ImageObserver o) {
return tk.checkImage(img, w, h, o);
}
public boolean prepareImage(
Image img, int w, int h, ImageObserver o) {
return tk.prepareImage(img, w, h, o);
}
public Image getImage(String filename) {
return tk.getImage(filename);
}
public Image getImage(URL url) {
return tk.getImage(url);
}
public Image createImage(String filename) {
return tk.createImage(filename);
}
public Image createImage(URL url) {
return tk.createImage(url);
}
public Image createImage(byte[] data, int offset, int length) {
return tk.createImage(data, offset, length);
}
public Image createImage(ImageProducer producer) {
return tk.createImage(producer);
}
public Image createImage(byte[] imagedata) {
return tk.createImage(imagedata);
}
/*
* Fonts
*/
public FontPeer getFontPeer(String name, int style) {
if (componentFactory != null) {
return componentFactory.getFontPeer(name, style);
}
return null;
}
public FontMetrics getFontMetrics(Font font) {
return tk.getFontMetrics(font);
}
public String[] getFontList() {
return tk.getFontList();
}
/*
* Desktop properties
*/
public void addPropertyChangeListener(String name,
PropertyChangeListener pcl) {
tk.addPropertyChangeListener(name, pcl);
}
public void removePropertyChangeListener(String name,
PropertyChangeListener pcl) {
tk.removePropertyChangeListener(name, pcl);
}
/*
* Modality
*/
public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
return false;
}
public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
return false;
}
/*
* Always on top
*/
public boolean isAlwaysOnTopSupported() {
return false;
}
/*
* AWT Event listeners
*/
public void addAWTEventListener(AWTEventListener listener,
long eventMask) {
tk.addAWTEventListener(listener, eventMask);
}
public void removeAWTEventListener(AWTEventListener listener) {
tk.removeAWTEventListener(listener);
}
public AWTEventListener[] getAWTEventListeners() {
return tk.getAWTEventListeners();
}
public AWTEventListener[] getAWTEventListeners(long eventMask) {
return tk.getAWTEventListeners(eventMask);
}
public boolean isDesktopSupported() {
return false;
}
public DesktopPeer createDesktopPeer(Desktop target)
throws HeadlessException{
throw new HeadlessException();
}
public boolean areExtraMouseButtonsEnabled() throws HeadlessException{
throw new HeadlessException();
}
}