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


Java SunToolkit.isInstanceOf方法代码示例

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


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

示例1: 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:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:JLayeredPane.java

示例2: setLayersOpaque

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private static void setLayersOpaque(Component component, boolean isOpaque) {
    // Shouldn't use instanceof to avoid loading Swing classes
    //    if it's a pure AWT application.
    if (SunToolkit.isInstanceOf(component, "javax.swing.RootPaneContainer")) {
        javax.swing.RootPaneContainer rpc = (javax.swing.RootPaneContainer)component;
        javax.swing.JRootPane root = rpc.getRootPane();
        javax.swing.JLayeredPane lp = root.getLayeredPane();
        Container c = root.getContentPane();
        javax.swing.JComponent content =
            (c instanceof javax.swing.JComponent) ? (javax.swing.JComponent)c : null;
        lp.setOpaque(isOpaque);
        root.setOpaque(isOpaque);
        if (content != null) {
            content.setOpaque(isOpaque);

            // Iterate down one level to see whether we have a JApplet
            // (which is also a RootPaneContainer) which requires processing
            int numChildren = content.getComponentCount();
            if (numChildren > 0) {
                Component child = content.getComponent(0);
                // It's OK to use instanceof here because we've
                // already loaded the RootPaneContainer class by now
                if (child instanceof javax.swing.RootPaneContainer) {
                    setLayersOpaque(child, isOpaque);
                }
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:Window.java

示例3: setComponentDropLocation

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private void setComponentDropLocation(TransferSupport support,
                                      boolean forDrop) {

    DropLocation dropLocation = (support == null)
                                ? null
                                : support.getDropLocation();

    if (SunToolkit.isInstanceOf(component, "javax.swing.text.JTextComponent")) {
        state = SwingAccessor.getJTextComponentAccessor().
                    setDropLocation((JTextComponent)component, dropLocation, state, forDrop);
    } else if (component instanceof JComponent) {
        state = ((JComponent)component).setDropLocation(dropLocation, state, forDrop);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:TransferHandler.java

示例4: fetchRoot

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private Container fetchRoot(JComponent c) {
    boolean encounteredHW = false;
    rootJ = c;
    Container root = c;
    xOffset = yOffset = 0;
    while (root != null &&
           (!(root instanceof Window) &&
            !SunToolkit.isInstanceOf(root, "java.applet.Applet"))) {
        xOffset += root.getX();
        yOffset += root.getY();
        root = root.getParent();
        if (root != null) {
            if (root instanceof JComponent) {
                rootJ = (JComponent)root;
            }
            else if (!root.isLightweight()) {
                if (!encounteredHW) {
                    encounteredHW = true;
                }
                else {
                    // We've encountered two hws now and may have
                    // a containment hierarchy with lightweights containing
                    // heavyweights containing other lightweights.
                    // Heavyweights poke holes in lightweight
                    // rendering so that if we call show on the BS
                    // (which is associated with the Window) you will
                    // not see the contents over any child
                    // heavyweights.  If we didn't do this when we
                    // went to show the descendants of the nested hw
                    // you would see nothing, so, we bail out here.
                    return null;
                }
            }
        }
    }
    if ((root instanceof RootPaneContainer) &&
        (rootJ instanceof JRootPane)) {
        // We're in a Swing heavyeight (JFrame/JWindow...), use double
        // buffering if double buffering enabled on the JRootPane and
        // the JRootPane wants true double buffering.
        if (rootJ.isDoubleBuffered() &&
                ((JRootPane)rootJ).getUseTrueDoubleBuffering()) {
            // Whether or not a component is double buffered is a
            // bit tricky with Swing. This gives a good approximation
            // of the various ways to turn on double buffering for
            // components.
            return root;
        }
    }
    // Don't do true double buffering.
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:BufferStrategyPaintManager.java

示例5: accept

import sun.awt.SunToolkit; //导入方法依赖的package包/类
/**
 * Determines whether the specified <code>Component</code>
 * is an acceptable choice as the new focus owner.
 * This method performs the following sequence of operations:
 * <ol>
 * <li>Checks whether <code>aComponent</code> is visible, displayable,
 *     enabled, and focusable.  If any of these properties is
 *     <code>false</code>, this method returns <code>false</code>.
 * <li>If <code>aComponent</code> is an instance of <code>JTable</code>,
 *     returns <code>true</code>.
 * <li>If <code>aComponent</code> is an instance of <code>JComboBox</code>,
 *     then returns the value of
 *     <code>aComponent.getUI().isFocusTraversable(aComponent)</code>.
 * <li>If <code>aComponent</code> is a <code>JComponent</code>
 *     with a <code>JComponent.WHEN_FOCUSED</code>
 *     <code>InputMap</code> that is neither <code>null</code>
 *     nor empty, returns <code>true</code>.
 * <li>Returns the value of
 *     <code>DefaultFocusTraversalPolicy.accept(aComponent)</code>.
 * </ol>
 *
 * @param aComponent the <code>Component</code> whose fitness
 *                   as a focus owner is to be tested
 * @see java.awt.Component#isVisible
 * @see java.awt.Component#isDisplayable
 * @see java.awt.Component#isEnabled
 * @see java.awt.Component#isFocusable
 * @see javax.swing.plaf.ComboBoxUI#isFocusTraversable
 * @see javax.swing.JComponent#getInputMap
 * @see java.awt.DefaultFocusTraversalPolicy#accept
 * @return <code>true</code> if <code>aComponent</code> is a valid choice
 *         for a focus owner;
 *         otherwise <code>false</code>
 */
 protected boolean accept(Component aComponent) {
    if (!super.accept(aComponent)) {
        return false;
    } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JTable")) {
        // JTable only has ancestor focus bindings, we thus force it
        // to be focusable by returning true here.
        return true;
    } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JComboBox")) {
        JComboBox box = (JComboBox)aComponent;
        return box.getUI().isFocusTraversable(box);
    } else if (aComponent instanceof JComponent) {
        JComponent jComponent = (JComponent)aComponent;
        InputMap inputMap = jComponent.getInputMap(JComponent.WHEN_FOCUSED,
                                                   false);
        while (inputMap != null && inputMap.size() == 0) {
            inputMap = inputMap.getParent();
        }
        if (inputMap != null) {
            return true;
        }
        // Delegate to the fitnessTestPolicy, this will test for the
        // case where the developer has overriden isFocusTraversable to
        // return true.
    }
    return fitnessTestPolicy.accept(aComponent);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:LayoutFocusTraversalPolicy.java

示例6: installProperty

import sun.awt.SunToolkit; //导入方法依赖的package包/类
/**
 * Convenience method for installing a property with the specified name
 * and value on a component if that property has not already been set
 * by the developer.  This method is intended to be used by
 * ui delegate instances that need to specify a default value for a
 * property of primitive type (boolean, int, ..), but do not wish
 * to override a value set by the client.  Since primitive property
 * values cannot be wrapped with the {@code UIResource} marker, this method
 * uses private state to determine whether the property has been set
 * by the client.
 *
 * @throws IllegalArgumentException if the specified property is not
 *         one which can be set using this method
 * @throws ClassCastException if the property value has not been set
 *         by the developer and the type does not match the property's type
 * @throws NullPointerException if {@code c} is {@code null}, or the
 *         named property has not been set by the developer and
 *         {@code propertyValue} is {@code null}
 * @param c target component to set the property on
 * @param propertyName name of the property to set
 * @param propertyValue value of the property
 * @since 1.5
 */
public static void installProperty(JComponent c,
                                   String propertyName, Object propertyValue) {
    // this is a special case because the JPasswordField's ancestor hierarchy
    // includes a class outside of javax.swing, thus we cannot call setUIProperty
    // directly.
    if (SunToolkit.isInstanceOf(c, "javax.swing.JPasswordField")) {
        if (!((JPasswordField)c).customSetUIProperty(propertyName, propertyValue)) {
            c.setUIProperty(propertyName, propertyValue);
        }
    } else {
        c.setUIProperty(propertyName, propertyValue);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:LookAndFeel.java


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