Search in sources :

Example 41 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class Dialog method modalityPopped.

final void modalityPopped() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if (tk instanceof SunToolkit) {
        SunToolkit stk = (SunToolkit) tk;
        stk.notifyModalityPopped(this);
    }
}
Also used : SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit)

Example 42 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class DefaultDesktopManager method dragFrameFaster.

// =========== stuff for faster frame dragging ===================
private void dragFrameFaster(JComponent f, int newX, int newY) {
    Rectangle previousBounds = new Rectangle(currentBounds.x, currentBounds.y, currentBounds.width, currentBounds.height);
    // move the frame
    currentBounds.x = newX;
    currentBounds.y = newY;
    if (didDrag) {
        // Only initiate cleanup if we have actually done a drag.
        emergencyCleanup(f);
    } else {
        didDrag = true;
        // We reset the danger field as until now we haven't actually
        // moved the internal frame so we don't need to initiate repaint.
        ((JInternalFrame) f).danger = false;
    }
    boolean floaterCollision = isFloaterCollision(previousBounds, currentBounds);
    JComponent parent = (JComponent) f.getParent();
    Rectangle visBounds = previousBounds.intersection(desktopBounds);
    RepaintManager currentManager = RepaintManager.currentManager(f);
    currentManager.beginPaint();
    try {
        if (!floaterCollision) {
            currentManager.copyArea(parent, desktopGraphics, visBounds.x, visBounds.y, visBounds.width, visBounds.height, newX - previousBounds.x, newY - previousBounds.y, true);
        }
        f.setBounds(currentBounds);
        if (!floaterCollision) {
            Rectangle r = currentBounds;
            currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height);
        }
        if (floaterCollision) {
            // since we couldn't blit we just redraw as fast as possible
            // the isDragging mucking is to avoid activating emergency
            // cleanup
            ((JInternalFrame) f).isDragging = false;
            parent.paintImmediately(currentBounds);
            ((JInternalFrame) f).isDragging = true;
        }
        // fake out the repaint manager.  We'll take care of everything
        currentManager.markCompletelyClean(parent);
        currentManager.markCompletelyClean(f);
        // compute the minimal newly exposed area
        // if the rects intersect then we use computeDifference.  Otherwise
        // we'll repaint the entire previous bounds
        Rectangle[] dirtyRects = null;
        if (previousBounds.intersects(currentBounds)) {
            dirtyRects = SwingUtilities.computeDifference(previousBounds, currentBounds);
        } else {
            dirtyRects = new Rectangle[1];
            dirtyRects[0] = previousBounds;
        }
        ;
        // Fix the damage
        for (int i = 0; i < dirtyRects.length; i++) {
            parent.paintImmediately(dirtyRects[i]);
            Rectangle r = dirtyRects[i];
            currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height);
        }
        // new areas of blit were exposed
        if (!(visBounds.equals(previousBounds))) {
            dirtyRects = SwingUtilities.computeDifference(previousBounds, desktopBounds);
            for (int i = 0; i < dirtyRects.length; i++) {
                dirtyRects[i].x += newX - previousBounds.x;
                dirtyRects[i].y += newY - previousBounds.y;
                ((JInternalFrame) f).isDragging = false;
                parent.paintImmediately(dirtyRects[i]);
                ((JInternalFrame) f).isDragging = true;
                Rectangle r = dirtyRects[i];
                currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height);
            }
        }
    } finally {
        currentManager.endPaint();
    }
    // update window if it's non-opaque
    Window topLevel = SwingUtilities.getWindowAncestor(f);
    Toolkit tk = Toolkit.getDefaultToolkit();
    if (!topLevel.isOpaque() && (tk instanceof SunToolkit) && ((SunToolkit) tk).needUpdateWindow()) {
        AWTAccessor.getWindowAccessor().updateWindow(topLevel);
    }
}
Also used : SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit)

Example 43 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class RepaintManager method _getOffscreenBuffer.

