< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XListPeer.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 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


 195     }
 196 
 197 
 198     /**
 199      * add Vertical Scrollbar
 200      */
 201     void createVerScrollbar() {
 202         vsb = new XVerticalScrollbar(this);
 203         vsb.setValues(0, 0, 0, 0, 1, 1);
 204     }
 205 
 206 
 207     /**
 208      * add Horizontal scrollbar
 209      */
 210     void createHorScrollbar() {
 211         hsb = new XHorizontalScrollbar(this);
 212         hsb.setValues(0, 0, 0, 0, HORIZ_SCROLL_AMT, HORIZ_SCROLL_AMT);
 213     }
 214 
 215     /* New method name for 1.1 */
 216     public void add(String item, int index) {
 217         addItem(item, index);
 218     }
 219 
 220     /* New method name for 1.1 */
 221     public void removeAll() {
 222         clear();
 223         maxLength = 0;
 224     }
 225 
 226     /* New method name for 1.1 */
 227     public void setMultipleMode (boolean b) {
 228         setMultipleSelections(b);
 229     }
 230 
 231     /* New method name for 1.1 */
 232     public Dimension getPreferredSize(int rows) {
 233         return preferredSize(rows);
 234     }
 235 
 236     /* New method name for 1.1 */
 237     public Dimension getMinimumSize(int rows) {
 238         return minimumSize(rows);
 239     }
 240 
 241     /**
 242      * Minimum size.
 243      */
 244     public Dimension minimumSize() {
 245         return minimumSize(DEFAULT_VISIBLE_ROWS);
 246     }
 247 
 248     /**
 249      * return the preferredSize
 250      */
 251     public Dimension preferredSize(int v) {
 252         return minimumSize(v);
 253     }
 254 
 255     /**
 256      * return the minimumsize
 257      */
 258     public Dimension minimumSize(int v) {
 259         FontMetrics fm = getFontMetrics(getFont());
 260         initFontMetrics();
 261         return new Dimension(20 + fm.stringWidth("0123456789abcde"),
 262                              getItemHeight() * v + (2*MARGIN));
 263     }
 264 
 265     /**
 266      * Calculate font metrics
 267      */
 268     void initFontMetrics() {
 269         FontMetrics fm = getFontMetrics(getFont());
 270         fontHeight = fm.getHeight();
 271         fontAscent = fm.getAscent();
 272         fontLeading = fm.getLeading();
 273     }
 274 
 275 
 276     /**
 277      * return the length of the largest item in the list
 278      */
 279     int maxLength() {
 280         FontMetrics fm = getFontMetrics(getFont());
 281         int m = 0;
 282         int end = items.size();


   1 /*
   2  * Copyright (c) 2003, 2018, 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


 195     }
 196 
 197 
 198     /**
 199      * add Vertical Scrollbar
 200      */
 201     void createVerScrollbar() {
 202         vsb = new XVerticalScrollbar(this);
 203         vsb.setValues(0, 0, 0, 0, 1, 1);
 204     }
 205 
 206 
 207     /**
 208      * add Horizontal scrollbar
 209      */
 210     void createHorScrollbar() {
 211         hsb = new XHorizontalScrollbar(this);
 212         hsb.setValues(0, 0, 0, 0, HORIZ_SCROLL_AMT, HORIZ_SCROLL_AMT);
 213     }
 214 

 215     public void add(String item, int index) {
 216         addItem(item, index);
 217     }
 218 

 219     public void removeAll() {
 220         clear();
 221         maxLength = 0;
 222     }
 223 

 224     public void setMultipleMode (boolean b) {
 225         setMultipleSelections(b);
 226     }
 227 
 228     public Dimension getMinimumSize() {
 229         return getMinimumSize(DEFAULT_VISIBLE_ROWS);













 230     }
 231 
 232     public Dimension getPreferredSize(int rows) {
 233         return getMinimumSize(rows);



 234     }
 235 
 236     public Dimension getMinimumSize(int rows) {



 237         FontMetrics fm = getFontMetrics(getFont());
 238         initFontMetrics();
 239         return new Dimension(20 + fm.stringWidth("0123456789abcde"),
 240                              getItemHeight() * rows + (2*MARGIN));
 241     }
 242 
 243     /**
 244      * Calculate font metrics
 245      */
 246     void initFontMetrics() {
 247         FontMetrics fm = getFontMetrics(getFont());
 248         fontHeight = fm.getHeight();
 249         fontAscent = fm.getAscent();
 250         fontLeading = fm.getLeading();
 251     }
 252 
 253 
 254     /**
 255      * return the length of the largest item in the list
 256      */
 257     int maxLength() {
 258         FontMetrics fm = getFontMetrics(getFont());
 259         int m = 0;
 260         int end = items.size();


< prev index next >