java.awt.peer.ListPeer Java Examples

The following examples show how to use java.awt.peer.ListPeer. 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: List.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
 
Example #2
Source File: ListRepaint.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
void test() {
    select(0);
    ((ListPeer) getPeer()).select(getSelectedIndex());

    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 #3
Source File: List.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #4
Source File: List.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
 
Example #5
Source File: List.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #6
Source File: ListRepaint.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
void test() {
    select(0);
    ((ListPeer) getPeer()).select(getSelectedIndex());

    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 #7
Source File: List.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #8
Source File: List.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
 
Example #9
Source File: ListRepaint.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
void test() {
    select(0);
    ((ListPeer) getPeer()).select(getSelectedIndex());

    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 #10
Source File: List.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #11
Source File: List.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #12
Source File: List.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #13
Source File: List.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #14
Source File: List.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
 
Example #15
Source File: List.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
 
Example #16
Source File: List.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #17
Source File: List.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #18
Source File: List.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deselects the item at the specified index.
 * <p>
 * Note that passing out of range parameters is invalid,
 * and will result in unspecified behavior.
 * <p>
 * If the item at the specified index is not selected,
 * then the operation is ignored.
 * @param        index the position of the item to deselect
 * @see          #select
 * @see          #getSelectedItem
 * @see          #isIndexSelected
 */
public synchronized void deselect(int index) {
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        if (isMultipleMode() || (getSelectedIndex() == index)) {
            peer.deselect(index);
        }
    }

    for (int i = 0 ; i < selected.length ; i++) {
        if (selected[i] == index) {
            int newsel[] = new int[selected.length - 1];
            System.arraycopy(selected, 0, newsel, 0, i);
            System.arraycopy(selected, i+1, newsel, i, selected.length - (i+1));
            selected = newsel;
            return;
        }
    }
}
 
Example #19
Source File: List.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @deprecated      replaced by <code>add(String, int)</code>.
 */
@Deprecated
public synchronized void addItem(String item, int index) {
    if (index < -1 || index >= items.size()) {
        index = -1;
    }

    if (item == null) {
        item = "";
    }

    if (index == -1) {
        items.addElement(item);
    } else {
        items.insertElementAt(item, index);
    }

    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.add(item, index);
    }
}
 
Example #20
Source File: List.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the peer for this list.  The peer allows us to modify the
 * list's appearance without changing its functionality.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        ListPeer peer = (ListPeer)this.peer;
        if (peer != null) {
            selected = peer.getSelectedIndexes();
        }
        super.removeNotify();
    }
}
 
Example #21
Source File: List.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated As of JDK version 1.1,
 * replaced by <code>getMinimumSize(int)</code>.
 */
@Deprecated
public Dimension minimumSize(int rows) {
    synchronized (getTreeLock()) {
        ListPeer peer = (ListPeer)this.peer;
        return (peer != null) ?
                   peer.getMinimumSize(rows) :
                   super.minimumSize();
    }
}
 
Example #22
Source File: List.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the minimum dimensions for the list
 * with the specified number of rows.
 *
 * @param  rows the number of rows in the list
 * @return the minimum dimensions for displaying this list
 * @deprecated As of JDK version 1.1,
 * replaced by {@code getMinimumSize(int)}.
 */
@Deprecated
public Dimension minimumSize(int rows) {
    synchronized (getTreeLock()) {
        ListPeer peer = (ListPeer)this.peer;
        return (peer != null) ?
                   peer.getMinimumSize(rows) :
                   super.minimumSize();
    }
}
 
Example #23
Source File: List.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the peer for this list.  The peer allows us to modify the
 * list's appearance without changing its functionality.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        ListPeer peer = (ListPeer)this.peer;
        if (peer != null) {
            selected = peer.getSelectedIndexes();
        }
        super.removeNotify();
    }
}
 
Example #24
Source File: List.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * @deprecated As of JDK version 1.1,
 * replaced by <code>getMinimumSize(int)</code>.
 */
@Deprecated
public Dimension minimumSize(int rows) {
    synchronized (getTreeLock()) {
        ListPeer peer = (ListPeer)this.peer;
        return (peer != null) ?
                   peer.getMinimumSize(rows) :
                   super.minimumSize();
    }
}
 
Example #25
Source File: List.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the peer for this list.  The peer allows us to modify the
 * list's appearance without changing its functionality.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        ListPeer peer = (ListPeer)this.peer;
        if (peer != null) {
            selected = peer.getSelectedIndexes();
        }
        super.removeNotify();
    }
}
 
Example #26
Source File: List.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the peer for this list.  The peer allows us to modify the
 * list's appearance without changing its functionality.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        ListPeer peer = (ListPeer)this.peer;
        if (peer != null) {
            selected = peer.getSelectedIndexes();
        }
        super.removeNotify();
    }
}
 
Example #27
Source File: List.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Removes the peer for this list.  The peer allows us to modify the
 * list's appearance without changing its functionality.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        ListPeer peer = (ListPeer)this.peer;
        if (peer != null) {
            selected = peer.getSelectedIndexes();
        }
        super.removeNotify();
    }
}
 
Example #28
Source File: List.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Makes the item at the specified index visible.
 * @param       index    the position of the item
 * @see         #getVisibleIndex
 */
public synchronized void makeVisible(int index) {
    visibleIndex = index;
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.makeVisible(index);
    }
}
 
Example #29
Source File: List.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * @deprecated As of JDK version 1.1,
 * replaced by <code>setMultipleMode(boolean)</code>.
 */
@Deprecated
public synchronized void setMultipleSelections(boolean b) {
    if (b != multipleMode) {
        multipleMode = b;
        ListPeer peer = (ListPeer)this.peer;
        if (peer != null) {
            peer.setMultipleMode(b);
        }
    }
}
 
Example #30
Source File: List.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @deprecated As of JDK version 1.1,
 * Not for public use in the future.
 * This method is expected to be retained only as a package
 * private method.
 */
@Deprecated
public synchronized void delItems(int start, int end) {
    for (int i = end; i >= start; i--) {
        items.removeElementAt(i);
    }
    ListPeer peer = (ListPeer)this.peer;
    if (peer != null) {
        peer.delItems(start, end);
    }
}