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

Print this page
rev 9717 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by:

*** 68,78 **** XVerticalScrollbar vsb; XHorizontalScrollbar hsb; ListPainter painter; // TODO: ick - Vector? ! Vector items; boolean multipleSelections; int active = NONE; // Holds the array of the indexes of the elements which is selected // This array should be kept sorted, low to high. --- 68,78 ---- XVerticalScrollbar vsb; XHorizontalScrollbar hsb; ListPainter painter; // TODO: ick - Vector? ! Vector<String> items; boolean multipleSelections; int active = NONE; // Holds the array of the indexes of the elements which is selected // This array should be kept sorted, low to high.
*** 137,147 **** */ public void preInit(XCreateWindowParams params) { super.preInit(params); // Stuff that must be initialized before layout() is called ! items = new Vector(); createVerScrollbar(); createHorScrollbar(); painter = new ListPainter(); --- 137,147 ---- */ public void preInit(XCreateWindowParams params) { super.preInit(params); // Stuff that must be initialized before layout() is called ! items = new Vector<>(); createVerScrollbar(); createHorScrollbar(); painter = new ListPainter();
*** 279,300 **** int maxLength() { FontMetrics fm = getFontMetrics(getFont()); int m = 0; int end = items.size(); for(int i = 0 ; i < end ; i++) { ! int l = fm.stringWidth(((String)items.elementAt(i))); m = Math.max(m, l); } return m; } /** * Calculates the width of item's label */ int getItemWidth(int i) { FontMetrics fm = getFontMetrics(getFont()); ! return fm.stringWidth((String)items.elementAt(i)); } /** * return the on-screen width of the given string "str" */ --- 279,300 ---- int maxLength() { FontMetrics fm = getFontMetrics(getFont()); int m = 0; int end = items.size(); for(int i = 0 ; i < end ; i++) { ! int l = fm.stringWidth(items.elementAt(i)); m = Math.max(m, l); } return m; } /** * Calculates the width of item's label */ int getItemWidth(int i) { FontMetrics fm = getFontMetrics(getFont()); ! return fm.stringWidth(items.elementAt(i)); } /** * return the on-screen width of the given string "str" */
*** 657,667 **** mouseEvent.getY()-(height-SCROLLBAR_WIDTH)); } else if ( ( currentIndex >= 0 ) && ( clickCount >= 2 ) && ( clickCount % 2 == 0 ) ) { postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED, ! (String)items.elementAt(currentIndex), mouseEvent.getWhen(), mouseEvent.getModifiers())); // No ext mods } else if (active == WINDOW) { // See 6243382 for more information trackMouseReleasedScroll(); --- 657,667 ---- mouseEvent.getY()-(height-SCROLLBAR_WIDTH)); } else if ( ( currentIndex >= 0 ) && ( clickCount >= 2 ) && ( clickCount % 2 == 0 ) ) { postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED, ! items.elementAt(currentIndex), mouseEvent.getWhen(), mouseEvent.getModifiers())); // No ext mods } else if (active == WINDOW) { // See 6243382 for more information trackMouseReleasedScroll();
*** 984,994 **** // say: "AWT also generates an action event when the user presses // the return key while an item in the list is selected." if (selected.length > 0) { postEvent(new ActionEvent((List)target, ActionEvent.ACTION_PERFORMED, ! (String)items.elementAt(getFocusIndex()), e.getWhen(), e.getModifiers())); // ActionEvent doesn't have // extended modifiers. } break; --- 984,994 ---- // say: "AWT also generates an action event when the user presses // the return key while an item in the list is selected." if (selected.length > 0) { postEvent(new ActionEvent((List)target, ActionEvent.ACTION_PERFORMED, ! items.elementAt(getFocusIndex()), e.getWhen(), e.getModifiers())); // ActionEvent doesn't have // extended modifiers. } break;
*** 1341,1351 **** /** * clear */ public void clear() { selected = new int[0]; ! items = new Vector(); currentIndex = -1; // Fixed 6291736: ITEM_STATE_CHANGED triggered after List.removeAll(), XToolkit // We should update 'focusIndex' variable more carefully setFocusIndex(-1); vsb.setValue(0); --- 1341,1351 ---- /** * clear */ public void clear() { selected = new int[0]; ! items = new Vector<>(); currentIndex = -1; // Fixed 6291736: ITEM_STATE_CHANGED triggered after List.removeAll(), XToolkit // We should update 'focusIndex' variable more carefully setFocusIndex(-1); vsb.setValue(0);
*** 1924,1934 **** } else if (isSelected(index)) { g.setColor(getListBackground()); } else { g.setColor(getListForeground()); } ! String str = (String)items.elementAt(index); g.drawString(str, x - hsb.getValue(), y + fontAscent); } else { // Clear the remaining area around the item - focus area and the rest of border g.setClip(x, y, listWidth, h); g.setColor(getListBackground()); --- 1924,1934 ---- } else if (isSelected(index)) { g.setColor(getListBackground()); } else { g.setColor(getListForeground()); } ! String str = items.elementAt(index); g.drawString(str, x - hsb.getValue(), y + fontAscent); } else { // Clear the remaining area around the item - focus area and the rest of border g.setClip(x, y, listWidth, h); g.setColor(getListBackground());