< prev index next >
src/java.desktop/windows/classes/sun/awt/windows/WListPeer.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -52,38 +52,40 @@
int selected[] = new int[nsel];
System.arraycopy(sel, 0, selected, 0, nsel);
return selected;
}
- /* New method name for 1.1 */
@Override
public void add(String item, int index) {
addItem(item, index);
}
- /* New method name for 1.1 */
@Override
public void removeAll() {
clear();
}
- /* New method name for 1.1 */
@Override
public void setMultipleMode (boolean b) {
setMultipleSelections(b);
}
- /* New method name for 1.1 */
@Override
public Dimension getPreferredSize(int rows) {
- return preferredSize(rows);
+ if ( fm == null ) {
+ List li = (List)target;
+ fm = getFontMetrics( li.getFont() );
+ }
+ Dimension d = getMinimumSize(rows);
+ d.width = Math.max(d.width, getMaxWidth() + 20);
+ return d;
}
- /* New method name for 1.1 */
@Override
public Dimension getMinimumSize(int rows) {
- return minimumSize(rows);
+ return new Dimension(20 + fm.stringWidth("0123456789abcde"),
+ (fm.getHeight() * rows) + 4); // include borders
}
private FontMetrics fm;
public void addItem(String item, int index) {
addItems(new String[] {item}, index, fm.stringWidth(item));
@@ -102,25 +104,10 @@
public native void deselect(int index);
@Override
public native void makeVisible(int index);
public native void setMultipleSelections(boolean v);
public native int getMaxWidth();
-
- public Dimension preferredSize(int v) {
- if ( fm == null ) {
- List li = (List)target;
- fm = getFontMetrics( li.getFont() );
- }
- Dimension d = minimumSize(v);
- d.width = Math.max(d.width, getMaxWidth() + 20);
- return d;
- }
- public Dimension minimumSize(int v) {
- return new Dimension(20 + fm.stringWidth("0123456789abcde"),
- (fm.getHeight() * v) + 4); // include borders
- }
-
// Toolkit & peer internals
WListPeer(List target) {
super(target);
}
< prev index next >