Java Code Examples for javax.swing.JPasswordField#isEnabled()

The following examples show how to use javax.swing.JPasswordField#isEnabled() . 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: PasswordView.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate >= 0
 * @param y the starting Y coordinate >= 0
 * @param p0 the starting offset in the model >= 0
 * @param p1 the ending offset in the model >= p0
 * @return the X location of the end of the range >= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 2
Source File: PasswordView.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 3
Source File: PasswordView.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 4
Source File: PasswordView.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 5
Source File: PasswordView.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 6
Source File: PasswordView.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 7
Source File: PasswordView.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 8
Source File: PasswordView.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 9
Source File: PasswordView.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 10
Source File: PasswordView.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 11
Source File: PasswordView.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 12
Source File: PasswordView.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 13
Source File: PasswordView.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 14
Source File: PasswordView.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Renders the given range in the model as normal unselected
 * text.  This sets the foreground color and echos the characters
 * using the value returned by getEchoChar().
 *
 * @param g the graphics context
 * @param x the starting X coordinate &gt;= 0
 * @param y the starting Y coordinate &gt;= 0
 * @param p0 the starting offset in the model &gt;= 0
 * @param p1 the ending offset in the model &gt;= p0
 * @return the X location of the end of the range &gt;= 0
 * @exception BadLocationException if p0 or p1 are out of range
 */
protected int drawUnselectedText(Graphics g, int x, int y,
                                 int p0, int p1) throws BadLocationException {

    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (! f.echoCharIsSet()) {
            return super.drawUnselectedText(g, x, y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        for (int i = 0; i < n; i++) {
            x = drawEchoCharacter(g, x, y, echoChar);
        }
    }
    return x;
}
 
Example 15
Source File: PasswordView.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private float drawUnselectedTextImpl(Graphics g, float x, float y,
                                     int p0, int p1,
                                     boolean useFPAPI)
        throws BadLocationException
{
    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (!f.echoCharIsSet()) {
            boolean useDrawUnselectedFPAPI = useFPAPI
                    && drawUnselectedTextOverridden
                    && g instanceof Graphics2D;
            return (useDrawUnselectedFPAPI )
                    ? super.drawUnselectedText((Graphics2D) g, x, y, p0, p1)
                    : super.drawUnselectedText(g, (int) x, (int) y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        boolean useEchoCharFPAPI = useFPAPI
                && drawEchoCharacterOverridden
                && g instanceof Graphics2D;
        for (int i = 0; i < n; i++) {
            x = (useEchoCharFPAPI)
                    ? drawEchoCharacter((Graphics2D) g, x, y, echoChar)
                    : drawEchoCharacter(g, (int) x, (int) y, echoChar);
        }
    }
    return x;
}
 
Example 16
Source File: PasswordView.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private float drawUnselectedTextImpl(Graphics g, float x, float y,
                                     int p0, int p1,
                                     boolean useFPAPI)
        throws BadLocationException
{
    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (!f.echoCharIsSet()) {
            boolean useDrawUnselectedFPAPI = useFPAPI
                    && drawUnselectedTextOverridden
                    && g instanceof Graphics2D;
            return (useDrawUnselectedFPAPI )
                    ? super.drawUnselectedText((Graphics2D) g, x, y, p0, p1)
                    : super.drawUnselectedText(g, (int) x, (int) y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        boolean useEchoCharFPAPI = useFPAPI
                && drawEchoCharacterOverridden
                && g instanceof Graphics2D;
        for (int i = 0; i < n; i++) {
            x = (useEchoCharFPAPI)
                    ? drawEchoCharacter((Graphics2D) g, x, y, echoChar)
                    : drawEchoCharacter(g, (int) x, (int) y, echoChar);
        }
    }
    return x;
}
 
Example 17
Source File: PasswordView.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private float drawUnselectedTextImpl(Graphics g, float x, float y,
                                     int p0, int p1,
                                     boolean useFPAPI)
        throws BadLocationException
{
    Container c = getContainer();
    if (c instanceof JPasswordField) {
        JPasswordField f = (JPasswordField) c;
        if (!f.echoCharIsSet()) {
            boolean useDrawUnselectedFPAPI = useFPAPI
                    && drawUnselectedTextOverridden
                    && g instanceof Graphics2D;
            return (useDrawUnselectedFPAPI )
                    ? super.drawUnselectedText((Graphics2D) g, x, y, p0, p1)
                    : super.drawUnselectedText(g, (int) x, (int) y, p0, p1);
        }
        if (f.isEnabled()) {
            g.setColor(f.getForeground());
        }
        else {
            g.setColor(f.getDisabledTextColor());
        }
        char echoChar = f.getEchoChar();
        int n = p1 - p0;
        boolean useEchoCharFPAPI = useFPAPI
                && drawEchoCharacterOverridden
                && g instanceof Graphics2D;
        for (int i = 0; i < n; i++) {
            x = (useEchoCharFPAPI)
                    ? drawEchoCharacter((Graphics2D) g, x, y, echoChar)
                    : drawEchoCharacter(g, (int) x, (int) y, echoChar);
        }
    }
    return x;
}