| Method from java.awt.Toolkit Detail: |
public void addAWTEventListener(AWTEventListener listener,
long eventMask) {
lockAWT();
try {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(awtEventsManager.permission);
}
awtEventsManager.addAWTEventListener(listener, eventMask);
} finally {
unlockAWT();
}
}
|
public void addPropertyChangeListener(String propName,
PropertyChangeListener l) {
lockAWT();
try {
if (desktopProperties.isEmpty()) {
initializeDesktopProperties();
}
} finally {
unlockAWT();
}
if (l != null) { // there is no guarantee that null listener will not be added
desktopPropsSupport.addPropertyChangeListener(propName, l);
}
}
|
abstract public void beep()
|
static void checkHeadless() throws HeadlessException {
if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance())
throw new HeadlessException();
}
|
abstract public int checkImage(Image a0,
int a1,
int a2,
ImageObserver a3)
|
abstract protected ButtonPeer createButton(Button a0) throws HeadlessException
|
abstract protected CanvasPeer createCanvas(Canvas a0)
|
abstract protected CheckboxPeer createCheckbox(Checkbox a0) throws HeadlessException
|
abstract protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem a0) throws HeadlessException
|
abstract protected ChoicePeer createChoice(Choice a0) throws HeadlessException
|
protected LightweightPeer createComponent(Component a0) throws NotImplementedException {
throw new NotImplementedException();
}
|
public Cursor createCustomCursor(Image img,
Point hotSpot,
String name) throws IndexOutOfBoundsException, HeadlessException {
lockAWT();
try {
int w = img.getWidth(null);
int h = img.getHeight(null);
if (w < 0 || h < 0) {
// Fix for HARMONY-4491
hotSpot.x = 0;
hotSpot.y = 0;
} else if (hotSpot.x < 0 || hotSpot.x >= w
|| hotSpot.y < 0 || hotSpot.y >= h) {
// awt.7E=invalid hotSpot
throw new IndexOutOfBoundsException(Messages.getString("awt.7E")); //$NON-NLS-1$
}
return new Cursor(name, img, hotSpot);
} finally {
unlockAWT();
}
}
|
NativeCursor createCustomNativeCursor(Image img,
Point hotSpot,
String name) {
return wtk.getCursorFactory().createCustomCursor(img, hotSpot.x, hotSpot.y);
}
Returns a shared instance of implementation of org.apache.harmony.awt.wtk.NativeCursor
for current platform for custom cursor |
abstract protected DialogPeer createDialog(Dialog a0) throws HeadlessException
|
public T createDragGestureRecognizer(Class<T> recognizerAbstractClass,
DragSource ds,
Component c,
int srcActions,
DragGestureListener dgl) {
if (recognizerAbstractClass == null) {
return null;
}
if (recognizerAbstractClass.isAssignableFrom(MouseDragGestureRecognizer.class)) {
return (T) new DefaultMouseDragGestureRecognizer(ds, c, srcActions, dgl);
}
return null;
}
|
abstract public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent a0) throws InvalidDnDOperationException
|
NativeWindow createEmbeddedNativeWindow(EmbeddedWindow ew) {
windows.add(ew);
CreationParams cp = new CreationParams();
cp.child = true;
cp.disabled = false;
cp.name = "EmbeddedWindow"; //$NON-NLS-1$
cp.parentId = ew.nativeWindowId;
cp.x = 0;
cp.y = 0;
Dimension size = getWindowFactory().getWindowSizeById(ew.nativeWindowId);
cp.w = size.width;
cp.h = size.height;
recentNativeWindowComponent = ew;
NativeWindow win = getWindowFactory().createWindow(cp);
nativeWindowCreated(win);
shutdownWatchdog.setWindowListEmpty(false);
return win;
}
|
abstract protected FileDialogPeer createFileDialog(FileDialog a0) throws HeadlessException
|
NativeWindow createFocusProxyNativeWindow(Window owner) {
CreationParams cp = new CreationParams();
cp.child = true;
cp.disabled = false;
cp.resizable = false;
cp.undecorated = true;
cp.iconified = false;
cp.visible = true;
cp.maximizedState = 0;
cp.decorType = CreationParams.DECOR_TYPE_NONE;
cp.parentId = owner.getNativeWindow().getId();
cp.x = -10;
cp.y = -10;
cp.w = 1;
cp.h = 1;
NativeWindow win = getWindowFactory().createWindow(cp);
windowFocusProxyMap.put(win, owner);
return win;
}
|
abstract protected FramePeer createFrame(Frame a0) throws HeadlessException
|
abstract public Image createImage(ImageProducer a0)
|
abstract public Image createImage(URL a0)
|
abstract public Image createImage(String a0)
|
public Image createImage(byte[] imagedata) {
return createImage(imagedata, 0, imagedata.length);
}
|
abstract public Image createImage(byte[] a0,
int a1,
int a2)
|
abstract protected LabelPeer createLabel(Label a0) throws HeadlessException
|
abstract protected ListPeer createList(List a0) throws HeadlessException
|
abstract protected MenuPeer createMenu(Menu a0) throws HeadlessException
|
abstract protected MenuBarPeer createMenuBar(MenuBar a0) throws HeadlessException
|
abstract protected MenuItemPeer createMenuItem(MenuItem a0) throws HeadlessException
|
NativeCursor createNativeCursor(int type) {
return wtk.getCursorFactory().getCursor(type);
}
Returns a shared instance of implementation of org.apache.harmony.awt.wtk.NativeCursor
for current platform for |
NativeWindow createNativeWindow(Component c) {
if (c instanceof Window) {
windows.add(c);
}
Component parent = null;
Point location = c.getLocation();
CreationParams cp = new CreationParams();
cp.child = !(c instanceof Window);
cp.disabled = !c.isEnabled();
if (c instanceof Window) {
Window w = (Window) c;
cp.resizable = w.isResizable();
cp.undecorated = w.isUndecorated();
parent = w.getOwner();
cp.locationByPlatform = w.locationByPlatform;
if (c instanceof Frame) {
Frame frame = (Frame) c;
int state = frame.getExtendedState();
cp.name = frame.getTitle();
cp.iconified = (state & Frame.ICONIFIED) != 0;
cp.maximizedState = 0;
if ((state & Frame.MAXIMIZED_BOTH) != 0) {
cp.maximizedState |= cp.MAXIMIZED;
}
if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
cp.maximizedState |= cp.MAXIMIZED_HORIZ;
}
if ((state & Frame.MAXIMIZED_VERT) != 0) {
cp.maximizedState |= cp.MAXIMIZED_VERT;
}
cp.decorType = CreationParams.DECOR_TYPE_FRAME;
} else if (c instanceof Dialog) {
Dialog dlg = (Dialog) c;
cp.name = dlg.getTitle();
cp.decorType = CreationParams.DECOR_TYPE_DIALOG;
} else if (w.isPopup()) {
cp.decorType = CreationParams.DECOR_TYPE_POPUP;
} else {
cp.decorType = CreationParams.DECOR_TYPE_UNDECOR;
}
} else {
parent = c.getHWAncestor();
cp.name = c.getName();
//set location relative to the nearest heavy weight ancestor
location = MouseDispatcher.convertPoint(c, 0, 0, parent);
}
if (parent != null) {
NativeWindow nativeParent = parent.getNativeWindow();
if (nativeParent == null) {
if (cp.child) {
return null; //component's window will be created when its parent is created ???
}
parent.mapToDisplay(true); //TODO: verify it
nativeParent = parent.getNativeWindow();
}
cp.parentId = nativeParent.getId();
}
cp.x = location.x;
cp.y = location.y;
cp.w = c.getWidth();
cp.h = c.getHeight();
recentNativeWindowComponent = c;
NativeWindow win = getWindowFactory().createWindow(cp);
nativeWindowCreated(win);
if (c instanceof Window) {
shutdownWatchdog.setWindowListEmpty(false);
}
return win;
}
|
abstract protected PanelPeer createPanel(Panel a0)
|
abstract protected PopupMenuPeer createPopupMenu(PopupMenu a0) throws HeadlessException
|
NativeWindow createPopupNativeWindow(PopupBox popup) {
CreationParams cp = new CreationParams();
cp.child = popup.isMenuBar();
cp.disabled = false;
cp.resizable = false;
cp.undecorated = true;
cp.iconified = false;
cp.visible = false;
cp.maximizedState = 0;
cp.decorType = CreationParams.DECOR_TYPE_POPUP;
NativeWindow nativeParent;
if (popup.getParent() != null) {
nativeParent = popup.getParent().getNativeWindow();
} else {
nativeParent = popup.getOwner().getNativeWindow();
}
assert nativeParent != null;
cp.parentId = nativeParent.getId();
cp.x = popup.getLocation().x;
cp.y = popup.getLocation().y;
cp.w = popup.getSize().width;
cp.h = popup.getSize().height;
recentNativeWindowComponent = popup;
NativeWindow win = getWindowFactory().createWindow(cp);
nativeWindowCreated(win);
return win;
}
|
abstract protected ScrollPanePeer createScrollPane(ScrollPane a0) throws HeadlessException
|
abstract protected ScrollbarPeer createScrollbar(Scrollbar a0) throws HeadlessException
|
abstract protected TextAreaPeer createTextArea(TextArea a0) throws HeadlessException
|
abstract protected TextFieldPeer createTextField(TextField a0) throws HeadlessException
|
abstract protected WindowPeer createWindow(Window a0) throws HeadlessException
|
void dispatchAWTEvent(AWTEvent event) {
awtEventsManager.dispatchAWTEvent(event);
}
|
public AWTEventListener[] getAWTEventListeners() {
lockAWT();
try {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(awtEventsManager.permission);
}
return awtEventsManager.getAWTEventListeners();
} finally {
unlockAWT();
}
}
|
public AWTEventListener[] getAWTEventListeners(long eventMask) {
lockAWT();
try {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(awtEventsManager.permission);
}
return awtEventsManager.getAWTEventListeners(eventMask);
} finally {
unlockAWT();
}
}
|
public Dimension getBestCursorSize(int prefWidth,
int prefHeight) throws HeadlessException {
lockAWT();
try {
return wtk.getCursorFactory().getBestCursorSize(prefWidth, prefHeight);
} finally {
unlockAWT();
}
}
|
abstract public ColorModel getColorModel() throws HeadlessException
|
Component getComponentById(long id) {
if (id == 0) {
return null;
}
return (Component) windowComponentMap.get(getWindowFactory().getWindowById(id));
}
|
Font getDefaultFont() {
return wtk.getSystemProperties().getDefaultFont();
}
|
public static Toolkit getDefaultToolkit() {
synchronized (ContextStorage.getContextLock()) {
if (ContextStorage.shutdownPending()) {
return null;
}
Toolkit defToolkit = ContextStorage.getDefaultToolkit();
if (defToolkit != null) {
return defToolkit;
}
staticLockAWT();
try {
defToolkit = GraphicsEnvironment.isHeadless() ?
new HeadlessToolkit() : new ToolkitImpl();
ContextStorage.setDefaultToolkit(defToolkit);
return defToolkit;
} finally {
staticUnlockAWT();
}
//TODO: read system property named awt.toolkit
//and create an instance of the specified class,
//by default use ToolkitImpl
}
}
|
public final Object getDesktopProperty(String propName) {
lockAWT();
try {
if (desktopProperties.isEmpty()) {
initializeDesktopProperties();
}
if (propName.equals("awt.dynamicLayoutSupported")) { //$NON-NLS-1$
// dynamicLayoutSupported is special case
return Boolean.valueOf(isDynamicLayoutActive());
}
Object val = desktopProperties.get(propName);
if (val == null) {
// try to lazily load prop value
// just for compatibility, our lazilyLoad is empty
val = lazilyLoadDesktopProperty(propName);
}
return val;
} finally {
unlockAWT();
}
}
|
Object getEventMonitor() {
return wtk.getNativeEventQueue().getEventMonitor();
}
|
Window getFocusProxyOwnerById(long id) {
if (id == 0) {
return null;
}
return windowFocusProxyMap.get(getWindowFactory().getWindowById(id));
}
|
abstract public String[] getFontList()Deprecated!
|
abstract public FontMetrics getFontMetrics(Font font)Deprecated!
|
abstract protected FontPeer getFontPeer(String a0,
int a1)Deprecated!
|
GraphicsFactory getGraphicsFactory() {
return wtk.getGraphicsFactory();
}
|
abstract public Image getImage(String a0)
|
abstract public Image getImage(URL a0)
|
public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
if (keyCode != KeyEvent.VK_CAPS_LOCK &&
keyCode != KeyEvent.VK_NUM_LOCK &&
keyCode != KeyEvent.VK_SCROLL_LOCK &&
keyCode != KeyEvent.VK_KANA_LOCK) {
throw new IllegalArgumentException();
}
return wtk.getLockingState(keyCode);
}
|
public int getMaximumCursorColors() throws HeadlessException {
lockAWT();
try {
return wtk.getCursorFactory().getMaximumCursorColors();
} finally {
unlockAWT();
}
}
|
public int getMenuShortcutKeyMask() throws HeadlessException {
lockAWT();
try {
return InputEvent.CTRL_MASK;
} finally {
unlockAWT();
}
}
|
protected MouseInfoPeer getMouseInfoPeer() {
return new MouseInfoPeer() {
};
}
|
protected static Container getNativeContainer(Component c) {
staticLockAWT();
try {
//TODO: implement
return c.getWindowAncestor();
} finally {
staticUnlockAWT();
}
}
|
NativeEventQueue getNativeEventQueue() {
return wtk.getNativeEventQueue();
}
|
NativeMouseInfo getNativeMouseInfo() {
return wtk.getNativeMouseInfo();
}
Returns implementation of org.apache.harmony.awt.wtk.NativeMouseInfo
for current platform. |
PopupBox getPopupBoxById(long id) {
if (id == 0) {
return null;
}
return (PopupBox) windowPopupMap.get(getWindowFactory().getWindowById(id));
}
|
abstract public PrintJob getPrintJob(Frame a0,
String a1,
Properties a2)
|
public PrintJob getPrintJob(Frame a0,
String a1,
JobAttributes a2,
PageAttributes a3) throws NotImplementedException {
lockAWT();
try {
} finally {
unlockAWT();
}
throw new org.apache.harmony.luni.util.NotImplementedException();
}
|
public static String getProperty(String propName,
String defVal) {
if (propName == null) {
// awt.7D=Property name is null
throw new NullPointerException(Messages.getString("awt.7D")); //$NON-NLS-1$
}
staticLockAWT();
try {
String retVal = null;
if (properties != null) {
try {
retVal = properties.getString(propName);
} catch (MissingResourceException e) {
} catch (ClassCastException e) {
}
}
return (retVal == null) ? defVal : retVal;
} finally {
staticUnlockAWT();
}
}
|
public PropertyChangeListener[] getPropertyChangeListeners() {
return desktopPropsSupport.getPropertyChangeListeners();
}
|
public PropertyChangeListener[] getPropertyChangeListeners(String propName) {
return desktopPropsSupport.getPropertyChangeListeners(propName);
}
|
public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException {
if (gc == null) {
throw new NullPointerException();
}
lockAWT();
try {
return new Insets(0, 0, 0, 0); //TODO: get real screen insets
} finally {
unlockAWT();
}
}
|
abstract public int getScreenResolution() throws HeadlessException
|
abstract public Dimension getScreenSize() throws HeadlessException
|
final Synchronizer getSynchronizer() {
return synchronizer;
}
|
abstract public Clipboard getSystemClipboard() throws HeadlessException
|
public final EventQueue getSystemEventQueue() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkAwtEventQueueAccess();
}
return getSystemEventQueueImpl();
}
|
EventQueueCore getSystemEventQueueCore() {
return systemEventQueueCore;
}
|
abstract protected EventQueue getSystemEventQueueImpl()
|
public Clipboard getSystemSelection() throws HeadlessException {
lockAWT();
try {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkSystemClipboardAccess();
}
if (systemSelection == null) {
systemSelection = dtk.getNativeSelection();
}
return systemSelection;
} finally {
unlockAWT();
}
}
|
final WTK getWTK() {
return wtk;
}
|
WindowFactory getWindowFactory() {
return wtk.getWindowFactory();
}
|
void init() {
lockAWT();
try {
ComponentInternals.setComponentInternals(new ComponentInternalsImpl());
new EventQueue(this); // create the system EventQueue
dispatcher = new Dispatcher(this);
final String className = getWTKClassName();
awtEventsManager = new AWTEventsManager();
dispatchThread = new EventDispatchThread(this, dispatcher);
nativeThread = new NativeEventThread();
dtk = DTK.getDTK();
NativeEventThread.Init init = new NativeEventThread.Init() {
public WTK init() {
wtk = createWTK(className);
wtk.getNativeEventQueue().setShutdownWatchdog(shutdownWatchdog);
synchronizer.setEnvironment(wtk, dispatchThread);
ContextStorage.setWTK(wtk);
dtk.initDragAndDrop();
return wtk;
}
};
nativeThread.start(init);
dispatchThread.start();
wtk.getNativeEventQueue().awake();
} finally {
unlockAWT();
}
}
|
protected void initializeDesktopProperties() {
lockAWT();
try {
wtk.getSystemProperties().init(desktopProperties);
} finally {
unlockAWT();
}
}
|
public boolean isDynamicLayoutActive() throws HeadlessException {
lockAWT();
try {
// always return true
return true;
} finally {
unlockAWT();
}
}
|
protected boolean isDynamicLayoutSet() throws HeadlessException {
lockAWT();
try {
return bDynamicLayoutSet;
} finally {
unlockAWT();
}
}
|
public boolean isFrameStateSupported(int state) throws HeadlessException {
lockAWT();
try {
return wtk.getWindowFactory().isWindowStateSupported(state);
} finally {
unlockAWT();
}
}
|
protected Object lazilyLoadDesktopProperty(String propName) {
return null;
}
|
protected void loadSystemColors(int[] colors) throws HeadlessException {
lockAWT();
try {
} finally {
unlockAWT();
}
}
|
final void lockAWT() {
synchronizer.lock();
}
|
abstract public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) throws HeadlessException
|
Map<TextAttribute, ?> mapInputMethodHighlightImpl(InputMethodHighlight highlight) throws HeadlessException {
HashMap< java.awt.font.TextAttribute, ? > map = new HashMap< java.awt.font.TextAttribute, Object >();
wtk.getSystemProperties().mapInputMethodHighlight(highlight, map);
return Collections.< java.awt.font.TextAttribute, Object > unmodifiableMap(map);
}
|
void nativeWindowCreated(NativeWindow win) {
if (recentNativeWindowComponent == null) {
return;
}
if (recentNativeWindowComponent instanceof Component) {
windowComponentMap.put(win, recentNativeWindowComponent);
((Component) recentNativeWindowComponent).nativeWindowCreated(win);
} else if (recentNativeWindowComponent instanceof PopupBox) {
windowPopupMap.put(win, recentNativeWindowComponent);
}
recentNativeWindowComponent = null;
}
Connect the component to its native window
This method is called after the synchronous window creation,
and also in the window creation callback if it exists (WM_CREATE on Windows)
Calling this method twice is OK because in second time it just does nothing.
This is done this way because on Windows the native window gets a series of native
events before windowFactory.CreateWindow() returns, and the WinWindow object should be created
to process them. The WM_CREATE message is guaranteed to be first in the series, so that the
the WM_CREATE handler creates the WinWindow object and calls nativeWindowCreated()
for it. |
void onQueueEmpty() {
if (windows.isEmpty()) {
if (systemClipboard != null) {
systemClipboard.onShutdown();
}
if (systemSelection != null) {
systemSelection.onShutdown();
}
shutdownWatchdog.setWindowListEmpty(true);
} else {
for (Iterator< ? > i = windows.iterator(); i.hasNext();) {
((Window) i.next()).redrawAll();
}
}
}
|
boolean onWindowCreated(long winId) {
nativeWindowCreated(getWindowFactory().getWindowById(winId));
return false;
}
Connect the component to its native window |
abstract public boolean prepareImage(Image a0,
int a1,
int a2,
ImageObserver a3)
|
public void removeAWTEventListener(AWTEventListener listener) {
lockAWT();
try {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(awtEventsManager.permission);
}
awtEventsManager.removeAWTEventListener(listener);
} finally {
unlockAWT();
}
}
|
void removeFocusProxyNativeWindow(NativeWindow w) {
windowFocusProxyMap.remove(w);
}
|
void removeNativeWindow(NativeWindow w) {
Component comp = (Component) windowComponentMap.get(w);
if ((comp != null) && (comp instanceof Window)) {
windows.remove(comp);
}
windowComponentMap.remove(w);
}
|
void removePopupNativeWindow(NativeWindow w) {
windowPopupMap.remove(w);
}
|
public void removePropertyChangeListener(String propName,
PropertyChangeListener l) {
desktopPropsSupport.removePropertyChangeListener(propName, l);
}
|
protected final void setDesktopProperty(String propName,
Object value) {
Object oldVal;
lockAWT();
try {
oldVal = getDesktopProperty(propName);
userPropSet.add(propName);
desktopProperties.put(propName, value);
} finally {
unlockAWT();
}
desktopPropsSupport.firePropertyChange(propName, oldVal, value);
}
|
public void setDynamicLayout(boolean dynamic) throws HeadlessException {
lockAWT();
try {
bDynamicLayoutSet = dynamic;
} finally {
unlockAWT();
}
}
|
public void setLockingKeyState(int keyCode,
boolean on) throws UnsupportedOperationException {
if (keyCode != KeyEvent.VK_CAPS_LOCK &&
keyCode != KeyEvent.VK_NUM_LOCK &&
keyCode != KeyEvent.VK_SCROLL_LOCK &&
keyCode != KeyEvent.VK_KANA_LOCK) {
throw new IllegalArgumentException();
}
wtk.setLockingState(keyCode, on);
}
|
void setSystemEventQueueCore(EventQueueCore core) {
systemEventQueueCore = core;
}
|
static final void staticLockAWT() {
ContextStorage.getSynchronizer().lock();
}
|
static final void staticUnlockAWT() {
ContextStorage.getSynchronizer().unlock();
}
|
abstract public void sync()
|
final void unlockAWT() {
synchronizer.unlock();
}
|
final void unsafeInvokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException {
synchronizer.storeStateAndFree();
try {
EventQueue.invokeAndWait(runnable);
} finally {
synchronizer.lockAndRestoreState();
}
}
InvokeAndWait under AWT lock. W/o this method system can hang up.
Added to support modality (Dialog.show() & PopupMenu.show()) from
not event dispatch thread. Use in other cases is not recommended.
Still can be called only for whole API methods that
cannot be called from other classes API methods.
Examples:
show() for modal dialogs - correct, only user can call it,
directly or through setVisible(true)
setBounds() for components - incorrect, setBounds()
can be called from layoutContainer()
for layout managers |