src/share/classes/javax/swing/JComboBox.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 658      * @see #setPrototypeDisplayValue
 659      * @since 1.4
 660      */
 661     public E getPrototypeDisplayValue() {
 662         return prototypeDisplayValue;
 663     }
 664 
 665     /**
 666      * Sets the prototype display value used to calculate the size of the display
 667      * for the UI portion.
 668      * <p>
 669      * If a prototype display value is specified, the preferred size of
 670      * the combo box is calculated by configuring the renderer with the
 671      * prototype display value and obtaining its preferred size. Specifying
 672      * the preferred display value is often useful when the combo box will be
 673      * displaying large amounts of data. If no prototype display value has
 674      * been specified, the renderer must be configured for each value from
 675      * the model and its preferred size obtained, which can be
 676      * relatively expensive.
 677      *
 678      * @param prototypeDisplayValue
 679      * @see #getPrototypeDisplayValue
 680      * @since 1.4
 681      * @beaninfo
 682      *       bound: true
 683      *   attribute: visualUpdate true
 684      * description: The display prototype value, used to compute display width and height.
 685      */
 686     public void setPrototypeDisplayValue(E prototypeDisplayValue) {
 687         Object oldValue = this.prototypeDisplayValue;
 688         this.prototypeDisplayValue = prototypeDisplayValue;
 689         firePropertyChange("prototypeDisplayValue", oldValue, prototypeDisplayValue);
 690     }
 691 
 692     /**
 693      * Adds an item to the item list.
 694      * This method works only if the <code>JComboBox</code> uses a
 695      * mutable data model.
 696      * <p>
 697      * <strong>Warning:</strong>
 698      * Focus and keyboard navigation problems may arise if you add duplicate


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 658      * @see #setPrototypeDisplayValue
 659      * @since 1.4
 660      */
 661     public E getPrototypeDisplayValue() {
 662         return prototypeDisplayValue;
 663     }
 664 
 665     /**
 666      * Sets the prototype display value used to calculate the size of the display
 667      * for the UI portion.
 668      * <p>
 669      * If a prototype display value is specified, the preferred size of
 670      * the combo box is calculated by configuring the renderer with the
 671      * prototype display value and obtaining its preferred size. Specifying
 672      * the preferred display value is often useful when the combo box will be
 673      * displaying large amounts of data. If no prototype display value has
 674      * been specified, the renderer must be configured for each value from
 675      * the model and its preferred size obtained, which can be
 676      * relatively expensive.
 677      *
 678      * @param prototypeDisplayValue the prototype display value
 679      * @see #getPrototypeDisplayValue
 680      * @since 1.4
 681      * @beaninfo
 682      *       bound: true
 683      *   attribute: visualUpdate true
 684      * description: The display prototype value, used to compute display width and height.
 685      */
 686     public void setPrototypeDisplayValue(E prototypeDisplayValue) {
 687         Object oldValue = this.prototypeDisplayValue;
 688         this.prototypeDisplayValue = prototypeDisplayValue;
 689         firePropertyChange("prototypeDisplayValue", oldValue, prototypeDisplayValue);
 690     }
 691 
 692     /**
 693      * Adds an item to the item list.
 694      * This method works only if the <code>JComboBox</code> uses a
 695      * mutable data model.
 696      * <p>
 697      * <strong>Warning:</strong>
 698      * Focus and keyboard navigation problems may arise if you add duplicate