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

The following examples show how to use java.awt.Component#getToolkit() . These examples are extracted from open source projects. 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 Project: netbeans   File: Utilities.java    License: 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 Project: LGoodDatePicker   File: AbstractUnitConverter.java    License: 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 3
Source Project: seaglass   File: MacEditorKit.java    License: 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 4
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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 Project: JDKSourceCode1.8   File: LookAndFeel.java    License: 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 9
/**
 * 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
/**
 * 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 Project: Bytecoder   File: LookAndFeel.java    License: 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
/**
 * 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
/**
 * 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 Project: Java8CN   File: LookAndFeel.java    License: 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 Project: hottub   File: LookAndFeel.java    License: 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
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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();
}