Java Code Examples for java.awt.peer.ButtonPeer

The following examples show how to use java.awt.peer.ButtonPeer. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: jdk1.8-source-analysis   Source File: Button.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 2
Source Project: dragonwell8_jdk   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 3
public void instrumentPeer() {
    origPeer = (ButtonPeer) getPeer();
    InvocationHandler handler = new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("requestFocus")) {
                Container parent = getParent();
                parent.remove(TestButton.this);
                System.err.println("parent = " + parent);
                System.err.println("target = " + TestButton.this);
                System.err.println("new parent = " + TestButton.this.getParent());
            }
            Object ret = null;
            try {
                ret = method.invoke(origPeer, args);
            } catch (IllegalAccessException iae) {
                throw new Error("Test error.", iae);
            } catch (InvocationTargetException ita) {
                throw new Error("Test error.", ita);
            }
            return ret;
        }
    };

    proxiedPeer = (ButtonPeer) Proxy.newProxyInstance(ButtonPeer.class.getClassLoader(), new Class[] {ButtonPeer.class}, handler);
    setPeer(proxiedPeer);
}
 
Example 4
void test() {
    setLabel("");
    setLabel(null);
    setLabel(getLabel());
    ((ButtonPeer) getPeer()).setLabel("");
    ((ButtonPeer) getPeer()).setLabel(null);
    ((ButtonPeer) getPeer()).setLabel(getLabel());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
 
Example 5
Source Project: TencentKona-8   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 6
public void instrumentPeer() {
    origPeer = (ButtonPeer) getPeer();
    InvocationHandler handler = new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("requestFocus")) {
                Container parent = getParent();
                parent.remove(TestButton.this);
                System.err.println("parent = " + parent);
                System.err.println("target = " + TestButton.this);
                System.err.println("new parent = " + TestButton.this.getParent());
            }
            Object ret = null;
            try {
                ret = method.invoke(origPeer, args);
            } catch (IllegalAccessException iae) {
                throw new Error("Test error.", iae);
            } catch (InvocationTargetException ita) {
                throw new Error("Test error.", ita);
            }
            return ret;
        }
    };

    proxiedPeer = (ButtonPeer) Proxy.newProxyInstance(ButtonPeer.class.getClassLoader(), new Class[] {ButtonPeer.class}, handler);
    setPeer(proxiedPeer);
}
 
Example 7
Source Project: TencentKona-8   Source File: ButtonRepaint.java    License: GNU General Public License v2.0 6 votes vote down vote up
void test() {
    setLabel("");
    setLabel(null);
    setLabel(getLabel());
    ((ButtonPeer) getPeer()).setLabel("");
    ((ButtonPeer) getPeer()).setLabel(null);
    ((ButtonPeer) getPeer()).setLabel(getLabel());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
 
Example 8
Source Project: jdk8u60   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 9
public void instrumentPeer() {
    origPeer = (ButtonPeer) getPeer();
    InvocationHandler handler = new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("requestFocus")) {
                Container parent = getParent();
                parent.remove(TestButton.this);
                System.err.println("parent = " + parent);
                System.err.println("target = " + TestButton.this);
                System.err.println("new parent = " + TestButton.this.getParent());
            }
            Object ret = null;
            try {
                ret = method.invoke(origPeer, args);
            } catch (IllegalAccessException iae) {
                throw new Error("Test error.", iae);
            } catch (InvocationTargetException ita) {
                throw new Error("Test error.", ita);
            }
            return ret;
        }
    };

    proxiedPeer = (ButtonPeer) Proxy.newProxyInstance(ButtonPeer.class.getClassLoader(), new Class[] {ButtonPeer.class}, handler);
    setPeer(proxiedPeer);
}
 
