本文整理汇总了Java中sun.awt.AWTAccessor类的典型用法代码示例。如果您正苦于以下问题:Java AWTAccessor类的具体用法?Java AWTAccessor怎么用?Java AWTAccessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AWTAccessor类属于sun.awt包,在下文中一共展示了AWTAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateInvalidComponents
import sun.awt.AWTAccessor; //导入依赖的package包/类
/**
* Validate all of the components that have been marked invalid.
* @see #addInvalidComponent
*/
public void validateInvalidComponents() {
final java.util.List<Component> ic;
synchronized(this) {
if (invalidComponents == null) {
return;
}
ic = invalidComponents;
invalidComponents = null;
}
int n = ic.size();
for(int i = 0; i < n; i++) {
final Component c = ic.get(i);
AccessControlContext stack = AccessController.getContext();
AccessControlContext acc =
AWTAccessor.getComponentAccessor().getAccessControlContext(c);
javaSecurityAccess.doIntersectionPrivilege(
new PrivilegedAction<Void>() {
public Void run() {
c.validate();
return null;
}
}, stack, acc);
}
}
示例2: run
import sun.awt.AWTAccessor; //导入依赖的package包/类
public Component run() {
try {
final Component component = createNoPermsComponent();
// 6482575 - clear the appContext field so as not to leak it
AWTAccessor.getComponentAccessor().
setAppContext(component, null);
return component;
} catch (Throwable e) {
// We don't care about component.
// So don't prevent class initialisation.
e.printStackTrace();
return null;
}
}
示例3: getNearestNativePeer
import sun.awt.AWTAccessor; //导入依赖的package包/类
private LWComponentPeer<?, ?> getNearestNativePeer(Component comp) {
if (comp==null)
return null;
final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
ComponentPeer peer = acc.getPeer(comp);
if (peer==null)
return null;
while (peer instanceof java.awt.peer.LightweightPeer) {
comp = comp.getParent();
if (comp==null)
return null;
peer = acc.getPeer(comp);
if (peer==null)
return null;
}
if (peer instanceof LWComponentPeer)
return (LWComponentPeer)peer;
return null;
}
示例4: isFocusedWindowModalBlocker
import sun.awt.AWTAccessor; //导入依赖的package包/类
boolean isFocusedWindowModalBlocker() {
Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
XWindowPeer focusedWindowPeer = null;
if (focusedWindow != null) {
focusedWindowPeer = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(focusedWindow);
} else {
/*
* For the case when a potential blocked window is not yet focused
* on the Java level (e.g. it's just been mapped) we're asking for the
* focused window on the native level.
*/
focusedWindowPeer = getNativeFocusedWindowPeer();
}
synchronized (getStateLock()) {
if (focusedWindowPeer != null && focusedWindowPeer.modalBlocker == target) {
return true;
}
}
return super.isFocusedWindowModalBlocker();
}
示例5: nativeQueueSurfaceDataRunnable
import sun.awt.AWTAccessor; //导入依赖的package包/类
void nativeQueueSurfaceDataRunnable(AppContext appContext,
final Component c, final Runnable r)
{
synchronized(this) {
if (runnableList == null) {
runnableList = new LinkedList<Runnable>();
}
runnableList.add(new Runnable() {
public void run() {
AccessControlContext stack = AccessController.getContext();
AccessControlContext acc =
AWTAccessor.getComponentAccessor().getAccessControlContext(c);
javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Void>() {
public Void run() {
r.run();
return null;
}
}, stack, acc);
}
});
}
scheduleProcessingRunnable(appContext);
}
示例6: showPopupMenu
import sun.awt.AWTAccessor; //导入依赖的package包/类
@Override
public synchronized void showPopupMenu(final int x, final int y) {
if (isDisposed())
return;
SunToolkit.executeOnEventHandlerThread(target, () -> {
PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
if (popup != newPopup) {
if (popup != null) {
popupParent.remove(popup);
}
if (newPopup != null) {
popupParent.add(newPopup);
}
popup = newPopup;
}
if (popup != null) {
WPopupMenuPeer peer = AWTAccessor.getMenuComponentAccessor()
.getPeer(popup);
peer.show(popupParent, new Point(x, y));
}
});
}
示例7: invokeAndWait
import sun.awt.AWTAccessor; //导入依赖的package包/类
/**
* Invokes a {@code Callable} in the {@code AppContext} mapped to the given {@code AccessibleContext}
* and waits for it to finish blocking the caller thread.
*
* @param callable the {@code Callable} to invoke
* @param accessibleContext the {@code AccessibleContext} which would be used to determine the right
* context for the task execution.
* @param <T> type parameter for the result value
*
* @return the result of the {@code Callable} execution
*/
public static <T> T invokeAndWait(final Callable<T> callable,
final AccessibleContext accessibleContext) {
AppContext targetContext = AWTAccessor.getAccessibleContextAccessor()
.getAppContext(accessibleContext);
if (targetContext != null) {
return invokeAndWait(callable, targetContext);
} else {
// Normally this should not happen, unmapped context provided and
// the target AppContext is unknown.
// Try to recover in case the context is a translator.
if (accessibleContext instanceof Translator) {
Object source = ((Translator)accessibleContext).getSource();
if (source instanceof Component) {
return invokeAndWait(callable, (Component)source);
}
}
}
throw new RuntimeException("Unmapped AccessibleContext used to dispatch event: " + accessibleContext);
}
示例8: handleCancel
import sun.awt.AWTAccessor; //导入依赖的package包/类
/**
* handle the cancel event
*/
void handleCancel() {
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.removeKeyEventDispatcher(this);
setSelectionField(null);
setFilterField(null);
directoryList.clear();
fileList.clear();
AWTAccessor.FileDialogAccessor fileDialogAccessor = AWTAccessor.getFileDialogAccessor();
fileDialogAccessor.setDirectory(target, null);
fileDialogAccessor.setFile(target, null);
fileDialogAccessor.setFiles(target, null);
handleQuitButton();
}
示例9: setBackground
import sun.awt.AWTAccessor; //导入依赖的package包/类
public void setBackground(Color c) {
Component comp;
int i;
Container cont = (Container) target;
final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
synchronized(target.getTreeLock()) {
int n = cont.getComponentCount();
for(i=0; i < n; i++) {
comp = cont.getComponent(i);
ComponentPeer peer = acc.getPeer(comp);
if (peer != null) {
Color color = comp.getBackground();
if (color == null || color.equals(c)) {
peer.setBackground(c);
}
}
}
}
super.setBackground(c);
}
示例10: init
import sun.awt.AWTAccessor; //导入依赖的package包/类
/**
* called from XFramePeer.setMenuBar
*/
public void init(Frame frame) {
this.target = frame;
this.framePeer = AWTAccessor.getComponentAccessor().getPeer(frame);
XCreateWindowParams params = getDelayedParams();
params.remove(DELAYED);
params.add(PARENT_WINDOW, framePeer.getShell());
params.add(TARGET, frame);
init(params);
}
示例11: getSize
import sun.awt.AWTAccessor; //导入依赖的package包/类
/**
* Gets the size of the security warning.
*
* The returned value is not valid until the peer has been created. Before
* invoking this method a developer must call the {@link Window#pack()},
* {@link Window#setVisible()}, or some other method that creates the peer.
*
* @param window the window to get the security warning size for
*
* @throws NullPointerException if the window argument is null
* @throws IllegalArgumentException if the window is trusted (i.e.
* the {@code getWarningString()} returns null)
*/
public static Dimension getSize(Window window) {
if (window == null) {
throw new NullPointerException(
"The window argument should not be null.");
}
if (window.getWarningString() == null) {
throw new IllegalArgumentException(
"The window must have a non-null warning string.");
}
// We don't check for a non-null peer since it may be destroyed
// after assigning a valid value to the security warning size.
return AWTAccessor.getWindowAccessor().getSecurityWarningSize(window);
}
示例12: setReparented
import sun.awt.AWTAccessor; //导入依赖的package包/类
void setReparented(boolean newValue) {
super.setReparented(newValue);
XToolkit.awtLock();
try {
if (isReparented() && delayedModalBlocking) {
addToTransientFors((XDialogPeer) AWTAccessor.getComponentAccessor().getPeer(modalBlocker));
delayedModalBlocking = false;
}
} finally {
XToolkit.awtUnlock();
}
}
示例13: setCursor
import sun.awt.AWTAccessor; //导入依赖的package包/类
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
if (comp == null) {
return;
}
Cursor cur = useCache ? cursor : getCapableCursor(comp);
Component nc = null;
if (useCache) {
synchronized (this) {
nc = nativeContainer.get();
}
} else {
nc = SunToolkit.getHeavyweightComponent(comp);
}
if (nc != null) {
ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
if (nc_peer instanceof XComponentPeer) {
synchronized (this) {
nativeContainer = new WeakReference<Component>(nc);
}
//6431076. A subcomponents (a XTextArea in particular)
//may want to override the cursor over some of their parts.
((XComponentPeer)nc_peer).pSetCursor(cur, false);
// in case of grab we do for Swing we need to update keep cursor updated
// (we don't need this in case of AWT menus). Window Manager consider
// the grabber as a current window and use its cursor. So we need to
// change cursor on the grabber too.
updateGrabbedCursor(cur);
}
}
}
示例14: initialize
import sun.awt.AWTAccessor; //导入依赖的package包/类
private static void initialize() {
Properties swingProps = loadSwingProperties();
initializeSystemDefaults(swingProps);
initializeDefaultLAF(swingProps);
initializeAuxiliaryLAFs(swingProps);
initializeInstalledLAFs(swingProps);
// Install Swing's PaintEventDispatcher
if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
new SwingPaintEventDispatcher());
}
// Install a hook that will be invoked if no one consumes the
// KeyEvent. If the source isn't a JComponent this will process
// key bindings, if the source is a JComponent it implies that
// processKeyEvent was already invoked and thus no need to process
// the bindings again, unless the Component is disabled, in which
// case KeyEvents will no longer be dispatched to it so that we
// handle it here.
KeyboardFocusManager.getCurrentKeyboardFocusManager().
addKeyEventPostProcessor(new KeyEventPostProcessor() {
public boolean postProcessKeyEvent(KeyEvent e) {
Component c = e.getComponent();
if ((!(c instanceof JComponent) ||
(c != null && !c.isEnabled())) &&
JComponent.KeyboardState.shouldProcess(e) &&
SwingUtilities.processKeyBindings(e)) {
e.consume();
return true;
}
return false;
}
});
AWTAccessor.getComponentAccessor().
setRequestFocusController(JComponent.focusController);
}
示例15: updateIconSize
import sun.awt.AWTAccessor; //导入依赖的package包/类
private void updateIconSize() {
int newSize = -1;
if (ownerWindow != null) {
Insets insets = ownerWindow.getInsets();
int max = Math.max(insets.top, Math.max(insets.bottom,
Math.max(insets.left, insets.right)));
if (max < 24) {
newSize = 0;
} else if (max < 32) {
newSize = 1;
} else if (max < 48) {
newSize = 2;
} else {
newSize = 3;
}
}
// Make sure we have a valid size
if (newSize == -1) {
newSize = 0;
}
synchronized (lock) {
if (newSize != currentSize) {
currentSize = newSize;
IconInfo ico = getSecurityIconInfo(currentSize, 0);
AWTAccessor.getWindowAccessor().setSecurityWarningSize(
ownerWindow, ico.getWidth(), ico.getHeight());
}
}
}