< prev index next >

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

Print this page
rev 1527 : 6727662: Code improvement and warnings removing from swing packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: malenkov

*** 35,45 **** * A MenuSelectionManager owns the selection in menu hierarchy. * * @author Arnaud Weber */ public class MenuSelectionManager { ! private Vector selection = new Vector(); /* diagnostic aids -- should be false for production builds. */ private static final boolean TRACE = false; // trace creates and disposes private static final boolean VERBOSE = false; // show reuse hits/misses private static final boolean DEBUG = false; // show bad params, misc. --- 35,45 ---- * A MenuSelectionManager owns the selection in menu hierarchy. * * @author Arnaud Weber */ public class MenuSelectionManager { ! private Vector<MenuElement> selection = new Vector<MenuElement>(); /* diagnostic aids -- should be false for production builds. */ private static final boolean TRACE = false; // trace creates and disposes private static final boolean VERBOSE = false; // show reuse hits/misses private static final boolean DEBUG = false; // show bad params, misc.
*** 97,114 **** System.out.print("Previous: "); printMenuElementArray(getSelectedPath()); System.out.print("New: "); printMenuElementArray(path); } for(i=0,c=path.length;i<c;i++) { ! if(i < currentSelectionCount && (MenuElement)selection.elementAt(i) == path[i]) firstDifference++; else break; } for(i=currentSelectionCount - 1 ; i >= firstDifference ; i--) { ! MenuElement me = (MenuElement)selection.elementAt(i); selection.removeElementAt(i); me.menuSelectionChanged(false); } for(i = firstDifference, c = path.length ; i < c ; i++) { --- 97,114 ---- System.out.print("Previous: "); printMenuElementArray(getSelectedPath()); System.out.print("New: "); printMenuElementArray(path); } for(i=0,c=path.length;i<c;i++) { ! if (i < currentSelectionCount && selection.elementAt(i) == path[i]) firstDifference++; else break; } for(i=currentSelectionCount - 1 ; i >= firstDifference ; i--) { ! MenuElement me = selection.elementAt(i); selection.removeElementAt(i); me.menuSelectionChanged(false); } for(i = firstDifference, c = path.length ; i < c ; i++) {
*** 128,138 **** */ public MenuElement[] getSelectedPath() { MenuElement res[] = new MenuElement[selection.size()]; int i,c; for(i=0,c=selection.size();i<c;i++) ! res[i] = (MenuElement) selection.elementAt(i); return res; } /** * Tell the menu selection to close and unselect all the menu components. Call this method --- 128,138 ---- */ public MenuElement[] getSelectedPath() { MenuElement res[] = new MenuElement[selection.size()]; int i,c; for(i=0,c=selection.size();i<c;i++) ! res[i] = selection.elementAt(i); return res; } /** * Tell the menu selection to close and unselect all the menu components. Call this method
*** 169,180 **** * @return all of the <code>ChangeListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ public ChangeListener[] getChangeListeners() { ! return (ChangeListener[])listenerList.getListeners( ! ChangeListener.class); } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance --- 169,179 ---- * @return all of the <code>ChangeListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ public ChangeListener[] getChangeListeners() { ! return listenerList.getListeners(ChangeListener.class); } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance
*** 253,264 **** continue; mc = subElements[j].getComponent(); if(!mc.isShowing()) continue; if(mc instanceof JComponent) { ! cWidth = ((JComponent)mc).getWidth(); ! cHeight = ((JComponent)mc).getHeight(); } else { r2 = mc.getBounds(); cWidth = r2.width; cHeight = r2.height; } --- 252,263 ---- continue; mc = subElements[j].getComponent(); if(!mc.isShowing()) continue; if(mc instanceof JComponent) { ! cWidth = mc.getWidth(); ! cHeight = mc.getHeight(); } else { r2 = mc.getBounds(); cWidth = r2.width; cHeight = r2.height; }
*** 333,343 **** System.out.println("Path is("); int i, j; for(i=0,j=path.length; i<j ;i++){ for (int k=0; k<=i; k++) System.out.print(" "); ! MenuElement me = (MenuElement) path[i]; if(me instanceof JMenuItem) { System.out.println(((JMenuItem)me).getText() + ", "); } else if (me instanceof JMenuBar) { System.out.println("JMenuBar, "); } else if(me instanceof JPopupMenu) { --- 332,342 ---- System.out.println("Path is("); int i, j; for(i=0,j=path.length; i<j ;i++){ for (int k=0; k<=i; k++) System.out.print(" "); ! MenuElement me = path[i]; if(me instanceof JMenuItem) { System.out.println(((JMenuItem)me).getText() + ", "); } else if (me instanceof JMenuBar) { System.out.println("JMenuBar, "); } else if(me instanceof JPopupMenu) {
*** 394,405 **** continue; mc = subElements[j].getComponent(); if(!mc.isShowing()) continue; if(mc instanceof JComponent) { ! cWidth = ((JComponent)mc).getWidth(); ! cHeight = ((JComponent)mc).getHeight(); } else { r2 = mc.getBounds(); cWidth = r2.width; cHeight = r2.height; } --- 393,404 ---- continue; mc = subElements[j].getComponent(); if(!mc.isShowing()) continue; if(mc instanceof JComponent) { ! cWidth = mc.getWidth(); ! cHeight = mc.getHeight(); } else { r2 = mc.getBounds(); cWidth = r2.width; cHeight = r2.height; }
*** 424,434 **** * * @param e a KeyEvent object */ public void processKeyEvent(KeyEvent e) { MenuElement[] sel2 = new MenuElement[0]; ! sel2 = (MenuElement[])selection.toArray(sel2); int selSize = sel2.length; MenuElement[] path; if (selSize < 1) { return; --- 423,433 ---- * * @param e a KeyEvent object */ public void processKeyEvent(KeyEvent e) { MenuElement[] sel2 = new MenuElement[0]; ! sel2 = selection.toArray(sel2); int selSize = sel2.length; MenuElement[] path; if (selSize < 1) { return;
*** 469,479 **** /** * Return true if c is part of the currently used menu */ public boolean isComponentPartOfCurrentMenu(Component c) { if(selection.size() > 0) { ! MenuElement me = (MenuElement)selection.elementAt(0); return isComponentPartOfCurrentMenu(me,c); } else return false; } --- 468,478 ---- /** * Return true if c is part of the currently used menu */ public boolean isComponentPartOfCurrentMenu(Component c) { if(selection.size() > 0) { ! MenuElement me = selection.elementAt(0); return isComponentPartOfCurrentMenu(me,c); } else return false; }
< prev index next >