Example 10
Source Project: jdk8u60   Source File: ButtonRepaint.java    License: GNU General Public License v2.0 6 votes vote down vote up
void test() {
    setLabel("");
    setLabel(null);
    setLabel(getLabel());
    ((ButtonPeer) getPeer()).setLabel("");
    ((ButtonPeer) getPeer()).setLabel(null);
    ((ButtonPeer) getPeer()).setLabel(getLabel());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
 
Example 11
Source Project: JDKSourceCode1.8   Source File: Button.java    License: MIT License 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 12
Source Project: openjdk-jdk8u   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 13
public void instrumentPeer() {
    origPeer = (ButtonPeer) getPeer();
    InvocationHandler handler = new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("requestFocus")) {
                Container parent = getParent();
                parent.remove(TestButton.this);
                System.err.println("parent = " + parent);
                System.err.println("target = " + TestButton.this);
                System.err.println("new parent = " + TestButton.this.getParent());
            }
            Object ret = null;
            try {
                ret = method.invoke(origPeer, args);
            } catch (IllegalAccessException iae) {
                throw new Error("Test error.", iae);
            } catch (InvocationTargetException ita) {
                throw new Error("Test error.", ita);
            }
            return ret;
        }
    };

    proxiedPeer = (ButtonPeer) Proxy.newProxyInstance(ButtonPeer.class.getClassLoader(), new Class[] {ButtonPeer.class}, handler);
    setPeer(proxiedPeer);
}
 
Example 14
Source Project: openjdk-jdk8u   Source File: ButtonRepaint.java    License: GNU General Public License v2.0 6 votes vote down vote up
void test() {
    setLabel("");
    setLabel(null);
    setLabel(getLabel());
    ((ButtonPeer) getPeer()).setLabel("");
    ((ButtonPeer) getPeer()).setLabel(null);
    ((ButtonPeer) getPeer()).setLabel(getLabel());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
 
Example 15
Source Project: openjdk-jdk8u-backup   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 16
public void instrumentPeer() {
    origPeer = (ButtonPeer) getPeer();
    InvocationHandler handler = new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("requestFocus")) {
                Container parent = getParent();
                parent.remove(TestButton.this);
                System.err.println("parent = " + parent);
                System.err.println("target = " + TestButton.this);
                System.err.println("new parent = " + TestButton.this.getParent());
            }
            Object ret = null;
            try {
                ret = method.invoke(origPeer, args);
            } catch (IllegalAccessException iae) {
                throw new Error("Test error.", iae);
            } catch (InvocationTargetException ita) {
                throw new Error("Test error.", ita);
            }
            return ret;
        }
    };

    proxiedPeer = (ButtonPeer) Proxy.newProxyInstance(ButtonPeer.class.getClassLoader(), new Class[] {ButtonPeer.class}, handler);
    setPeer(proxiedPeer);
}
 
Example 17
void test() {
    setLabel("");
    setLabel(null);
    setLabel(getLabel());
    ((ButtonPeer) getPeer()).setLabel("");
    ((ButtonPeer) getPeer()).setLabel(null);
    ((ButtonPeer) getPeer()).setLabel(getLabel());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
 
Example 18
Source Project: Bytecoder   Source File: Button.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or {@code null}
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 19
Source Project: openjdk-jdk9   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or {@code null}
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 20
Source Project: jdk8u-jdk   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 21
public void instrumentPeer() {
    origPeer = (ButtonPeer) getPeer();
    InvocationHandler handler = new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("requestFocus")) {
                Container parent = getParent();
                parent.remove(TestButton.this);
                System.err.println("parent = " + parent);
                System.err.println("target = " + TestButton.this);
                System.err.println("new parent = " + TestButton.this.getParent());
            }
            Object ret = null;
            try {
                ret = method.invoke(origPeer, args);
            } catch (IllegalAccessException iae) {
                throw new Error("Test error.", iae);
            } catch (InvocationTargetException ita) {
                throw new Error("Test error.", ita);
            }
            return ret;
        }
    };

    proxiedPeer = (ButtonPeer) Proxy.newProxyInstance(ButtonPeer.class.getClassLoader(), new Class[] {ButtonPeer.class}, handler);
    setPeer(proxiedPeer);
}
 
