当前位置: 首页>>代码示例>>Java>>正文


Java SunToolkit类代码示例

本文整理汇总了Java中sun.awt.SunToolkit的典型用法代码示例。如果您正苦于以下问题:Java SunToolkit类的具体用法?Java SunToolkit怎么用?Java SunToolkit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SunToolkit类属于sun.awt包,在下文中一共展示了SunToolkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isWindowPerpixelTranslucencySupported

import sun.awt.SunToolkit; //导入依赖的package包/类
boolean isWindowPerpixelTranslucencySupported() {
    /*
     * Per-pixel alpha is supported if all the conditions are TRUE:
     *    1. The toolkit is a sort of SunToolkit
     *    2. The toolkit supports translucency in general
     *        (isWindowTranslucencySupported())
     *    3. There's at least one translucency-capable
     *        GraphicsConfiguration
     */
    Toolkit curToolkit = Toolkit.getDefaultToolkit();
    if (!(curToolkit instanceof SunToolkit)) {
        return false;
    }
    if (!((SunToolkit)curToolkit).isWindowTranslucencySupported()) {
        return false;
    }

    // TODO: cache translucency capable GC
    return getTranslucencyCapableGC() != null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:GraphicsDevice.java

示例2: Blit

import sun.awt.SunToolkit; //导入依赖的package包/类
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) {
    try {
        SunToolkit.awtLock();

        XRSurfaceData x11sdDst = (XRSurfaceData) dst;
        x11sdDst.validateAsDestination(null, clip);
        XRSurfaceData x11sdSrc = (XRSurfaceData) src;
        x11sdSrc.validateAsSource(null, XRUtils.RepeatNone, XRUtils.FAST);

        x11sdDst.maskBuffer.validateCompositeState(comp, null, null, null);

        x11sdDst.maskBuffer.compositeBlit(x11sdSrc, x11sdDst, sx, sy, dx, dy, w, h);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:XRPMBlitLoops.java

示例3: imageUpdate

import sun.awt.SunToolkit; //导入依赖的package包/类
@Override
public boolean imageUpdate(Image img, int infoflags, int x, int y,
        int width, int height) {

    if (isRVObserver()) {
        isRVObserverCalled = true;
        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Image resolutionVariant = getResolutionVariant(img);
        int rvFlags = toolkit.checkImage(resolutionVariant, width, height,
                new IdleImageObserver());
        if (rvFlags < infoflags) {
            throw new RuntimeException("Info flags are greater than"
                    + " resolution varint info flags");
        }
    } else if ((infoflags & ALLBITS) != 0) {
        isImageLoaded = true;
    }

    return (infoflags & ALLBITS) == 0;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:MultiResolutionToolkitImageTest.java

示例4: lock

import sun.awt.SunToolkit; //导入依赖的package包/类
/**
 * Locks the queue for read/write access.
 */
public final void lock() {
    /*
     * Implementation note: In theory we should have two separate locks:
     * one lock to synchronize access to the RenderQueue, and then a
     * separate lock (the AWT lock) that only needs to be acquired when
     * we are about to flush the queue (using native windowing system
     * operations).  In practice it has been difficult to enforce the
     * correct lock ordering; sometimes AWT will have already acquired
     * the AWT lock before grabbing the RQ lock (see 6253009), while the
     * expected order should be RQ lock and then AWT lock.  Due to this
     * issue, using two separate locks is prone to deadlocks.  Therefore,
     * to solve this issue we have decided to eliminate the separate RQ
     * lock and instead just acquire the AWT lock here.  (Someday it might
     * be nice to go back to the old two-lock system, but that would
     * require potentially risky changes to AWT to ensure that it never
     * acquires the AWT lock before calling into 2D code that wants to
     * acquire the RQ lock.)
     */
    SunToolkit.awtLock();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:RenderQueue.java

示例5: validateOptimizedDrawing

import sun.awt.SunToolkit; //导入依赖的package包/类
private void validateOptimizedDrawing() {
    boolean layeredComponentFound = false;
    synchronized(getTreeLock()) {
        Integer layer;

        for (Component c : getComponents()) {
            layer = null;

            if(SunToolkit.isInstanceOf(c, "javax.swing.JInternalFrame") ||
                   (c instanceof JComponent &&
                    (layer = (Integer)((JComponent)c).
                                 getClientProperty(LAYER_PROPERTY)) != null))
            {
                if(layer != null && layer.equals(FRAME_CONTENT_LAYER))
                    continue;
                layeredComponentFound = true;
                break;
            }
        }
    }

    if(layeredComponentFound)
        optimizedDrawingPossible = false;
    else
        optimizedDrawingPossible = true;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:JLayeredPane.java

示例6: test

import sun.awt.SunToolkit; //导入依赖的package包/类
void test() throws Exception {
    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    focusLatch.await(5, TimeUnit.SECONDS);

    Robot robot = new Robot();
    robot.setAutoDelay(100);

    robot.keyPress(KeyEvent.VK_ALT);
    robot.keyPress(KeyEvent.VK_T);
    robot.keyRelease(KeyEvent.VK_T);
    robot.keyRelease(KeyEvent.VK_ALT);

    robot.keyPress(KeyEvent.VK_ALT);
    robot.keyPress(KeyEvent.VK_F);
    robot.keyRelease(KeyEvent.VK_F);
    robot.keyRelease(KeyEvent.VK_ALT);

    actionLatch.await(5, TimeUnit.SECONDS);

    if (!action1 || !action2) {
        throw new RuntimeException("Actions not performed");
    }

    System.out.println("Passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:AltCharAcceleratorTest.java

示例7: dispatch

import sun.awt.SunToolkit; //导入依赖的package包/类
void dispatch(final _NativeEvent event) {
    // grab a local ref to the handler
    final H localHandler;
    final AppContext localHandlerContext;
    synchronized (_AppEventDispatcher.this) {
        localHandler = _handler;
        localHandlerContext = handlerContext;
    }

    if (localHandler == null) {
        performDefaultAction(event);
    } else {
        SunToolkit.invokeLaterOnAppContext(localHandlerContext, new Runnable() {
            public void run() {
                performUsing(localHandler, event);
            }
        });
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:_AppEventHandler.java

示例8: waitForIdle

import sun.awt.SunToolkit; //导入依赖的package包/类
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:Robot.java

示例9: stopLWModal

import sun.awt.SunToolkit; //导入依赖的package包/类
private void stopLWModal() {
    synchronized (getTreeLock()) {
        if (modalAppContext != null) {
            Container nativeContainer = getHeavyweightContainer();
            if(nativeContainer != null) {
                if (this.modalComp !=  null) {
                    nativeContainer.modalComp = this.modalComp;
                    this.modalComp = null;
                    return;
                }
                else {
                    nativeContainer.modalComp = null;
                }
            }
            // Wake up event dispatch thread on which the dialog was
            // initially shown
            SunToolkit.postEvent(modalAppContext,
                    new PeerEvent(this,
                            new WakingRunnable(),
                            PeerEvent.PRIORITY_EVENT));
        }
        EventQueue.invokeLater(new WakingRunnable());
        getTreeLock().notifyAll();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:Container.java

示例10: main

import sun.awt.SunToolkit; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

        Frame frame = new Frame();
        frame.setSize(300, 300);
        frame.setVisible(true);
        toolkit.realSync();

        Robot robot = new Robot();

        robot.keyPress(KeyEvent.VK_DELETE);
        robot.keyRelease(KeyEvent.VK_DELETE);
        toolkit.realSync();

        frame.dispose();

        if (eventsCount != 3) {
            throw new RuntimeException("Wrong number of key events: " + eventsCount);
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:KeyCharTest.java

示例11: newMouseEvent

import sun.awt.SunToolkit; //导入依赖的package包/类
private static MouseEvent newMouseEvent(
    Component source, Point point, MouseEvent template )
{
    MouseEvent e = template;
    MouseEvent nme = new MouseEvent(
        source,
        e.getID(), e.getWhen(),
        e.getModifiersEx() | e.getModifiers(),
        point.x, point.y,
        e.getXOnScreen(), e.getYOnScreen(),
        e.getClickCount(), e.isPopupTrigger(), e.getButton() );
    // Because these MouseEvents are dispatched directly to
    // their target, we need to mark them as being
    // system-generated here
    SunToolkit.setSystemGenerated(nme);
    return nme;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:XTextAreaPeer.java

示例12: addImpl

import sun.awt.SunToolkit; //导入依赖的package包/类
/**
 * Adds the specified component to this scroll pane container.
 * If the scroll pane has an existing child component, that
 * component is removed and the new one is added.
 * @param comp the component to be added
 * @param constraints  not applicable
 * @param index position of child component (must be &lt;= 0)
 */
protected final void addImpl(Component comp, Object constraints, int index) {
    synchronized (getTreeLock()) {
        if (getComponentCount() > 0) {
            remove(0);
        }
        if (index > 0) {
            throw new IllegalArgumentException("position greater than 0");
        }

        if (!SunToolkit.isLightweightOrUnknown(comp)) {
            super.addImpl(comp, constraints, index);
        } else {
            addToPanel(comp, constraints, index);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:ScrollPane.java

示例13: dragDropFinished

import sun.awt.SunToolkit; //导入依赖的package包/类
/**
 * upcall from native code via implemented class (do)
 */

protected final void dragDropFinished(final boolean success,
                                      final int operations,
                                      final int x, final int y) {
    DragSourceEvent event =
        new DragSourceDropEvent(getDragSourceContext(),
                                operations & sourceActions,
                                success, x, y);
    EventDispatcher dispatcher =
        new EventDispatcher(DISPATCH_FINISH, event);

    SunToolkit.invokeLaterOnAppContext(
        SunToolkit.targetToAppContext(getComponent()), dispatcher);

    startSecondaryEventLoop();
    setNativeContext(0);
    dragImage = null;
    dragImageOffset = null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:SunDragSourceContextPeer.java

示例14: drawLine

import sun.awt.SunToolkit; //导入依赖的package包/类
public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) {
    Region compClip = sg2d.getCompClip();
    int transX1 = Region.clipAdd(x1, sg2d.transX);
    int transY1 = Region.clipAdd(y1, sg2d.transY);
    int transX2 = Region.clipAdd(x2, sg2d.transX);
    int transY2 = Region.clipAdd(y2, sg2d.transY);

    SunToolkit.awtLock();
    try {
        validateSurface(sg2d);
        lineGen.rasterizeLine(rectBuffer, transX1, transY1,
                transX2, transY2, compClip.getLoX(), compClip.getLoY(),
                compClip.getHiX(), compClip.getHiY(), true, true);
        tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:XRRenderer.java

示例15: Blit

import sun.awt.SunToolkit; //导入依赖的package包/类
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int sx, int sy,
                 int dx, int dy,
                 int w, int h)
{
    SunToolkit.awtLock();
    try {
        X11SurfaceData x11sd = (X11SurfaceData)dst;
        // pass null clip region here since we clip manually in native code
        // also use false for needExposures since we clip to the pixmap
        long xgc = x11sd.getBlitGC(null, false);
        nativeBlit(src.getNativeOps(), dst.getNativeOps(), xgc, clip,
                   sx, sy, dx, dy, w, h);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:X11PMBlitLoops.java


注:本文中的sun.awt.SunToolkit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。