Java Code Examples for java.awt.Component#getToolkit()

The following examples show how to use java.awt.Component#getToolkit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utilities.java    From netbeans with Apache License 2.0 7 votes vote down vote up
public static Cursor createCustomCursor(Component component, Image icon, String name) {
    Toolkit t = component.getToolkit();
    Dimension d = t.getBestCursorSize(16, 16);
    Image i = icon;

    if (d.width != icon.getWidth(null)) {
        if (((d.width) == 0) && (d.height == 0)) {
            // system doesn't support custom cursors, falling back
            return Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
        }

        // need to resize the icon
        Image empty = ImageUtilities.createBufferedImage(d.width, d.height);
        i = ImageUtilities.mergeImages(icon, empty, 0, 0);
    }

    return t.createCustomCursor(i, new Point(1, 1), name);
}
 
Example 2
Source File: MacEditorKit.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation, such as pasting into
 * an uneditable <code>JTextField</code> that has focus. The default
 * implementation beeps. Subclasses that wish different behavior should
 * override this and provide the additional feedback.
 *
 * @param component Component the error occured in, may be null indicating
 *                  the error condition is not directly associated with a
 *                  <code>Component</code>.
 */
static void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;

    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }

    toolkit.beep();
}
 
Example 3
Source File: AbstractUnitConverter.java    From LGoodDatePicker with MIT License 5 votes vote down vote up
/**
 * Returns the components screen resolution or the default screen resolution if the component is
 * null or has no toolkit assigned yet.
 *
 * @param c the component to ask for a toolkit
 * @return the component's screen resolution
 */
protected int getScreenResolution(Component c) {
    if (c == null) {
        return getDefaultScreenResolution();
    }

    Toolkit toolkit = c.getToolkit();
    return toolkit != null
            ? toolkit.getScreenResolution()
            : getDefaultScreenResolution();
}
 
Example 4
Source File: LookAndFeel.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 5
Source File: LookAndFeel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 6
Source File: LookAndFeel.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 7
Source File: LookAndFeel.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 8
Source File: LookAndFeel.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 9
Source File: LookAndFeel.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 10
Source File: LookAndFeel.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 11
Source File: LookAndFeel.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 12
Source File: LookAndFeel.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 13
Source File: LookAndFeel.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 14
Source File: LookAndFeel.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 15
Source File: LookAndFeel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 16
Source File: LookAndFeel.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 17
Source File: LookAndFeel.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 18
Source File: LookAndFeel.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 19
Source File: LookAndFeel.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}
 
Example 20
Source File: LookAndFeel.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Invoked when the user attempts an invalid operation,
 * such as pasting into an uneditable <code>JTextField</code>
 * that has focus. The default implementation beeps. Subclasses
 * that wish different behavior should override this and provide
 * the additional feedback.
 *
 * @param component the <code>Component</code> the error occurred in,
 *                  may be <code>null</code>
 *                  indicating the error condition is not directly
 *                  associated with a <code>Component</code>
 * @since 1.4
 */
public void provideErrorFeedback(Component component) {
    Toolkit toolkit = null;
    if (component != null) {
        toolkit = component.getToolkit();
    } else {
        toolkit = Toolkit.getDefaultToolkit();
    }
    toolkit.beep();
}