Example 22
Source Project: jdk8u-jdk   Source File: ButtonRepaint.java    License: GNU General Public License v2.0 6 votes vote down vote up
void test() {
    setLabel("");
    setLabel(null);
    setLabel(getLabel());
    ((ButtonPeer) getPeer()).setLabel("");
    ((ButtonPeer) getPeer()).setLabel(null);
    ((ButtonPeer) getPeer()).setLabel(getLabel());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
 
Example 23
Source Project: Java8CN   Source File: Button.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 24
Source Project: hottub   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 25
public void instrumentPeer() {
    origPeer = (ButtonPeer) getPeer();
    InvocationHandler handler = new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("requestFocus")) {
                Container parent = getParent();
                parent.remove(TestButton.this);
                System.err.println("parent = " + parent);
                System.err.println("target = " + TestButton.this);
                System.err.println("new parent = " + TestButton.this.getParent());
            }
            Object ret = null;
            try {
                ret = method.invoke(origPeer, args);
            } catch (IllegalAccessException iae) {
                throw new Error("Test error.", iae);
            } catch (InvocationTargetException ita) {
                throw new Error("Test error.", ita);
            }
            return ret;
        }
    };

    proxiedPeer = (ButtonPeer) Proxy.newProxyInstance(ButtonPeer.class.getClassLoader(), new Class[] {ButtonPeer.class}, handler);
    setPeer(proxiedPeer);
}
 
Example 26
Source Project: hottub   Source File: ButtonRepaint.java    License: GNU General Public License v2.0 6 votes vote down vote up
void test() {
    setLabel("");
    setLabel(null);
    setLabel(getLabel());
    ((ButtonPeer) getPeer()).setLabel("");
    ((ButtonPeer) getPeer()).setLabel(null);
    ((ButtonPeer) getPeer()).setLabel(getLabel());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
 
Example 27
Source Project: openjdk-8-source   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}
 
Example 28
public void instrumentPeer() {
    origPeer = (ButtonPeer) getPeer();
    InvocationHandler handler = new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) {
            if (method.getName().equals("requestFocus")) {
                Container parent = getParent();
                parent.remove(TestButton.this);
                System.err.println("parent = " + parent);
                System.err.println("target = " + TestButton.this);
                System.err.println("new parent = " + TestButton.this.getParent());
            }
            Object ret = null;
            try {
                ret = method.invoke(origPeer, args);
            } catch (IllegalAccessException iae) {
                throw new Error("Test error.", iae);
            } catch (InvocationTargetException ita) {
                throw new Error("Test error.", ita);
            }
            return ret;
        }
    };

    proxiedPeer = (ButtonPeer) Proxy.newProxyInstance(ButtonPeer.class.getClassLoader(), new Class[] {ButtonPeer.class}, handler);
    setPeer(proxiedPeer);
}
 
Example 29
void test() {
    setLabel("");
    setLabel(null);
    setLabel(getLabel());
    ((ButtonPeer) getPeer()).setLabel("");
    ((ButtonPeer) getPeer()).setLabel(null);
    ((ButtonPeer) getPeer()).setLabel(getLabel());

    setFont(null);
    setFont(getFont());
    getPeer().setFont(getFont());

    setBackground(null);
    setBackground(getBackground());
    getPeer().setBackground(getBackground());

    setForeground(null);
    setForeground(getForeground());
    getPeer().setForeground(getForeground());

    setEnabled(isEnabled());
    getPeer().setEnabled(isEnabled());
}
 
Example 30
Source Project: openjdk-8   Source File: Button.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the button's label to be the specified string.
 *
 * @param     label   the new label, or <code>null</code>
 *                if the button has no label.
 * @see       java.awt.Button#getLabel
 */
public void setLabel(String label) {
    boolean testvalid = false;

    synchronized (this) {
        if (label != this.label && (this.label == null ||
                                    !this.label.equals(label))) {
            this.label = label;
            ButtonPeer peer = (ButtonPeer)this.peer;
            if (peer != null) {
                peer.setLabel(label);
            }
            testvalid = true;
        }
    }

    // This could change the preferred size of the Component.
    if (testvalid) {
        invalidateIfValid();
    }
}