private Image _getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight) {
    Dimension maxSize = getDoubleBufferMaximumSize();
    DoubleBufferInfo doubleBuffer;
    int width, height;
    // If the window is non-opaque, it's double-buffered at peer's level
    Window w = (c instanceof Window) ? (Window) c : SwingUtilities.getWindowAncestor(c);
    if (!w.isOpaque()) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        if ((tk instanceof SunToolkit) && (((SunToolkit) tk).needUpdateWindow())) {
            return null;
        }
    }
    if (standardDoubleBuffer == null) {
        standardDoubleBuffer = new DoubleBufferInfo();
    }
    doubleBuffer = standardDoubleBuffer;
    width = proposedWidth < 1 ? 1 : (proposedWidth > maxSize.width ? maxSize.width : proposedWidth);
    height = proposedHeight < 1 ? 1 : (proposedHeight > maxSize.height ? maxSize.height : proposedHeight);
    if (doubleBuffer.needsReset || (doubleBuffer.image != null && (doubleBuffer.size.width < width || doubleBuffer.size.height < height))) {
        doubleBuffer.needsReset = false;
        if (doubleBuffer.image != null) {
            doubleBuffer.image.flush();
            doubleBuffer.image = null;
        }
        width = Math.max(doubleBuffer.size.width, width);
        height = Math.max(doubleBuffer.size.height, height);
    }
    Image result = doubleBuffer.image;
    if (doubleBuffer.image == null) {
        result = c.createImage(width, height);
        doubleBuffer.size = new Dimension(width, height);
        if (c instanceof JComponent) {
            ((JComponent) c).setCreatedDoubleBuffer(true);
            doubleBuffer.image = result;
        }
    // JComponent will inform us when it is no longer valid
    // (via removeNotify) we have no such hook to other components,
    // therefore we don't keep a ref to the Component
    // (indirectly through the Image) by stashing the image.
    }
    return result;
}
Also used : SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit) VolatileImage(java.awt.image.VolatileImage)

Example 44 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class RepaintManager method updateWindows.

private void updateWindows(Map<Component, Rectangle> dirtyComponents) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (!(toolkit instanceof SunToolkit && ((SunToolkit) toolkit).needUpdateWindow())) {
        return;
    }
    Set<Window> windows = new HashSet<Window>();
    Set<Component> dirtyComps = dirtyComponents.keySet();
    for (Iterator<Component> it = dirtyComps.iterator(); it.hasNext(); ) {
        Component dirty = it.next();
        Window window = dirty instanceof Window ? (Window) dirty : SwingUtilities.getWindowAncestor(dirty);
        if (window != null && !window.isOpaque()) {
            windows.add(window);
        }
    }
    for (Window window : windows) {
        AWTAccessor.getWindowAccessor().updateWindow(window);
    }
}
Also used : SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit)

Example 45 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class RepaintManager method getPaintManager.

private synchronized PaintManager getPaintManager() {
    if (paintManager == null) {
        PaintManager paintManager = null;
        if (doubleBufferingEnabled && !nativeDoubleBuffering) {
            switch(bufferStrategyType) {
                case BUFFER_STRATEGY_NOT_SPECIFIED:
                    Toolkit tk = Toolkit.getDefaultToolkit();
                    if (tk instanceof SunToolkit) {
                        SunToolkit stk = (SunToolkit) tk;
                        if (stk.useBufferPerWindow()) {
                            paintManager = new BufferStrategyPaintManager();
                        }
                    }
                    break;
                case BUFFER_STRATEGY_SPECIFIED_ON:
                    paintManager = new BufferStrategyPaintManager();
                    break;
                default:
                    break;
            }
        }
        // null case handled in setPaintManager
        setPaintManager(paintManager);
    }
    return paintManager;
}
Also used : SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit)

Aggregations

SunToolkit (sun.awt.SunToolkit)120 Robot (java.awt.Robot)26 Point (java.awt.Point)9 Frame (java.awt.Frame)7 JFrame (javax.swing.JFrame)7 BufferedImage (java.awt.image.BufferedImage)5 Rectangle (java.awt.Rectangle)4 FlowLayout (java.awt.FlowLayout)3 TextField (java.awt.TextField)3 Toolkit (java.awt.Toolkit)3 MouseEvent (java.awt.event.MouseEvent)3 JTableHeader (javax.swing.table.JTableHeader)3 Component (java.awt.Component)2 KeyEvent (java.awt.event.KeyEvent)2 VolatileImage (java.awt.image.VolatileImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 URL (java.net.URL)2