src/solaris/classes/sun/awt/X11/ListHelper.java

Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr

*** 53,66 **** private final int TEXT_SPACE; // Space between the edge of an item and // the text private final int SCROLLBAR_WIDTH; // Width of a scrollbar ! private java.util.List items; // List of items // TODO: maybe this would be better as a simple int[] ! private java.util.List selected; // List of selected items private boolean multiSelect; // Can multiple items be selected // at once? private int focusedIndex; private int maxVisItems; // # items visible without a vsb --- 53,66 ---- private final int TEXT_SPACE; // Space between the edge of an item and // the text private final int SCROLLBAR_WIDTH; // Width of a scrollbar ! private java.util.List<String> items; // List of items // TODO: maybe this would be better as a simple int[] ! private java.util.List<Integer> selected; // List of selected items private boolean multiSelect; // Can multiple items be selected // at once? private int focusedIndex; private int maxVisItems; // # items visible without a vsb
*** 98,109 **** int BORDER, int SCROLLBAR) { this.peer = peer; this.colors = colors; this.multiSelect = multiSelect; ! items = new ArrayList(initialSize); ! selected = new ArrayList(1); selected.add(Integer.valueOf(-1)); this.maxVisItems = maxVisItems; if (scrollVert) { vsb = new XVerticalScrollbar(this); --- 98,109 ---- int BORDER, int SCROLLBAR) { this.peer = peer; this.colors = colors; this.multiSelect = multiSelect; ! items = new ArrayList<>(initialSize); ! selected = new ArrayList<>(1); selected.add(Integer.valueOf(-1)); this.maxVisItems = maxVisItems; if (scrollVert) { vsb = new XVerticalScrollbar(this);
*** 188,198 **** /* docs */ /* if called for multiselect, return -1 */ public int getSelectedIndex() { if (!multiSelect) { ! Integer val = (Integer)selected.get(0); return val.intValue(); } return -1; } --- 188,198 ---- /* docs */ /* if called for multiselect, return -1 */ public int getSelectedIndex() { if (!multiSelect) { ! Integer val = selected.get(0); return val.intValue(); } return -1; }
*** 215,225 **** public int getItemCount() { return items.size(); } public String getItem(int index) { ! return (String) items.get(index); } /**********************************************************************/ /* GUI-related methods */ /**********************************************************************/ --- 215,225 ---- public int getItemCount() { return items.size(); } public String getItem(int index) { ! return items.get(index); } /**********************************************************************/ /* GUI-related methods */ /**********************************************************************/
*** 574,586 **** g.drawString(string, x + TEXT_SPACE, y + (height + fm.getMaxAscent() - fm.getMaxDescent())/2); //g.clipRect(clip.x, clip.y, clip.width, clip.height); } boolean isItemSelected(int index) { ! Iterator itr = selected.iterator(); while (itr.hasNext()) { ! Integer val = (Integer)itr.next(); if (val.intValue() == index) { return true; } } return false; --- 574,586 ---- g.drawString(string, x + TEXT_SPACE, y + (height + fm.getMaxAscent() - fm.getMaxDescent())/2); //g.clipRect(clip.x, clip.y, clip.width, clip.height); } boolean isItemSelected(int index) { ! Iterator<Integer> itr = selected.iterator(); while (itr.hasNext()) { ! Integer val = itr.next(); if (val.intValue() == index) { return true; } } return false;