提交 363ab66c 编写于 作者: R rupashka

6727662: Code improvement and warnings removing from swing packages

Summary: Removed unnecessary castings and other warnings
Reviewed-by: malenkov
上级 a90d474b
...@@ -1315,8 +1315,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl ...@@ -1315,8 +1315,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
// Make sure the change actually took effect // Make sure the change actually took effect
if (!selected && isSelected()) { if (!selected && isSelected()) {
if (getModel() instanceof DefaultButtonModel) { if (getModel() instanceof DefaultButtonModel) {
ButtonGroup group = (ButtonGroup) ButtonGroup group = ((DefaultButtonModel)getModel()).getGroup();
((DefaultButtonModel)getModel()).getGroup();
if (group != null) { if (group != null) {
group.clearSelection(); group.clearSelection();
} }
...@@ -1886,8 +1885,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl ...@@ -1886,8 +1885,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])(listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class));
} }
/** /**
...@@ -1944,8 +1942,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl ...@@ -1944,8 +1942,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
* @since 1.4 * @since 1.4
*/ */
public ActionListener[] getActionListeners() { public ActionListener[] getActionListeners() {
return (ActionListener[])(listenerList.getListeners( return listenerList.getListeners(ActionListener.class);
ActionListener.class));
} }
/** /**
...@@ -2137,7 +2134,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl ...@@ -2137,7 +2134,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
* @since 1.4 * @since 1.4
*/ */
public ItemListener[] getItemListeners() { public ItemListener[] getItemListeners() {
return (ItemListener[])listenerList.getListeners(ItemListener.class); return listenerList.getListeners(ItemListener.class);
} }
/** /**
...@@ -2981,7 +2978,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl ...@@ -2981,7 +2978,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
paintViewR.height = AbstractButton.this.getHeight() - (paintViewInsets.top + paintViewInsets.bottom); paintViewR.height = AbstractButton.this.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
String clippedText = SwingUtilities.layoutCompoundLabel( String clippedText = SwingUtilities.layoutCompoundLabel(
(JComponent)AbstractButton.this, AbstractButton.this,
getFontMetrics(getFont()), getFontMetrics(getFont()),
text, text,
icon, icon,
......
...@@ -118,8 +118,7 @@ public abstract class AbstractCellEditor implements CellEditor, Serializable { ...@@ -118,8 +118,7 @@ public abstract class AbstractCellEditor implements CellEditor, Serializable {
* @since 1.4 * @since 1.4
*/ */
public CellEditorListener[] getCellEditorListeners() { public CellEditorListener[] getCellEditorListeners() {
return (CellEditorListener[])listenerList.getListeners( return listenerList.getListeners(CellEditorListener.class);
CellEditorListener.class);
} }
/** /**
......
...@@ -85,8 +85,7 @@ public abstract class AbstractListModel implements ListModel, Serializable ...@@ -85,8 +85,7 @@ public abstract class AbstractListModel implements ListModel, Serializable
* @since 1.4 * @since 1.4
*/ */
public ListDataListener[] getListDataListeners() { public ListDataListener[] getListDataListeners() {
return (ListDataListener[])listenerList.getListeners( return listenerList.getListeners(ListDataListener.class);
ListDataListener.class);
} }
......
...@@ -98,8 +98,7 @@ public abstract class AbstractSpinnerModel implements SpinnerModel, Serializable ...@@ -98,8 +98,7 @@ public abstract class AbstractSpinnerModel implements SpinnerModel, Serializable
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
......
...@@ -197,7 +197,7 @@ public class ActionMap implements Serializable { ...@@ -197,7 +197,7 @@ public class ActionMap implements Serializable {
return pKeys; return pKeys;
} }
HashMap keyMap = new HashMap(); HashMap<Object, Object> keyMap = new HashMap<Object, Object>();
int counter; int counter;
for (counter = keys.length - 1; counter >= 0; counter--) { for (counter = keys.length - 1; counter >= 0; counter--) {
......
...@@ -62,7 +62,7 @@ class AncestorNotifier implements ComponentListener, PropertyChangeListener, Ser ...@@ -62,7 +62,7 @@ class AncestorNotifier implements ComponentListener, PropertyChangeListener, Ser
} }
AncestorListener[] getAncestorListeners() { AncestorListener[] getAncestorListeners() {
return (AncestorListener[])listenerList.getListeners(AncestorListener.class); return listenerList.getListeners(AncestorListener.class);
} }
/** /**
......
...@@ -88,10 +88,10 @@ class ArrayTable implements Cloneable { ...@@ -88,10 +88,10 @@ class ArrayTable implements Cloneable {
// Write ou the Serializable key/value pairs. // Write ou the Serializable key/value pairs.
s.writeInt(validCount); s.writeInt(validCount);
if (validCount > 0) { if (validCount > 0) {
for (int counter = 0; counter < keys.length; counter++) { for (Object key : keys) {
if (keys[counter] != null) { if (key != null) {
s.writeObject(keys[counter]); s.writeObject(key);
s.writeObject(table.get(keys[counter])); s.writeObject(table.get(key));
if (--validCount == 0) { if (--validCount == 0) {
break; break;
} }
...@@ -315,7 +315,7 @@ class ArrayTable implements Cloneable { ...@@ -315,7 +315,7 @@ class ArrayTable implements Cloneable {
*/ */
private void grow() { private void grow() {
Object[] array = (Object[])table; Object[] array = (Object[])table;
Hashtable tmp = new Hashtable(array.length/2); Hashtable<Object, Object> tmp = new Hashtable<Object, Object>(array.length/2);
for (int i = 0; i<array.length; i+=2) { for (int i = 0; i<array.length; i+=2) {
tmp.put(array[i], array[i+1]); tmp.put(array[i], array[i+1]);
} }
......
...@@ -68,7 +68,7 @@ import java.io.Serializable; ...@@ -68,7 +68,7 @@ import java.io.Serializable;
public class ButtonGroup implements Serializable { public class ButtonGroup implements Serializable {
// the list of buttons participating in this group // the list of buttons participating in this group
protected Vector<AbstractButton> buttons = new Vector(); protected Vector<AbstractButton> buttons = new Vector<AbstractButton>();
/** /**
* The current selection. * The current selection.
......
...@@ -37,7 +37,7 @@ class DebugGraphicsInfo { ...@@ -37,7 +37,7 @@ class DebugGraphicsInfo {
Color flashColor = Color.red; Color flashColor = Color.red;
int flashTime = 100; int flashTime = 100;
int flashCount = 2; int flashCount = 2;
Hashtable componentToDebug; Hashtable<JComponent, Integer> componentToDebug;
JFrame debugFrame = null; JFrame debugFrame = null;
java.io.PrintStream stream = System.out; java.io.PrintStream stream = System.out;
...@@ -46,7 +46,7 @@ class DebugGraphicsInfo { ...@@ -46,7 +46,7 @@ class DebugGraphicsInfo {
return; return;
} }
if (componentToDebug == null) { if (componentToDebug == null) {
componentToDebug = new Hashtable(); componentToDebug = new Hashtable<JComponent, Integer>();
} }
if (debug > 0) { if (debug > 0) {
componentToDebug.put(component, Integer.valueOf(debug)); componentToDebug.put(component, Integer.valueOf(debug));
...@@ -59,7 +59,7 @@ class DebugGraphicsInfo { ...@@ -59,7 +59,7 @@ class DebugGraphicsInfo {
if (componentToDebug == null) { if (componentToDebug == null) {
return 0; return 0;
} else { } else {
Integer integer = (Integer)componentToDebug.get(component); Integer integer = componentToDebug.get(component);
return integer == null ? 0 : integer.intValue(); return integer == null ? 0 : integer.intValue();
} }
......
...@@ -343,8 +343,7 @@ public class DefaultBoundedRangeModel implements BoundedRangeModel, Serializable ...@@ -343,8 +343,7 @@ public class DefaultBoundedRangeModel implements BoundedRangeModel, Serializable
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
......
...@@ -326,8 +326,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable { ...@@ -326,8 +326,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable {
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
/** /**
...@@ -380,8 +379,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable { ...@@ -380,8 +379,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable {
* @since 1.4 * @since 1.4
*/ */
public ActionListener[] getActionListeners() { public ActionListener[] getActionListeners() {
return (ActionListener[])listenerList.getListeners( return listenerList.getListeners(ActionListener.class);
ActionListener.class);
} }
/** /**
...@@ -434,7 +432,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable { ...@@ -434,7 +432,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable {
* @since 1.4 * @since 1.4
*/ */
public ItemListener[] getItemListeners() { public ItemListener[] getItemListeners() {
return (ItemListener[])listenerList.getListeners(ItemListener.class); return listenerList.getListeners(ItemListener.class);
} }
/** /**
......
...@@ -156,18 +156,17 @@ final class LegacyLayoutFocusTraversalPolicy ...@@ -156,18 +156,17 @@ final class LegacyLayoutFocusTraversalPolicy
} }
} }
final class CompareTabOrderComparator implements Comparator { final class CompareTabOrderComparator implements Comparator<Component> {
private final DefaultFocusManager defaultFocusManager; private final DefaultFocusManager defaultFocusManager;
CompareTabOrderComparator(DefaultFocusManager defaultFocusManager) { CompareTabOrderComparator(DefaultFocusManager defaultFocusManager) {
this.defaultFocusManager = defaultFocusManager; this.defaultFocusManager = defaultFocusManager;
} }
public int compare(Object o1, Object o2) { public int compare(Component o1, Component o2) {
if (o1 == o2) { if (o1 == o2) {
return 0; return 0;
} }
return (defaultFocusManager.compareTabOrder((Component)o1, return (defaultFocusManager.compareTabOrder(o1, o2)) ? -1 : 1;
(Component)o2)) ? -1 : 1;
} }
} }
...@@ -133,8 +133,7 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, ...@@ -133,8 +133,7 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable,
* @since 1.4 * @since 1.4
*/ */
public ListSelectionListener[] getListSelectionListeners() { public ListSelectionListener[] getListSelectionListeners() {
return (ListSelectionListener[])listenerList.getListeners( return listenerList.getListeners(ListSelectionListener.class);
ListSelectionListener.class);
} }
/** /**
......
...@@ -110,8 +110,7 @@ Serializable { ...@@ -110,8 +110,7 @@ Serializable {
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
/** /**
......
...@@ -1119,7 +1119,7 @@ public class GroupLayout implements LayoutManager2 { ...@@ -1119,7 +1119,7 @@ public class GroupLayout implements LayoutManager2 {
* creating one if necessary. * creating one if necessary.
*/ */
private ComponentInfo getComponentInfo(Component component) { private ComponentInfo getComponentInfo(Component component) {
ComponentInfo info = (ComponentInfo)componentInfos.get(component); ComponentInfo info = componentInfos.get(component);
if (info == null) { if (info == null) {
info = new ComponentInfo(component); info = new ComponentInfo(component);
componentInfos.put(component, info); componentInfos.put(component, info);
...@@ -1698,7 +1698,7 @@ public class GroupLayout implements LayoutManager2 { ...@@ -1698,7 +1698,7 @@ public class GroupLayout implements LayoutManager2 {
for (int counter = springs.size() - 1; counter >= 0; counter--) { for (int counter = springs.size() - 1; counter >= 0; counter--) {
Spring spring = springs.get(counter); Spring spring = springs.get(counter);
if (spring instanceof AutoPreferredGapSpring) { if (spring instanceof AutoPreferredGapSpring) {
((AutoPreferredGapSpring)spring).unset(); spring.unset();
} else if (spring instanceof Group) { } else if (spring instanceof Group) {
((Group)spring).unsetAutopadding(); ((Group)spring).unsetAutopadding();
} }
......
...@@ -200,7 +200,7 @@ public class InputMap implements Serializable { ...@@ -200,7 +200,7 @@ public class InputMap implements Serializable {
return pKeys; return pKeys;
} }
HashMap keyMap = new HashMap(); HashMap<KeyStroke, KeyStroke> keyMap = new HashMap<KeyStroke, KeyStroke>();
int counter; int counter;
for (counter = keys.length - 1; counter >= 0; counter--) { for (counter = keys.length - 1; counter >= 0; counter--) {
...@@ -212,7 +212,7 @@ public class InputMap implements Serializable { ...@@ -212,7 +212,7 @@ public class InputMap implements Serializable {
KeyStroke[] allKeys = new KeyStroke[keyMap.size()]; KeyStroke[] allKeys = new KeyStroke[keyMap.size()];
return (KeyStroke[])keyMap.keySet().toArray(allKeys); return keyMap.keySet().toArray(allKeys);
} }
private void writeObject(ObjectOutputStream s) throws IOException { private void writeObject(ObjectOutputStream s) throws IOException {
......
...@@ -859,7 +859,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible { ...@@ -859,7 +859,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
* @since 1.4 * @since 1.4
*/ */
public ItemListener[] getItemListeners() { public ItemListener[] getItemListeners() {
return (ItemListener[])listenerList.getListeners(ItemListener.class); return listenerList.getListeners(ItemListener.class);
} }
/** /**
...@@ -897,8 +897,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible { ...@@ -897,8 +897,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
* @since 1.4 * @since 1.4
*/ */
public ActionListener[] getActionListeners() { public ActionListener[] getActionListeners() {
return (ActionListener[])listenerList.getListeners( return listenerList.getListeners(ActionListener.class);
ActionListener.class);
} }
/** /**
...@@ -937,8 +936,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible { ...@@ -937,8 +936,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
* @since 1.4 * @since 1.4
*/ */
public PopupMenuListener[] getPopupMenuListeners() { public PopupMenuListener[] getPopupMenuListeners() {
return (PopupMenuListener[])listenerList.getListeners( return listenerList.getListeners(PopupMenuListener.class);
PopupMenuListener.class);
} }
/** /**
...@@ -1668,7 +1666,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible { ...@@ -1668,7 +1666,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
if (editor != null) { if (editor != null) {
Component comp = editor.getEditorComponent(); Component comp = editor.getEditorComponent();
if (comp instanceof Accessible) { if (comp instanceof Accessible) {
AccessibleContext ac = ((Accessible)comp).getAccessibleContext(); AccessibleContext ac = comp.getAccessibleContext();
if (ac != null) { // may be null if (ac != null) { // may be null
ac.setAccessibleName(getAccessibleName()); ac.setAccessibleName(getAccessibleName());
ac.setAccessibleDescription(getAccessibleDescription()); ac.setAccessibleDescription(getAccessibleDescription());
...@@ -1741,7 +1739,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible { ...@@ -1741,7 +1739,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
// Fire a FOCUSED lost PropertyChangeEvent for the // Fire a FOCUSED lost PropertyChangeEvent for the
// previously selected list item. // previously selected list item.
PropertyChangeEvent pce = null; PropertyChangeEvent pce;
if (previousSelectedAccessible != null) { if (previousSelectedAccessible != null) {
pce = new PropertyChangeEvent(previousSelectedAccessible, pce = new PropertyChangeEvent(previousSelectedAccessible,
......
...@@ -192,7 +192,8 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -192,7 +192,8 @@ public abstract class JComponent extends Container implements Serializable,
/** /**
* @see #readObject * @see #readObject
*/ */
private static final Hashtable readObjectCallbacks = new Hashtable(1); private static final Hashtable<ObjectInputStream, ReadObjectCallback> readObjectCallbacks =
new Hashtable<ObjectInputStream, ReadObjectCallback>(1);
/** /**
* Keys to use for forward focus traversal when the JComponent is * Keys to use for forward focus traversal when the JComponent is
...@@ -356,7 +357,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -356,7 +357,7 @@ public abstract class JComponent extends Container implements Serializable,
/** /**
* Temporary rectangles. * Temporary rectangles.
*/ */
private static java.util.List tempRectangles = new java.util.ArrayList(11); private static java.util.List<Rectangle> tempRectangles = new java.util.ArrayList<Rectangle>(11);
/** Used for <code>WHEN_FOCUSED</code> bindings. */ /** Used for <code>WHEN_FOCUSED</code> bindings. */
private InputMap focusInputMap; private InputMap focusInputMap;
...@@ -451,7 +452,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -451,7 +452,7 @@ public abstract class JComponent extends Container implements Serializable,
Rectangle rect; Rectangle rect;
int size = tempRectangles.size(); int size = tempRectangles.size();
if (size > 0) { if (size > 0) {
rect = (Rectangle)tempRectangles.remove(size - 1); rect = tempRectangles.remove(size - 1);
} }
else { else {
rect = new Rectangle(0, 0, 0, 0); rect = new Rectangle(0, 0, 0, 0);
...@@ -806,7 +807,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -806,7 +807,7 @@ public abstract class JComponent extends Container implements Serializable,
// its index. // its index.
if (paintingChild != null && if (paintingChild != null &&
(paintingChild instanceof JComponent) && (paintingChild instanceof JComponent) &&
((JComponent)paintingChild).isOpaque()) { paintingChild.isOpaque()) {
for (; i >= 0; i--) { for (; i >= 0; i--) {
if (getComponent(i) == paintingChild){ if (getComponent(i) == paintingChild){
break; break;
...@@ -875,7 +876,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -875,7 +876,7 @@ public abstract class JComponent extends Container implements Serializable,
shouldSetFlagBack = true; shouldSetFlagBack = true;
} }
if(!printing) { if(!printing) {
((JComponent)comp).paint(cg); comp.paint(cg);
} }
else { else {
if (!getFlag(IS_PRINTING_ALL)) { if (!getFlag(IS_PRINTING_ALL)) {
...@@ -1098,7 +1099,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -1098,7 +1099,7 @@ public abstract class JComponent extends Container implements Serializable,
} }
private void adjustPaintFlags() { private void adjustPaintFlags() {
JComponent jparent = null; JComponent jparent;
Container parent; Container parent;
for(parent = getParent() ; parent != null ; parent = for(parent = getParent() ; parent != null ; parent =
parent.getParent()) { parent.getParent()) {
...@@ -2096,7 +2097,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -2096,7 +2097,7 @@ public abstract class JComponent extends Container implements Serializable,
private void registerWithKeyboardManager(boolean onlyIfNew) { private void registerWithKeyboardManager(boolean onlyIfNew) {
InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false); InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
KeyStroke[] strokes; KeyStroke[] strokes;
Hashtable registered = (Hashtable)getClientProperty Hashtable<KeyStroke, KeyStroke> registered = (Hashtable)getClientProperty
(WHEN_IN_FOCUSED_WINDOW_BINDINGS); (WHEN_IN_FOCUSED_WINDOW_BINDINGS);
if (inputMap != null) { if (inputMap != null) {
...@@ -2120,10 +2121,10 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -2120,10 +2121,10 @@ public abstract class JComponent extends Container implements Serializable,
} }
// Remove any old ones. // Remove any old ones.
if (registered != null && registered.size() > 0) { if (registered != null && registered.size() > 0) {
Enumeration keys = registered.keys(); Enumeration<KeyStroke> keys = registered.keys();
while (keys.hasMoreElements()) { while (keys.hasMoreElements()) {
KeyStroke ks = (KeyStroke)keys.nextElement(); KeyStroke ks = keys.nextElement();
unregisterWithKeyboardManager(ks); unregisterWithKeyboardManager(ks);
} }
registered.clear(); registered.clear();
...@@ -2131,7 +2132,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -2131,7 +2132,7 @@ public abstract class JComponent extends Container implements Serializable,
// Updated the registered Hashtable. // Updated the registered Hashtable.
if (strokes != null && strokes.length > 0) { if (strokes != null && strokes.length > 0) {
if (registered == null) { if (registered == null) {
registered = new Hashtable(strokes.length); registered = new Hashtable<KeyStroke, KeyStroke>(strokes.length);
putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, registered); putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, registered);
} }
for (int counter = strokes.length - 1; counter >= 0; counter--) { for (int counter = strokes.length - 1; counter >= 0; counter--) {
...@@ -2174,7 +2175,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -2174,7 +2175,7 @@ public abstract class JComponent extends Container implements Serializable,
InputMap km = getInputMap(WHEN_IN_FOCUSED_WINDOW, false); InputMap km = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
while (km != inputMap && km != null) { while (km != inputMap && km != null) {
km = (ComponentInputMap)km.getParent(); km = km.getParent();
} }
if (km != null) { if (km != null) {
registerWithKeyboardManager(false); registerWithKeyboardManager(false);
...@@ -3673,7 +3674,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -3673,7 +3674,7 @@ public abstract class JComponent extends Container implements Serializable,
if (c != null && c instanceof Accessible) { if (c != null && c instanceof Accessible) {
AccessibleJComponent.this.firePropertyChange( AccessibleJComponent.this.firePropertyChange(
AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
null, ((Accessible) c).getAccessibleContext()); null, c.getAccessibleContext());
} }
} }
public void componentRemoved(ContainerEvent e) { public void componentRemoved(ContainerEvent e) {
...@@ -3681,7 +3682,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -3681,7 +3682,7 @@ public abstract class JComponent extends Container implements Serializable,
if (c != null && c instanceof Accessible) { if (c != null && c instanceof Accessible) {
AccessibleJComponent.this.firePropertyChange( AccessibleJComponent.this.firePropertyChange(
AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
((Accessible) c).getAccessibleContext(), null); c.getAccessibleContext(), null);
} }
} }
} }
...@@ -4377,7 +4378,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -4377,7 +4378,7 @@ public abstract class JComponent extends Container implements Serializable,
// System.out.println("A) checking opaque: " + ((JComponent)child).isOpaque() + " " + child); // System.out.println("A) checking opaque: " + ((JComponent)child).isOpaque() + " " + child);
// System.out.print("B) "); // System.out.print("B) ");
// Thread.dumpStack(); // Thread.dumpStack();
return ((JComponent)child).isOpaque(); return child.isOpaque();
} else { } else {
/** Sometimes a heavy weight can have a bound larger than its peer size /** Sometimes a heavy weight can have a bound larger than its peer size
* so we should always draw under heavy weights * so we should always draw under heavy weights
...@@ -4693,7 +4694,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -4693,7 +4694,7 @@ public abstract class JComponent extends Container implements Serializable,
result = (T[])getPropertyChangeListeners(); result = (T[])getPropertyChangeListeners();
} }
else { else {
result = (T[])listenerList.getListeners(listenerType); result = listenerList.getListeners(listenerType);
} }
if (result.length == 0) { if (result.length == 0) {
...@@ -4904,7 +4905,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -4904,7 +4905,7 @@ public abstract class JComponent extends Container implements Serializable,
if(!isShowing()) { if(!isShowing()) {
return; return;
} }
while(!((JComponent)c).isOpaque()) { while(!c.isOpaque()) {
parent = c.getParent(); parent = c.getParent();
if(parent != null) { if(parent != null) {
x += c.getX(); x += c.getX();
...@@ -5198,7 +5199,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -5198,7 +5199,7 @@ public abstract class JComponent extends Container implements Serializable,
Rectangle siblingRect; Rectangle siblingRect;
boolean opaque; boolean opaque;
if (sibling instanceof JComponent) { if (sibling instanceof JComponent) {
opaque = ((JComponent)sibling).isOpaque(); opaque = sibling.isOpaque();
if (!opaque) { if (!opaque) {
if (retValue == PARTIALLY_OBSCURED) { if (retValue == PARTIALLY_OBSCURED) {
continue; continue;
...@@ -5345,7 +5346,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -5345,7 +5346,7 @@ public abstract class JComponent extends Container implements Serializable,
*/ */
private class ReadObjectCallback implements ObjectInputValidation private class ReadObjectCallback implements ObjectInputValidation
{ {
private final Vector roots = new Vector(1); private final Vector<JComponent> roots = new Vector<JComponent>(1);
private final ObjectInputStream inputStream; private final ObjectInputStream inputStream;
ReadObjectCallback(ObjectInputStream s) throws Exception { ReadObjectCallback(ObjectInputStream s) throws Exception {
...@@ -5361,8 +5362,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -5361,8 +5362,7 @@ public abstract class JComponent extends Container implements Serializable,
*/ */
public void validateObject() throws InvalidObjectException { public void validateObject() throws InvalidObjectException {
try { try {
for(int i = 0; i < roots.size(); i++) { for (JComponent root : roots) {
JComponent root = (JComponent)(roots.elementAt(i));
SwingUtilities.updateComponentTreeUI(root); SwingUtilities.updateComponentTreeUI(root);
} }
} }
...@@ -5382,8 +5382,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -5382,8 +5382,7 @@ public abstract class JComponent extends Container implements Serializable,
/* If the Component c is a descendant of one of the /* If the Component c is a descendant of one of the
* existing roots (or it IS an existing root), we're done. * existing roots (or it IS an existing root), we're done.
*/ */
for(int i = 0; i < roots.size(); i++) { for (JComponent root : roots) {
JComponent root = (JComponent)roots.elementAt(i);
for(Component p = c; p != null; p = p.getParent()) { for(Component p = c; p != null; p = p.getParent()) {
if (p == root) { if (p == root) {
return; return;
...@@ -5396,7 +5395,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -5396,7 +5395,7 @@ public abstract class JComponent extends Container implements Serializable,
* to the roots vector. * to the roots vector.
*/ */
for(int i = 0; i < roots.size(); i++) { for(int i = 0; i < roots.size(); i++) {
JComponent root = (JComponent)roots.elementAt(i); JComponent root = roots.elementAt(i);
for(Component p = root.getParent(); p != null; p = p.getParent()) { for(Component p = root.getParent(); p != null; p = p.getParent()) {
if (p == c) { if (p == c) {
roots.removeElementAt(i--); // !! roots.removeElementAt(i--); // !!
...@@ -5428,7 +5427,7 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -5428,7 +5427,7 @@ public abstract class JComponent extends Container implements Serializable,
* in the readObjectCallbacks table. Note that the ReadObjectCallback * in the readObjectCallbacks table. Note that the ReadObjectCallback
* constructor takes care of calling s.registerValidation(). * constructor takes care of calling s.registerValidation().
*/ */
ReadObjectCallback cb = (ReadObjectCallback)(readObjectCallbacks.get(s)); ReadObjectCallback cb = readObjectCallbacks.get(s);
if (cb == null) { if (cb == null) {
try { try {
readObjectCallbacks.put(s, cb = new ReadObjectCallback(s)); readObjectCallbacks.put(s, cb = new ReadObjectCallback(s));
......
...@@ -133,8 +133,8 @@ public class JDesktopPane extends JLayeredPane implements Accessible ...@@ -133,8 +133,8 @@ public class JDesktopPane extends JLayeredPane implements Accessible
public Component getDefaultComponent(Container c) { public Component getDefaultComponent(Container c) {
JInternalFrame jifArray[] = getAllFrames(); JInternalFrame jifArray[] = getAllFrames();
Component comp = null; Component comp = null;
for (int i = 0; i < jifArray.length; i++) { for (JInternalFrame jif : jifArray) {
comp = jifArray[i].getFocusTraversalPolicy().getDefaultComponent(jifArray[i]); comp = jif.getFocusTraversalPolicy().getDefaultComponent(jif);
if (comp != null) { if (comp != null) {
break; break;
} }
...@@ -262,16 +262,15 @@ public class JDesktopPane extends JLayeredPane implements Accessible ...@@ -262,16 +262,15 @@ public class JDesktopPane extends JLayeredPane implements Accessible
public JInternalFrame[] getAllFrames() { public JInternalFrame[] getAllFrames() {
int i, count; int i, count;
JInternalFrame[] results; JInternalFrame[] results;
Vector vResults = new Vector(10); Vector<JInternalFrame> vResults = new Vector<JInternalFrame>(10);
Object next, tmp;
count = getComponentCount(); count = getComponentCount();
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
next = getComponent(i); Component next = getComponent(i);
if(next instanceof JInternalFrame) if(next instanceof JInternalFrame)
vResults.addElement(next); vResults.addElement((JInternalFrame) next);
else if(next instanceof JInternalFrame.JDesktopIcon) { else if(next instanceof JInternalFrame.JDesktopIcon) {
tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame(); JInternalFrame tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
if(tmp != null) if(tmp != null)
vResults.addElement(tmp); vResults.addElement(tmp);
} }
...@@ -324,18 +323,17 @@ public class JDesktopPane extends JLayeredPane implements Accessible ...@@ -324,18 +323,17 @@ public class JDesktopPane extends JLayeredPane implements Accessible
public JInternalFrame[] getAllFramesInLayer(int layer) { public JInternalFrame[] getAllFramesInLayer(int layer) {
int i, count; int i, count;
JInternalFrame[] results; JInternalFrame[] results;
Vector vResults = new Vector(10); Vector<JInternalFrame> vResults = new Vector<JInternalFrame>(10);
Object next, tmp;
count = getComponentCount(); count = getComponentCount();
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
next = getComponent(i); Component next = getComponent(i);
if(next instanceof JInternalFrame) { if(next instanceof JInternalFrame) {
if(((JInternalFrame)next).getLayer() == layer) if(((JInternalFrame)next).getLayer() == layer)
vResults.addElement(next); vResults.addElement((JInternalFrame) next);
} else if(next instanceof JInternalFrame.JDesktopIcon) { } else if(next instanceof JInternalFrame.JDesktopIcon) {
tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame(); JInternalFrame tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
if(tmp != null && ((JInternalFrame)tmp).getLayer() == layer) if(tmp != null && tmp.getLayer() == layer)
vResults.addElement(tmp); vResults.addElement(tmp);
} }
} }
......
...@@ -277,7 +277,7 @@ public class JDialog extends Dialog implements WindowConstants, ...@@ -277,7 +277,7 @@ public class JDialog extends Dialog implements WindowConstants,
title, modal); title, modal);
if (owner == null) { if (owner == null) {
WindowListener ownerShutdownListener = WindowListener ownerShutdownListener =
(WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); SwingUtilities.getSharedOwnerFrameShutdownListener();
addWindowListener(ownerShutdownListener); addWindowListener(ownerShutdownListener);
} }
dialogInit(); dialogInit();
...@@ -329,7 +329,7 @@ public class JDialog extends Dialog implements WindowConstants, ...@@ -329,7 +329,7 @@ public class JDialog extends Dialog implements WindowConstants,
title, modal, gc); title, modal, gc);
if (owner == null) { if (owner == null) {
WindowListener ownerShutdownListener = WindowListener ownerShutdownListener =
(WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); SwingUtilities.getSharedOwnerFrameShutdownListener();
addWindowListener(ownerShutdownListener); addWindowListener(ownerShutdownListener);
} }
dialogInit(); dialogInit();
......
...@@ -319,8 +319,7 @@ public class JEditorPane extends JTextComponent { ...@@ -319,8 +319,7 @@ public class JEditorPane extends JTextComponent {
* @since 1.4 * @since 1.4
*/ */
public synchronized HyperlinkListener[] getHyperlinkListeners() { public synchronized HyperlinkListener[] getHyperlinkListeners() {
return (HyperlinkListener[])listenerList.getListeners( return listenerList.getListeners(javax.swing.event.HyperlinkListener.class);
HyperlinkListener.class);
} }
/** /**
...@@ -492,8 +491,8 @@ public class JEditorPane extends JTextComponent { ...@@ -492,8 +491,8 @@ public class JEditorPane extends JTextComponent {
if (pageProperties != null) { if (pageProperties != null) {
// transfer properties discovered in stream to the // transfer properties discovered in stream to the
// document property collection. // document property collection.
for (Enumeration e = pageProperties.keys(); e.hasMoreElements() ;) { for (Enumeration<String> e = pageProperties.keys(); e.hasMoreElements() ;) {
Object key = e.nextElement(); String key = e.nextElement();
doc.putProperty(key, pageProperties.get(key)); doc.putProperty(key, pageProperties.get(key));
} }
pageProperties.clear(); pageProperties.clear();
...@@ -775,7 +774,7 @@ public class JEditorPane extends JTextComponent { ...@@ -775,7 +774,7 @@ public class JEditorPane extends JTextComponent {
*/ */
private void handleConnectionProperties(URLConnection conn) { private void handleConnectionProperties(URLConnection conn) {
if (pageProperties == null) { if (pageProperties == null) {
pageProperties = new Hashtable(); pageProperties = new Hashtable<String, Object>();
} }
String type = conn.getContentType(); String type = conn.getContentType();
if (type != null) { if (type != null) {
...@@ -989,7 +988,7 @@ public class JEditorPane extends JTextComponent { ...@@ -989,7 +988,7 @@ public class JEditorPane extends JTextComponent {
* of the content type in the http header information. * of the content type in the http header information.
*/ */
private void setCharsetFromContentTypeParameters(String paramlist) { private void setCharsetFromContentTypeParameters(String paramlist) {
String charset = null; String charset;
try { try {
// paramlist is handed to us with a leading ';', strip it. // paramlist is handed to us with a leading ';', strip it.
int semi = paramlist.indexOf(';'); int semi = paramlist.indexOf(';');
...@@ -1080,9 +1079,9 @@ public class JEditorPane extends JTextComponent { ...@@ -1080,9 +1079,9 @@ public class JEditorPane extends JTextComponent {
*/ */
public EditorKit getEditorKitForContentType(String type) { public EditorKit getEditorKitForContentType(String type) {
if (typeHandlers == null) { if (typeHandlers == null) {
typeHandlers = new Hashtable(3); typeHandlers = new Hashtable<String, EditorKit>(3);
} }
EditorKit k = (EditorKit) typeHandlers.get(type); EditorKit k = typeHandlers.get(type);
if (k == null) { if (k == null) {
k = createEditorKitForContentType(type); k = createEditorKitForContentType(type);
if (k != null) { if (k != null) {
...@@ -1106,7 +1105,7 @@ public class JEditorPane extends JTextComponent { ...@@ -1106,7 +1105,7 @@ public class JEditorPane extends JTextComponent {
*/ */
public void setEditorKitForContentType(String type, EditorKit k) { public void setEditorKitForContentType(String type, EditorKit k) {
if (typeHandlers == null) { if (typeHandlers == null) {
typeHandlers = new Hashtable(3); typeHandlers = new Hashtable<String, EditorKit>(3);
} }
typeHandlers.put(type, k); typeHandlers.put(type, k);
} }
...@@ -1176,13 +1175,12 @@ public class JEditorPane extends JTextComponent { ...@@ -1176,13 +1175,12 @@ public class JEditorPane extends JTextComponent {
* registered for the given type * registered for the given type
*/ */
public static EditorKit createEditorKitForContentType(String type) { public static EditorKit createEditorKitForContentType(String type) {
EditorKit k = null; Hashtable<String, EditorKit> kitRegistry = getKitRegisty();
Hashtable kitRegistry = getKitRegisty(); EditorKit k = kitRegistry.get(type);
k = (EditorKit) kitRegistry.get(type);
if (k == null) { if (k == null) {
// try to dynamically load the support // try to dynamically load the support
String classname = (String) getKitTypeRegistry().get(type); String classname = getKitTypeRegistry().get(type);
ClassLoader loader = (ClassLoader) getKitLoaderRegistry().get(type); ClassLoader loader = getKitLoaderRegistry().get(type);
try { try {
Class c; Class c;
if (loader != null) { if (loader != null) {
...@@ -1252,20 +1250,20 @@ public class JEditorPane extends JTextComponent { ...@@ -1252,20 +1250,20 @@ public class JEditorPane extends JTextComponent {
* @since 1.3 * @since 1.3
*/ */
public static String getEditorKitClassNameForContentType(String type) { public static String getEditorKitClassNameForContentType(String type) {
return (String)getKitTypeRegistry().get(type); return getKitTypeRegistry().get(type);
} }
private static Hashtable getKitTypeRegistry() { private static Hashtable<String, String> getKitTypeRegistry() {
loadDefaultKitsIfNecessary(); loadDefaultKitsIfNecessary();
return (Hashtable)SwingUtilities.appContextGet(kitTypeRegistryKey); return (Hashtable)SwingUtilities.appContextGet(kitTypeRegistryKey);
} }
private static Hashtable getKitLoaderRegistry() { private static Hashtable<String, ClassLoader> getKitLoaderRegistry() {
loadDefaultKitsIfNecessary(); loadDefaultKitsIfNecessary();
return (Hashtable)SwingUtilities.appContextGet(kitLoaderRegistryKey); return (Hashtable)SwingUtilities.appContextGet(kitLoaderRegistryKey);
} }
private static Hashtable getKitRegisty() { private static Hashtable<String, EditorKit> getKitRegisty() {
Hashtable ht = (Hashtable)SwingUtilities.appContextGet(kitRegistryKey); Hashtable ht = (Hashtable)SwingUtilities.appContextGet(kitRegistryKey);
if (ht == null) { if (ht == null) {
ht = new Hashtable(3); ht = new Hashtable(3);
...@@ -1512,7 +1510,7 @@ public class JEditorPane extends JTextComponent { ...@@ -1512,7 +1510,7 @@ public class JEditorPane extends JTextComponent {
private EditorKit kit; private EditorKit kit;
private boolean isUserSetEditorKit; private boolean isUserSetEditorKit;
private Hashtable pageProperties; private Hashtable<String, Object> pageProperties;
/** Should be kept in sync with javax.swing.text.html.FormView counterpart. */ /** Should be kept in sync with javax.swing.text.html.FormView counterpart. */
final static String PostDataProperty = "javax.swing.JEditorPane.postdata"; final static String PostDataProperty = "javax.swing.JEditorPane.postdata";
...@@ -1520,7 +1518,7 @@ public class JEditorPane extends JTextComponent { ...@@ -1520,7 +1518,7 @@ public class JEditorPane extends JTextComponent {
/** /**
* Table of registered type handlers for this editor. * Table of registered type handlers for this editor.
*/ */
private Hashtable typeHandlers; private Hashtable<String, EditorKit> typeHandlers;
/* /*
* Private AppContext keys for this class's static variables. * Private AppContext keys for this class's static variables.
...@@ -1913,11 +1911,11 @@ public class JEditorPane extends JTextComponent { ...@@ -1913,11 +1911,11 @@ public class JEditorPane extends JTextComponent {
} }
} }
private class LinkVector extends Vector { private class LinkVector extends Vector<HTMLLink> {
public int baseElementIndex(Element e) { public int baseElementIndex(Element e) {
HTMLLink l; HTMLLink l;
for (int i = 0; i < elementCount; i++) { for (int i = 0; i < elementCount; i++) {
l = (HTMLLink) elementAt(i); l = elementAt(i);
if (l.element == e) { if (l.element == e) {
return i; return i;
} }
...@@ -2029,7 +2027,7 @@ public class JEditorPane extends JTextComponent { ...@@ -2029,7 +2027,7 @@ public class JEditorPane extends JTextComponent {
buildLinkTable(); buildLinkTable();
} }
if (linkIndex >= 0 && linkIndex < hyperlinks.size()) { if (linkIndex >= 0 && linkIndex < hyperlinks.size()) {
return (AccessibleHyperlink) hyperlinks.elementAt(linkIndex); return hyperlinks.elementAt(linkIndex);
} else { } else {
return null; return null;
} }
......
...@@ -248,7 +248,7 @@ public class JFileChooser extends JComponent implements Accessible { ...@@ -248,7 +248,7 @@ public class JFileChooser extends JComponent implements Accessible {
private String approveButtonToolTipText = null; private String approveButtonToolTipText = null;
private int approveButtonMnemonic = 0; private int approveButtonMnemonic = 0;
private Vector filters = new Vector(5); private Vector<FileFilter> filters = new Vector<FileFilter>(5);
private JDialog dialog = null; private JDialog dialog = null;
private int dialogType = OPEN_DIALOG; private int dialogType = OPEN_DIALOG;
private int returnValue = ERROR_OPTION; private int returnValue = ERROR_OPTION;
...@@ -503,7 +503,7 @@ public class JFileChooser extends JComponent implements Accessible { ...@@ -503,7 +503,7 @@ public class JFileChooser extends JComponent implements Accessible {
if(selectedFiles == null) { if(selectedFiles == null) {
return new File[0]; return new File[0];
} else { } else {
return (File[]) selectedFiles.clone(); return selectedFiles.clone();
} }
} }
...@@ -1415,17 +1415,17 @@ public class JFileChooser extends JComponent implements Accessible { ...@@ -1415,17 +1415,17 @@ public class JFileChooser extends JComponent implements Accessible {
fileFilter = filter; fileFilter = filter;
if (filter != null) { if (filter != null) {
if (isMultiSelectionEnabled() && selectedFiles != null && selectedFiles.length > 0) { if (isMultiSelectionEnabled() && selectedFiles != null && selectedFiles.length > 0) {
Vector fList = new Vector(); Vector<File> fList = new Vector<File>();
boolean failed = false; boolean failed = false;
for (int i = 0; i < selectedFiles.length; i++) { for (File file : selectedFiles) {
if (filter.accept(selectedFiles[i])) { if (filter.accept(file)) {
fList.add(selectedFiles[i]); fList.add(file);
} else { } else {
failed = true; failed = true;
} }
} }
if (failed) { if (failed) {
setSelectedFiles((fList.size() == 0) ? null : (File[])fList.toArray(new File[fList.size()])); setSelectedFiles((fList.size() == 0) ? null : fList.toArray(new File[fList.size()]));
} }
} else if (selectedFile != null && !filter.accept(selectedFile)) { } else if (selectedFile != null && !filter.accept(selectedFile)) {
setSelectedFile(null); setSelectedFile(null);
...@@ -1702,8 +1702,7 @@ public class JFileChooser extends JComponent implements Accessible { ...@@ -1702,8 +1702,7 @@ public class JFileChooser extends JComponent implements Accessible {
* @since 1.4 * @since 1.4
*/ */
public ActionListener[] getActionListeners() { public ActionListener[] getActionListeners() {
return (ActionListener[])listenerList.getListeners( return listenerList.getListeners(ActionListener.class);
ActionListener.class);
} }
/** /**
...@@ -1744,7 +1743,7 @@ public class JFileChooser extends JComponent implements Accessible { ...@@ -1744,7 +1743,7 @@ public class JFileChooser extends JComponent implements Accessible {
WeakReference<JFileChooser> jfcRef; WeakReference<JFileChooser> jfcRef;
public WeakPCL(JFileChooser jfc) { public WeakPCL(JFileChooser jfc) {
jfcRef = new WeakReference(jfc); jfcRef = new WeakReference<JFileChooser>(jfc);
} }
public void propertyChange(PropertyChangeEvent ev) { public void propertyChange(PropertyChangeEvent ev) {
assert ev.getPropertyName().equals(SHOW_HIDDEN_PROP); assert ev.getPropertyName().equals(SHOW_HIDDEN_PROP);
......
...@@ -421,8 +421,8 @@ public class JInternalFrame extends JComponent implements ...@@ -421,8 +421,8 @@ public class JInternalFrame extends JComponent implements
invalidate(); invalidate();
Component[] children = getComponents(); Component[] children = getComponents();
if (children != null) { if (children != null) {
for(int i = 0; i < children.length; i++) { for (Component child : children) {
SwingUtilities.updateComponentTreeUI(children[i]); SwingUtilities.updateComponentTreeUI(child);
} }
} }
} }
...@@ -1535,8 +1535,7 @@ public class JInternalFrame extends JComponent implements ...@@ -1535,8 +1535,7 @@ public class JInternalFrame extends JComponent implements
* @see #addInternalFrameListener * @see #addInternalFrameListener
*/ */
public InternalFrameListener[] getInternalFrameListeners() { public InternalFrameListener[] getInternalFrameListeners() {
return (InternalFrameListener[])listenerList.getListeners( return listenerList.getListeners(InternalFrameListener.class);
InternalFrameListener.class);
} }
// remind: name ok? all one method ok? need to be synchronized? // remind: name ok? all one method ok? need to be synchronized?
...@@ -2258,8 +2257,8 @@ public class JInternalFrame extends JComponent implements ...@@ -2258,8 +2257,8 @@ public class JInternalFrame extends JComponent implements
invalidate(); invalidate();
Component[] children = getComponents(); Component[] children = getComponents();
if (children != null) { if (children != null) {
for(int i = 0; i < children.length; i++) { for (Component child : children) {
SwingUtilities.updateComponentTreeUI(children[i]); SwingUtilities.updateComponentTreeUI(child);
} }
} }
} }
......
...@@ -191,7 +191,7 @@ public class JLayeredPane extends JComponent implements Accessible { ...@@ -191,7 +191,7 @@ public class JLayeredPane extends JComponent implements Accessible {
private void validateOptimizedDrawing() { private void validateOptimizedDrawing() {
boolean layeredComponentFound = false; boolean layeredComponentFound = false;
synchronized(getTreeLock()) { synchronized(getTreeLock()) {
Integer layer = null; Integer layer;
for (Component c : getComponents()) { for (Component c : getComponents()) {
layer = null; layer = null;
...@@ -213,7 +213,7 @@ public class JLayeredPane extends JComponent implements Accessible { ...@@ -213,7 +213,7 @@ public class JLayeredPane extends JComponent implements Accessible {
} }
protected void addImpl(Component comp, Object constraints, int index) { protected void addImpl(Component comp, Object constraints, int index) {
int layer = DEFAULT_LAYER.intValue(); int layer;
int pos; int pos;
if(constraints instanceof Integer) { if(constraints instanceof Integer) {
...@@ -364,7 +364,7 @@ public class JLayeredPane extends JComponent implements Accessible { ...@@ -364,7 +364,7 @@ public class JLayeredPane extends JComponent implements Accessible {
if(c instanceof JComponent) if(c instanceof JComponent)
((JComponent)c).putClientProperty(LAYER_PROPERTY, layerObj); ((JComponent)c).putClientProperty(LAYER_PROPERTY, layerObj);
else else
getComponentToLayer().put((Component)c, layerObj); getComponentToLayer().put(c, layerObj);
if(c.getParent() == null || c.getParent() != this) { if(c.getParent() == null || c.getParent() != this) {
repaint(c.getBounds()); repaint(c.getBounds());
...@@ -388,7 +388,7 @@ public class JLayeredPane extends JComponent implements Accessible { ...@@ -388,7 +388,7 @@ public class JLayeredPane extends JComponent implements Accessible {
if(c instanceof JComponent) if(c instanceof JComponent)
i = (Integer)((JComponent)c).getClientProperty(LAYER_PROPERTY); i = (Integer)((JComponent)c).getClientProperty(LAYER_PROPERTY);
else else
i = (Integer)getComponentToLayer().get((Component)c); i = getComponentToLayer().get(c);
if(i == null) if(i == null)
return DEFAULT_LAYER.intValue(); return DEFAULT_LAYER.intValue();
...@@ -465,9 +465,9 @@ public class JLayeredPane extends JComponent implements Accessible { ...@@ -465,9 +465,9 @@ public class JLayeredPane extends JComponent implements Accessible {
* @see #getComponentCountInLayer * @see #getComponentCountInLayer
*/ */
public int getPosition(Component c) { public int getPosition(Component c) {
int i, count, startLayer, curLayer, startLocation, pos = 0; int i, startLayer, curLayer, startLocation, pos = 0;
count = getComponentCount(); getComponentCount();
startLocation = getIndexOf(c); startLocation = getIndexOf(c);
if(startLocation == -1) if(startLocation == -1)
......
...@@ -1848,8 +1848,7 @@ public class JList extends JComponent implements Scrollable, Accessible ...@@ -1848,8 +1848,7 @@ public class JList extends JComponent implements Scrollable, Accessible
* @since 1.4 * @since 1.4
*/ */
public ListSelectionListener[] getListSelectionListeners() { public ListSelectionListener[] getListSelectionListeners() {
return (ListSelectionListener[])listenerList.getListeners( return listenerList.getListeners(ListSelectionListener.class);
ListSelectionListener.class);
} }
...@@ -2220,9 +2219,9 @@ public class JList extends JComponent implements Scrollable, Accessible ...@@ -2220,9 +2219,9 @@ public class JList extends JComponent implements Scrollable, Accessible
ListSelectionModel sm = getSelectionModel(); ListSelectionModel sm = getSelectionModel();
sm.clearSelection(); sm.clearSelection();
int size = getModel().getSize(); int size = getModel().getSize();
for(int i = 0; i < indices.length; i++) { for (int i : indices) {
if (indices[i] < size) { if (i < size) {
sm.addSelectionInterval(indices[i], indices[i]); sm.addSelectionInterval(i, i);
} }
} }
} }
...@@ -2724,7 +2723,7 @@ public class JList extends JComponent implements Scrollable, Accessible ...@@ -2724,7 +2723,7 @@ public class JList extends JComponent implements Scrollable, Accessible
return true; return true;
} }
if (getParent() instanceof JViewport) { if (getParent() instanceof JViewport) {
return (((JViewport)getParent()).getWidth() > getPreferredSize().width); return (getParent().getWidth() > getPreferredSize().width);
} }
return false; return false;
} }
...@@ -2749,7 +2748,7 @@ public class JList extends JComponent implements Scrollable, Accessible ...@@ -2749,7 +2748,7 @@ public class JList extends JComponent implements Scrollable, Accessible
return true; return true;
} }
if (getParent() instanceof JViewport) { if (getParent() instanceof JViewport) {
return (((JViewport)getParent()).getHeight() > getPreferredSize().height); return (getParent().getHeight() > getPreferredSize().height);
} }
return false; return false;
} }
...@@ -3161,7 +3160,7 @@ public class JList extends JComponent implements Scrollable, Accessible ...@@ -3161,7 +3160,7 @@ public class JList extends JComponent implements Scrollable, Accessible
private AccessibleContext getCurrentAccessibleContext() { private AccessibleContext getCurrentAccessibleContext() {
Component c = getComponentAtIndex(indexInParent); Component c = getComponentAtIndex(indexInParent);
if (c instanceof Accessible) { if (c instanceof Accessible) {
return ((Accessible) c).getAccessibleContext(); return c.getAccessibleContext();
} else { } else {
return null; return null;
} }
......
...@@ -371,8 +371,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement ...@@ -371,8 +371,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
* @since 1.3 * @since 1.3
*/ */
protected Point getPopupMenuOrigin() { protected Point getPopupMenuOrigin() {
int x = 0; int x;
int y = 0; int y;
JPopupMenu pm = getPopupMenu(); JPopupMenu pm = getPopupMenu();
// Figure out the sizes needed to caclulate the menu position // Figure out the sizes needed to caclulate the menu position
Dimension s = getSize(); Dimension s = getSize();
...@@ -900,10 +900,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement ...@@ -900,10 +900,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
* on another menu * on another menu
*/ */
public boolean isTopLevelMenu() { public boolean isTopLevelMenu() {
if (getParent() instanceof JMenuBar) return getParent() instanceof JMenuBar;
return true;
return false;
} }
/** /**
...@@ -1015,7 +1013,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement ...@@ -1015,7 +1013,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
* @since 1.4 * @since 1.4
*/ */
public MenuListener[] getMenuListeners() { public MenuListener[] getMenuListeners() {
return (MenuListener[])listenerList.getListeners(MenuListener.class); return listenerList.getListeners(MenuListener.class);
} }
/** /**
...@@ -1305,7 +1303,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement ...@@ -1305,7 +1303,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
* @return the array of menu items * @return the array of menu items
*/ */
private MenuElement[] buildMenuElementArray(JMenu leaf) { private MenuElement[] buildMenuElementArray(JMenu leaf) {
Vector elements = new Vector(); Vector<MenuElement> elements = new Vector<MenuElement>();
Component current = leaf.getPopupMenu(); Component current = leaf.getPopupMenu();
JPopupMenu pop; JPopupMenu pop;
JMenu menu; JMenu menu;
...@@ -1409,8 +1407,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement ...@@ -1409,8 +1407,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
public int getAccessibleChildrenCount() { public int getAccessibleChildrenCount() {
Component[] children = getMenuComponents(); Component[] children = getMenuComponents();
int count = 0; int count = 0;
for (int j = 0; j < children.length; j++) { for (Component child : children) {
if (children[j] instanceof Accessible) { if (child instanceof Accessible) {
count++; count++;
} }
} }
...@@ -1426,18 +1424,18 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement ...@@ -1426,18 +1424,18 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
public Accessible getAccessibleChild(int i) { public Accessible getAccessibleChild(int i) {
Component[] children = getMenuComponents(); Component[] children = getMenuComponents();
int count = 0; int count = 0;
for (int j = 0; j < children.length; j++) { for (Component child : children) {
if (children[j] instanceof Accessible) { if (child instanceof Accessible) {
if (count == i) { if (count == i) {
if (children[j] instanceof JComponent) { if (child instanceof JComponent) {
// FIXME: [[[WDW - probably should set this when // FIXME: [[[WDW - probably should set this when
// the component is added to the menu. I tried // the component is added to the menu. I tried
// to do this in most cases, but the separators // to do this in most cases, but the separators
// added by addSeparator are hard to get to.]]] // added by addSeparator are hard to get to.]]]
AccessibleContext ac = ((Accessible) children[j]).getAccessibleContext(); AccessibleContext ac = child.getAccessibleContext();
ac.setAccessibleParent(JMenu.this); ac.setAccessibleParent(JMenu.this);
} }
return (Accessible) children[j]; return (Accessible) child;
} else { } else {
count++; count++;
} }
...@@ -1581,7 +1579,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement ...@@ -1581,7 +1579,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
} }
JMenuItem mi = getItem(i); JMenuItem mi = getItem(i);
if (mi != null && mi instanceof JMenu) { if (mi != null && mi instanceof JMenu) {
if (((JMenu) mi).isSelected()) { if (mi.isSelected()) {
MenuElement old[] = MenuElement old[] =
MenuSelectionManager.defaultManager().getSelectedPath(); MenuSelectionManager.defaultManager().getSelectedPath();
MenuElement me[] = new MenuElement[old.length-2]; MenuElement me[] = new MenuElement[old.length-2];
......
...@@ -414,7 +414,7 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement ...@@ -414,7 +414,7 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement
*/ */
public MenuElement[] getSubElements() { public MenuElement[] getSubElements() {
MenuElement result[]; MenuElement result[];
Vector tmp = new Vector(); Vector<MenuElement> tmp = new Vector<MenuElement>();
int c = getComponentCount(); int c = getComponentCount();
int i; int i;
Component m; Component m;
...@@ -422,12 +422,12 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement ...@@ -422,12 +422,12 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement
for(i=0 ; i < c ; i++) { for(i=0 ; i < c ; i++) {
m = getComponent(i); m = getComponent(i);
if(m instanceof MenuElement) if(m instanceof MenuElement)
tmp.addElement(m); tmp.addElement((MenuElement) m);
} }
result = new MenuElement[tmp.size()]; result = new MenuElement[tmp.size()];
for(i=0,c=tmp.size() ; i < c ; i++) for(i=0,c=tmp.size() ; i < c ; i++)
result[i] = (MenuElement) tmp.elementAt(i); result[i] = tmp.elementAt(i);
return result; return result;
} }
...@@ -664,9 +664,9 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement ...@@ -664,9 +664,9 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement
boolean retValue = super.processKeyBinding(ks, e, condition, pressed); boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
if (!retValue) { if (!retValue) {
MenuElement[] subElements = getSubElements(); MenuElement[] subElements = getSubElements();
for (int i=0; i<subElements.length; i++) { for (MenuElement subElement : subElements) {
if (processBindingForKeyStrokeRecursive( if (processBindingForKeyStrokeRecursive(
subElements[i], ks, e, condition, pressed)) { subElement, ks, e, condition, pressed)) {
return true; return true;
} }
} }
...@@ -693,9 +693,8 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement ...@@ -693,9 +693,8 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement
} }
MenuElement[] subElements = elem.getSubElements(); MenuElement[] subElements = elem.getSubElements();
for(int i=0; i<subElements.length; i++) { for (MenuElement subElement : subElements) {
if (processBindingForKeyStrokeRecursive(subElements[i], ks, e, if (processBindingForKeyStrokeRecursive(subElement, ks, e, condition, pressed)) {
condition, pressed)) {
return true; return true;
// We don't, pass along to children JMenu's // We don't, pass along to children JMenu's
} }
......
...@@ -275,7 +275,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement ...@@ -275,7 +275,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement
* hidden: true * hidden: true
*/ */
public void setArmed(boolean b) { public void setArmed(boolean b) {
ButtonModel model = (ButtonModel) getModel(); ButtonModel model = getModel();
boolean oldValue = model.isArmed(); boolean oldValue = model.isArmed();
if(model.isArmed() != b) { if(model.isArmed() != b) {
...@@ -290,7 +290,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement ...@@ -290,7 +290,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement
* @see #setArmed * @see #setArmed
*/ */
public boolean isArmed() { public boolean isArmed() {
ButtonModel model = (ButtonModel) getModel(); ButtonModel model = getModel();
return model.isArmed(); return model.isArmed();
} }
...@@ -721,8 +721,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement ...@@ -721,8 +721,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement
* @since 1.4 * @since 1.4
*/ */
public MenuDragMouseListener[] getMenuDragMouseListeners() { public MenuDragMouseListener[] getMenuDragMouseListeners() {
return (MenuDragMouseListener[])listenerList.getListeners( return listenerList.getListeners(MenuDragMouseListener.class);
MenuDragMouseListener.class);
} }
/** /**
...@@ -752,8 +751,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement ...@@ -752,8 +751,7 @@ public class JMenuItem extends AbstractButton implements Accessible,MenuElement
* @since 1.4 * @since 1.4
*/ */
public MenuKeyListener[] getMenuKeyListeners() { public MenuKeyListener[] getMenuKeyListeners() {
return (MenuKeyListener[])listenerList.getListeners( return listenerList.getListeners(MenuKeyListener.class);
MenuKeyListener.class);
} }
/** /**
......
...@@ -963,7 +963,7 @@ public class JOptionPane extends JComponent implements Accessible ...@@ -963,7 +963,7 @@ public class JOptionPane extends JComponent implements Accessible
} }
if (window instanceof SwingUtilities.SharedOwnerFrame) { if (window instanceof SwingUtilities.SharedOwnerFrame) {
WindowListener ownerShutdownListener = WindowListener ownerShutdownListener =
(WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); SwingUtilities.getSharedOwnerFrameShutdownListener();
dialog.addWindowListener(ownerShutdownListener); dialog.addWindowListener(ownerShutdownListener);
} }
initDialog(dialog, style, parentComponent); initDialog(dialog, style, parentComponent);
...@@ -1300,11 +1300,10 @@ public class JOptionPane extends JComponent implements Accessible ...@@ -1300,11 +1300,10 @@ public class JOptionPane extends JComponent implements Accessible
// Use reflection to get Container.startLWModal. // Use reflection to get Container.startLWModal.
try { try {
Object obj; Method method = AccessController.doPrivileged(new ModalPrivilegedAction(
obj = AccessController.doPrivileged(new ModalPrivilegedAction(
Container.class, "startLWModal")); Container.class, "startLWModal"));
if (obj != null) { if (method != null) {
((Method)obj).invoke(dialog, (Object[])null); method.invoke(dialog, (Object[])null);
} }
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
...@@ -1446,11 +1445,10 @@ public class JOptionPane extends JComponent implements Accessible ...@@ -1446,11 +1445,10 @@ public class JOptionPane extends JComponent implements Accessible
// Use reflection to get Container.startLWModal. // Use reflection to get Container.startLWModal.
try { try {
Object obj; Method method = AccessController.doPrivileged(new ModalPrivilegedAction(
obj = AccessController.doPrivileged(new ModalPrivilegedAction(
Container.class, "startLWModal")); Container.class, "startLWModal"));
if (obj != null) { if (method != null) {
((Method)obj).invoke(dialog, (Object[])null); method.invoke(dialog, (Object[])null);
} }
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
...@@ -1531,12 +1529,11 @@ public class JOptionPane extends JComponent implements Accessible ...@@ -1531,12 +1529,11 @@ public class JOptionPane extends JComponent implements Accessible
event.getPropertyName().equals(VALUE_PROPERTY)) { event.getPropertyName().equals(VALUE_PROPERTY)) {
// Use reflection to get Container.stopLWModal(). // Use reflection to get Container.stopLWModal().
try { try {
Object obj; Method method = AccessController.doPrivileged(
obj = AccessController.doPrivileged(
new ModalPrivilegedAction( new ModalPrivilegedAction(
Container.class, "stopLWModal")); Container.class, "stopLWModal"));
if (obj != null) { if (method != null) {
((Method)obj).invoke(iFrame, (Object[])null); method.invoke(iFrame, (Object[])null);
} }
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
...@@ -1852,7 +1849,7 @@ public class JOptionPane extends JComponent implements Accessible ...@@ -1852,7 +1849,7 @@ public class JOptionPane extends JComponent implements Accessible
* description: The UI object that implements the optionpane's LookAndFeel * description: The UI object that implements the optionpane's LookAndFeel
*/ */
public void setUI(OptionPaneUI ui) { public void setUI(OptionPaneUI ui) {
if ((OptionPaneUI)this.ui != ui) { if (this.ui != ui) {
super.setUI(ui); super.setUI(ui);
invalidate(); invalidate();
} }
...@@ -2327,7 +2324,7 @@ public class JOptionPane extends JComponent implements Accessible ...@@ -2327,7 +2324,7 @@ public class JOptionPane extends JComponent implements Accessible
// Serialization support. // Serialization support.
private void writeObject(ObjectOutputStream s) throws IOException { private void writeObject(ObjectOutputStream s) throws IOException {
Vector values = new Vector(); Vector<Object> values = new Vector<Object>();
s.defaultWriteObject(); s.defaultWriteObject();
// Save the icon, if its Serializable. // Save the icon, if its Serializable.
...@@ -2342,7 +2339,7 @@ public class JOptionPane extends JComponent implements Accessible ...@@ -2342,7 +2339,7 @@ public class JOptionPane extends JComponent implements Accessible
} }
// Save the treeModel, if its Serializable. // Save the treeModel, if its Serializable.
if(options != null) { if(options != null) {
Vector serOptions = new Vector(); Vector<Object> serOptions = new Vector<Object>();
for(int counter = 0, maxCounter = options.length; for(int counter = 0, maxCounter = options.length;
counter < maxCounter; counter++) counter < maxCounter; counter++)
...@@ -2510,16 +2507,16 @@ public class JOptionPane extends JComponent implements Accessible ...@@ -2510,16 +2507,16 @@ public class JOptionPane extends JComponent implements Accessible
/** /**
* Retrieves a method from the provided class and makes it accessible. * Retrieves a method from the provided class and makes it accessible.
*/ */
private static class ModalPrivilegedAction implements PrivilegedAction { private static class ModalPrivilegedAction implements PrivilegedAction<Method> {
private Class clazz; private Class<?> clazz;
private String methodName; private String methodName;
public ModalPrivilegedAction(Class clazz, String methodName) { public ModalPrivilegedAction(Class<?> clazz, String methodName) {
this.clazz = clazz; this.clazz = clazz;
this.methodName = methodName; this.methodName = methodName;
} }
public Object run() { public Method run() {
Method method = null; Method method = null;
try { try {
method = clazz.getDeclaredMethod(methodName, (Class[])null); method = clazz.getDeclaredMethod(methodName, (Class[])null);
......
...@@ -584,7 +584,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -584,7 +584,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
int nitems = getComponentCount(); int nitems = getComponentCount();
// PENDING(ges): Why not use an array? // PENDING(ges): Why not use an array?
Vector tempItems = new Vector(); Vector<Component> tempItems = new Vector<Component>();
/* Remove the item at index, nitems-index times /* Remove the item at index, nitems-index times
storing them in a temporary vector in the storing them in a temporary vector in the
...@@ -600,8 +600,8 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -600,8 +600,8 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
/* Add the removed items back to the menu, they are /* Add the removed items back to the menu, they are
already in the correct order in the temp vector. already in the correct order in the temp vector.
*/ */
for (int i = 0; i < tempItems.size() ; i++) { for (Component tempItem : tempItems) {
add((Component)tempItems.elementAt(i)); add(tempItem);
} }
} }
...@@ -632,8 +632,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -632,8 +632,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
* @since 1.4 * @since 1.4
*/ */
public PopupMenuListener[] getPopupMenuListeners() { public PopupMenuListener[] getPopupMenuListeners() {
return (PopupMenuListener[])listenerList.getListeners( return listenerList.getListeners(PopupMenuListener.class);
PopupMenuListener.class);
} }
/** /**
...@@ -665,8 +664,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -665,8 +664,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
* @since 1.5 * @since 1.5
*/ */
public MenuKeyListener[] getMenuKeyListeners() { public MenuKeyListener[] getMenuKeyListeners() {
return (MenuKeyListener[])listenerList.getListeners( return listenerList.getListeners(MenuKeyListener.class);
MenuKeyListener.class);
} }
/** /**
...@@ -781,7 +779,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -781,7 +779,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
// set selection path before popping up! // set selection path before popping up!
if (isPopupMenu()) { if (isPopupMenu()) {
MenuElement me[] = new MenuElement[1]; MenuElement me[] = new MenuElement[1];
me[0] = (MenuElement) this; me[0] = this;
MenuSelectionManager.defaultManager().setSelectedPath(me); MenuSelectionManager.defaultManager().setSelectedPath(me);
} }
} }
...@@ -848,10 +846,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -848,10 +846,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
* being displayed). * being displayed).
*/ */
public boolean isVisible() { public boolean isVisible() {
if(popup != null) return popup != null;
return true;
else
return false;
} }
/** /**
...@@ -1311,7 +1306,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -1311,7 +1306,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
// Serialization support. // Serialization support.
//////////// ////////////
private void writeObject(ObjectOutputStream s) throws IOException { private void writeObject(ObjectOutputStream s) throws IOException {
Vector values = new Vector(); Vector<Object> values = new Vector<Object>();
s.defaultWriteObject(); s.defaultWriteObject();
// Save the invoker, if its Serializable. // Save the invoker, if its Serializable.
...@@ -1494,7 +1489,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -1494,7 +1489,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
*/ */
public MenuElement[] getSubElements() { public MenuElement[] getSubElements() {
MenuElement result[]; MenuElement result[];
Vector tmp = new Vector(); Vector<MenuElement> tmp = new Vector<MenuElement>();
int c = getComponentCount(); int c = getComponentCount();
int i; int i;
Component m; Component m;
...@@ -1502,12 +1497,12 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -1502,12 +1497,12 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
for(i=0 ; i < c ; i++) { for(i=0 ; i < c ; i++) {
m = getComponent(i); m = getComponent(i);
if(m instanceof MenuElement) if(m instanceof MenuElement)
tmp.addElement(m); tmp.addElement((MenuElement) m);
} }
result = new MenuElement[tmp.size()]; result = new MenuElement[tmp.size()];
for(i=0,c=tmp.size() ; i < c ; i++) for(i=0,c=tmp.size() ; i < c ; i++)
result[i] = (MenuElement) tmp.elementAt(i); result[i] = tmp.elementAt(i);
return result; return result;
} }
......
...@@ -699,8 +699,7 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib ...@@ -699,8 +699,7 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
/** /**
......
...@@ -659,8 +659,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible ...@@ -659,8 +659,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
* @since 1.4 * @since 1.4
*/ */
public AdjustmentListener[] getAdjustmentListeners() { public AdjustmentListener[] getAdjustmentListeners() {
return (AdjustmentListener[])listenerList.getListeners( return listenerList.getListeners(AdjustmentListener.class);
AdjustmentListener.class);
} }
...@@ -754,8 +753,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible ...@@ -754,8 +753,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
public void setEnabled(boolean x) { public void setEnabled(boolean x) {
super.setEnabled(x); super.setEnabled(x);
Component[] children = getComponents(); Component[] children = getComponents();
for(int i = 0; i < children.length; i++) { for (Component child : children) {
children[i].setEnabled(x); child.setEnabled(x);
} }
} }
......
...@@ -930,7 +930,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { ...@@ -930,7 +930,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
throw new IllegalArgumentException( "Label incremement must be > 0" ); throw new IllegalArgumentException( "Label incremement must be > 0" );
} }
class SmartHashtable extends Hashtable implements PropertyChangeListener { class SmartHashtable extends Hashtable<Object, Object> implements PropertyChangeListener {
int increment = 0; int increment = 0;
int start = 0; int start = 0;
boolean startAtMin = false; boolean startAtMin = false;
...@@ -977,9 +977,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { ...@@ -977,9 +977,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
if ( e.getPropertyName().equals( "minimum" ) || if ( e.getPropertyName().equals( "minimum" ) ||
e.getPropertyName().equals( "maximum" ) ) { e.getPropertyName().equals( "maximum" ) ) {
Dictionary labelTable = getLabelTable(); Enumeration keys = getLabelTable().keys();
Enumeration keys = labelTable.keys(); Hashtable<Object, Object> hashtable = new Hashtable<Object, Object>();
Hashtable hashtable = new Hashtable();
// Save the labels that were added by the developer // Save the labels that were added by the developer
while ( keys.hasMoreElements() ) { while ( keys.hasMoreElements() ) {
......
...@@ -433,8 +433,7 @@ public class JSpinner extends JComponent implements Accessible ...@@ -433,8 +433,7 @@ public class JSpinner extends JComponent implements Accessible
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
...@@ -1536,7 +1535,7 @@ public class JSpinner extends JComponent implements Accessible ...@@ -1536,7 +1535,7 @@ public class JSpinner extends JComponent implements Accessible
return textField.getAccessibleContext(); return textField.getAccessibleContext();
} }
} else if (editor instanceof Accessible) { } else if (editor instanceof Accessible) {
return ((Accessible)editor).getAccessibleContext(); return editor.getAccessibleContext();
} }
return null; return null;
} }
...@@ -1693,7 +1692,7 @@ public class JSpinner extends JComponent implements Accessible ...@@ -1693,7 +1692,7 @@ public class JSpinner extends JComponent implements Accessible
if (i < 0 || i > 1) { if (i < 0 || i > 1) {
return false; return false;
} }
Object o = null; Object o;
if (i == 0) { if (i == 0) {
o = getNextValue(); // AccessibleAction.INCREMENT o = getNextValue(); // AccessibleAction.INCREMENT
} else { } else {
......
...@@ -313,8 +313,7 @@ public class JTabbedPane extends JComponent ...@@ -313,8 +313,7 @@ public class JTabbedPane extends JComponent
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
/** /**
...@@ -2062,7 +2061,7 @@ public class JTabbedPane extends JComponent ...@@ -2062,7 +2061,7 @@ public class JTabbedPane extends JComponent
* Accessibility classes unnecessarily. * Accessibility classes unnecessarily.
*/ */
AccessibleContext ac; AccessibleContext ac;
ac = ((Accessible) component).getAccessibleContext(); ac = component.getAccessibleContext();
if (ac != null) { if (ac != null) {
ac.setAccessibleParent(this); ac.setAccessibleParent(this);
} }
......
...@@ -1677,16 +1677,16 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -1677,16 +1677,16 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
if (!forDrop && state != null) { if (!forDrop && state != null) {
clearSelection(); clearSelection();
int[] rows = (int[])((int[][])state)[0]; int[] rows = ((int[][])state)[0];
int[] cols = (int[])((int[][])state)[1]; int[] cols = ((int[][])state)[1];
int[] anchleads = (int[])((int[][])state)[2]; int[] anchleads = ((int[][])state)[2];
for (int i = 0; i < rows.length; i++) { for (int row : rows) {
addRowSelectionInterval(rows[i], rows[i]); addRowSelectionInterval(row, row);
} }
for (int i = 0; i < cols.length; i++) { for (int col : cols) {
addColumnSelectionInterval(cols[i], cols[i]); addColumnSelectionInterval(col, col);
} }
SwingUtilities2.setLeadAnchorWithoutSelection( SwingUtilities2.setLeadAnchorWithoutSelection(
...@@ -1776,7 +1776,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -1776,7 +1776,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
boolean oldValue = this.autoCreateRowSorter; boolean oldValue = this.autoCreateRowSorter;
this.autoCreateRowSorter = autoCreateRowSorter; this.autoCreateRowSorter = autoCreateRowSorter;
if (autoCreateRowSorter) { if (autoCreateRowSorter) {
setRowSorter(new TableRowSorter(getModel())); setRowSorter(new TableRowSorter<TableModel>(getModel()));
} }
firePropertyChange("autoCreateRowSorter", oldValue, firePropertyChange("autoCreateRowSorter", oldValue,
autoCreateRowSorter); autoCreateRowSorter);
...@@ -3198,7 +3198,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -3198,7 +3198,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
private void accommodateDelta(int resizingColumnIndex, int delta) { private void accommodateDelta(int resizingColumnIndex, int delta) {
int columnCount = getColumnCount(); int columnCount = getColumnCount();
int from = resizingColumnIndex; int from = resizingColumnIndex;
int to = columnCount; int to;
// Use the mode to determine how to absorb the changes. // Use the mode to determine how to absorb the changes.
switch(autoResizeMode) { switch(autoResizeMode) {
...@@ -3237,8 +3237,6 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -3237,8 +3237,6 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
} }
adjustSizes(totalWidth + delta, r, false); adjustSizes(totalWidth + delta, r, false);
return;
} }
private interface Resizable2 { private interface Resizable2 {
...@@ -3492,7 +3490,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -3492,7 +3490,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #editingRow * @see #editingRow
*/ */
public boolean isEditing() { public boolean isEditing() {
return (cellEditor == null)? false : true; return cellEditor != null;
} }
/** /**
...@@ -3642,7 +3640,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -3642,7 +3640,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
firePropertyChange("model", old, dataModel); firePropertyChange("model", old, dataModel);
if (getAutoCreateRowSorter()) { if (getAutoCreateRowSorter()) {
setRowSorter(new TableRowSorter(dataModel)); setRowSorter(new TableRowSorter<TableModel>(dataModel));
} }
} }
} }
...@@ -5160,7 +5158,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -5160,7 +5158,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
public boolean getScrollableTracksViewportHeight() { public boolean getScrollableTracksViewportHeight() {
return getFillsViewportHeight() return getFillsViewportHeight()
&& getParent() instanceof JViewport && getParent() instanceof JViewport
&& (((JViewport)getParent()).getHeight() > getPreferredSize().height); && (getParent().getHeight() > getPreferredSize().height);
} }
/** /**
...@@ -5214,7 +5212,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -5214,7 +5212,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
// by setting the client property JTable.autoStartsEdit to Boolean.FALSE. // by setting the client property JTable.autoStartsEdit to Boolean.FALSE.
if (!retValue && condition == WHEN_ANCESTOR_OF_FOCUSED_COMPONENT && if (!retValue && condition == WHEN_ANCESTOR_OF_FOCUSED_COMPONENT &&
isFocusOwner() && isFocusOwner() &&
!Boolean.FALSE.equals((Boolean)getClientProperty("JTable.autoStartsEdit"))) { !Boolean.FALSE.equals(getClientProperty("JTable.autoStartsEdit"))) {
// We do not have a binding for the event. // We do not have a binding for the event.
Component editorComponent = getEditorComponent(); Component editorComponent = getEditorComponent();
if (editorComponent == null) { if (editorComponent == null) {
...@@ -5436,7 +5434,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -5436,7 +5434,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
this.value = null; this.value = null;
((JComponent)getComponent()).setBorder(new LineBorder(Color.black)); ((JComponent)getComponent()).setBorder(new LineBorder(Color.black));
try { try {
Class type = table.getColumnClass(column); Class<?> type = table.getColumnClass(column);
// Since our obligation is to produce a value which is // Since our obligation is to produce a value which is
// assignable for the required type it is OK to use the // assignable for the required type it is OK to use the
// String constructor for columns which are declared // String constructor for columns which are declared
...@@ -6627,10 +6625,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -6627,10 +6625,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
} else if (name.compareTo("tableCellEditor") == 0) { } else if (name.compareTo("tableCellEditor") == 0) {
if (oldValue != null && oldValue instanceof TableCellEditor) { if (oldValue != null && oldValue instanceof TableCellEditor) {
((TableCellEditor) oldValue).removeCellEditorListener((CellEditorListener) this); ((TableCellEditor) oldValue).removeCellEditorListener(this);
} }
if (newValue != null && newValue instanceof TableCellEditor) { if (newValue != null && newValue instanceof TableCellEditor) {
((TableCellEditor) newValue).addCellEditorListener((CellEditorListener) this); ((TableCellEditor) newValue).addCellEditorListener(this);
} }
} }
} }
...@@ -7045,7 +7043,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -7045,7 +7043,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
*/ */
public Accessible getAccessibleSelection(int i) { public Accessible getAccessibleSelection(int i) {
if (i < 0 || i > getAccessibleSelectionCount()) { if (i < 0 || i > getAccessibleSelectionCount()) {
return (Accessible) null; return null;
} }
int rowsSel = JTable.this.getSelectedRowCount(); int rowsSel = JTable.this.getSelectedRowCount();
...@@ -7158,7 +7156,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -7158,7 +7156,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
return getAccessibleChild((r * ttlCols) + c); return getAccessibleChild((r * ttlCols) + c);
} }
} }
return (Accessible) null; return null;
} }
/** /**
...@@ -7906,7 +7904,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -7906,7 +7904,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
JTable.this, getValueAt(row, column), JTable.this, getValueAt(row, column),
false, false, row, column); false, false, row, column);
if (component instanceof Accessible) { if (component instanceof Accessible) {
return ((Accessible) component).getAccessibleContext(); return component.getAccessibleContext();
} else { } else {
return null; return null;
} }
......
...@@ -475,8 +475,7 @@ public class JTextField extends JTextComponent implements SwingConstants { ...@@ -475,8 +475,7 @@ public class JTextField extends JTextComponent implements SwingConstants {
* @since 1.4 * @since 1.4
*/ */
public synchronized ActionListener[] getActionListeners() { public synchronized ActionListener[] getActionListeners() {
return (ActionListener[])listenerList.getListeners( return listenerList.getListeners(ActionListener.class);
ActionListener.class);
} }
/** /**
......
...@@ -187,7 +187,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -187,7 +187,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* information must be determined by visiting all the parent * information must be determined by visiting all the parent
* paths and seeing if they are visible. * paths and seeing if they are visible.
*/ */
transient private Hashtable expandedState; transient private Hashtable<TreePath, Boolean> expandedState;
/** /**
...@@ -281,7 +281,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -281,7 +281,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* Used when <code>setExpandedState</code> is invoked, * Used when <code>setExpandedState</code> is invoked,
* will be a <code>Stack</code> of <code>Stack</code>s. * will be a <code>Stack</code> of <code>Stack</code>s.
*/ */
transient private Stack expandedStack; transient private Stack<Stack<TreePath>> expandedStack;
/** /**
* Lead selection path, may not be <code>null</code>. * Lead selection path, may not be <code>null</code>.
...@@ -652,9 +652,9 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -652,9 +652,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
@ConstructorProperties({"model"}) @ConstructorProperties({"model"})
public JTree(TreeModel newModel) { public JTree(TreeModel newModel) {
super(); super();
expandedStack = new Stack(); expandedStack = new Stack<Stack<TreePath>>();
toggleClickCount = 2; toggleClickCount = 2;
expandedState = new Hashtable(); expandedState = new Hashtable<TreePath, Boolean>();
setLayout(null); setLayout(null);
rowHeight = 16; rowHeight = 16;
visibleRowCount = 20; visibleRowCount = 20;
...@@ -691,7 +691,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -691,7 +691,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* description: The UI object that implements the Component's LookAndFeel. * description: The UI object that implements the Component's LookAndFeel.
*/ */
public void setUI(TreeUI ui) { public void setUI(TreeUI ui) {
if ((TreeUI)this.ui != ui) { if (this.ui != ui) {
settingUI = true; settingUI = true;
uiTreeExpansionListener = null; uiTreeExpansionListener = null;
try { try {
...@@ -1298,8 +1298,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -1298,8 +1298,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
Object root = (model == null) ? null : model.getRoot(); Object root = (model == null) ? null : model.getRoot();
TreePath rootPath = (root == null) ? null : new TreePath(root); TreePath rootPath = (root == null) ? null : new TreePath(root);
TreePath child = null; TreePath child;
TreePath parent = null; TreePath parent;
boolean outside = row == -1 boolean outside = row == -1
|| p.y < bounds.y || p.y < bounds.y
|| p.y >= bounds.y + bounds.height; || p.y >= bounds.y + bounds.height;
...@@ -1940,14 +1940,14 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -1940,14 +1940,14 @@ public class JTree extends JComponent implements Scrollable, Accessible
if(!isExpanded(parent)) if(!isExpanded(parent))
return null; return null;
Enumeration toggledPaths = expandedState.keys(); Enumeration<TreePath> toggledPaths = expandedState.keys();
Vector elements = null; Vector<TreePath> elements = null;
TreePath path; TreePath path;
Object value; Object value;
if(toggledPaths != null) { if(toggledPaths != null) {
while(toggledPaths.hasMoreElements()) { while(toggledPaths.hasMoreElements()) {
path = (TreePath)toggledPaths.nextElement(); path = toggledPaths.nextElement();
value = expandedState.get(path); value = expandedState.get(path);
// Add the path if it is expanded, a descendant of parent, // Add the path if it is expanded, a descendant of parent,
// and it is visible (all parents expanded). This is rather // and it is visible (all parents expanded). This is rather
...@@ -1956,7 +1956,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -1956,7 +1956,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
((Boolean)value).booleanValue() && ((Boolean)value).booleanValue() &&
parent.isDescendant(path) && isVisible(path)) { parent.isDescendant(path) && isVisible(path)) {
if (elements == null) { if (elements == null) {
elements = new Vector(); elements = new Vector<TreePath>();
} }
elements.addElement(path); elements.addElement(path);
} }
...@@ -1990,9 +1990,9 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -1990,9 +1990,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
return false; return false;
// Is this node expanded? // Is this node expanded?
Object value = expandedState.get(path); Boolean value = expandedState.get(path);
if(value == null || !((Boolean)value).booleanValue()) if(value == null || !value.booleanValue())
return false; return false;
// It is, make sure its parent is also expanded. // It is, make sure its parent is also expanded.
...@@ -2018,7 +2018,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -2018,7 +2018,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
TreePath path = tree.getPathForRow(this, row); TreePath path = tree.getPathForRow(this, row);
if(path != null) { if(path != null) {
Boolean value = (Boolean)expandedState.get(path); Boolean value = expandedState.get(path);
return (value != null && value.booleanValue()); return (value != null && value.booleanValue());
} }
...@@ -2704,8 +2704,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -2704,8 +2704,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @since 1.4 * @since 1.4
*/ */
public TreeExpansionListener[] getTreeExpansionListeners() { public TreeExpansionListener[] getTreeExpansionListeners() {
return (TreeExpansionListener[])listenerList.getListeners( return listenerList.getListeners(TreeExpansionListener.class);
TreeExpansionListener.class);
} }
/** /**
...@@ -2737,8 +2736,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -2737,8 +2736,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @since 1.4 * @since 1.4
*/ */
public TreeWillExpandListener[] getTreeWillExpandListeners() { public TreeWillExpandListener[] getTreeWillExpandListeners() {
return (TreeWillExpandListener[])listenerList.getListeners( return listenerList.getListeners(TreeWillExpandListener.class);
TreeWillExpandListener.class);
} }
/** /**
...@@ -2895,8 +2893,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -2895,8 +2893,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @since 1.4 * @since 1.4
*/ */
public TreeSelectionListener[] getTreeSelectionListeners() { public TreeSelectionListener[] getTreeSelectionListeners() {
return (TreeSelectionListener[])listenerList.getListeners( return listenerList.getListeners(TreeSelectionListener.class);
TreeSelectionListener.class);
} }
/** /**
...@@ -3030,7 +3027,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3030,7 +3027,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
// Serialization support. // Serialization support.
private void writeObject(ObjectOutputStream s) throws IOException { private void writeObject(ObjectOutputStream s) throws IOException {
Vector values = new Vector(); Vector<Object> values = new Vector<Object>();
s.defaultWriteObject(); s.defaultWriteObject();
// Save the cellRenderer, if its Serializable. // Save the cellRenderer, if its Serializable.
...@@ -3077,9 +3074,9 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3077,9 +3074,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
// Create an instance of expanded state. // Create an instance of expanded state.
expandedState = new Hashtable(); expandedState = new Hashtable<TreePath, Boolean>();
expandedStack = new Stack(); expandedStack = new Stack<Stack<TreePath>>();
Vector values = (Vector)s.readObject(); Vector values = (Vector)s.readObject();
int indexCounter = 0; int indexCounter = 0;
...@@ -3132,13 +3129,13 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3132,13 +3129,13 @@ public class JTree extends JComponent implements Scrollable, Accessible
TreeModel model = getModel(); TreeModel model = getModel();
if(model != null) { if(model != null) {
Enumeration paths = expandedState.keys(); Enumeration<TreePath> paths = expandedState.keys();
if(paths != null) { if(paths != null) {
Vector state = new Vector(); Vector<Object> state = new Vector<Object>();
while(paths.hasMoreElements()) { while(paths.hasMoreElements()) {
TreePath path = (TreePath)paths.nextElement(); TreePath path = paths.nextElement();
Object archivePath; Object archivePath;
try { try {
...@@ -3502,7 +3499,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3502,7 +3499,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
*/ */
public boolean getScrollableTracksViewportWidth() { public boolean getScrollableTracksViewportWidth() {
if (getParent() instanceof JViewport) { if (getParent() instanceof JViewport) {
return (((JViewport)getParent()).getWidth() > getPreferredSize().width); return getParent().getWidth() > getPreferredSize().width;
} }
return false; return false;
} }
...@@ -3518,7 +3515,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3518,7 +3515,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
*/ */
public boolean getScrollableTracksViewportHeight() { public boolean getScrollableTracksViewportHeight() {
if (getParent() instanceof JViewport) { if (getParent() instanceof JViewport) {
return (((JViewport)getParent()).getHeight() > getPreferredSize().height); return getParent().getHeight() > getPreferredSize().height;
} }
return false; return false;
} }
...@@ -3535,14 +3532,14 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3535,14 +3532,14 @@ public class JTree extends JComponent implements Scrollable, Accessible
protected void setExpandedState(TreePath path, boolean state) { protected void setExpandedState(TreePath path, boolean state) {
if(path != null) { if(path != null) {
// Make sure all parents of path are expanded. // Make sure all parents of path are expanded.
Stack stack; Stack<TreePath> stack;
TreePath parentPath = path.getParentPath(); TreePath parentPath = path.getParentPath();
if (expandedStack.size() == 0) { if (expandedStack.size() == 0) {
stack = new Stack(); stack = new Stack<TreePath>();
} }
else { else {
stack = (Stack)expandedStack.pop(); stack = expandedStack.pop();
} }
try { try {
...@@ -3556,7 +3553,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3556,7 +3553,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
} }
} }
for(int counter = stack.size() - 1; counter >= 0; counter--) { for(int counter = stack.size() - 1; counter >= 0; counter--) {
parentPath = (TreePath)stack.pop(); parentPath = stack.pop();
if(!isExpanded(parentPath)) { if(!isExpanded(parentPath)) {
try { try {
fireTreeWillExpand(parentPath); fireTreeWillExpand(parentPath);
...@@ -3636,12 +3633,11 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3636,12 +3633,11 @@ public class JTree extends JComponent implements Scrollable, Accessible
if(parent == null) if(parent == null)
return null; return null;
Vector descendants = new Vector(); Vector<TreePath> descendants = new Vector<TreePath>();
Enumeration nodes = expandedState.keys(); Enumeration<TreePath> nodes = expandedState.keys();
TreePath path;
while(nodes.hasMoreElements()) { while(nodes.hasMoreElements()) {
path = (TreePath)nodes.nextElement(); TreePath path = nodes.nextElement();
if(parent.isDescendant(path)) if(parent.isDescendant(path))
descendants.addElement(path); descendants.addElement(path);
} }
...@@ -3664,8 +3660,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -3664,8 +3660,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
{ {
if(toRemove != null) { if(toRemove != null) {
while(toRemove.hasMoreElements()) { while(toRemove.hasMoreElements()) {
Enumeration descendants = getDescendantToggledPaths Enumeration descendants = getDescendantToggledPaths
((TreePath)toRemove.nextElement()); (toRemove.nextElement());
if(descendants != null) { if(descendants != null) {
while(descendants.hasMoreElements()) { while(descendants.hasMoreElements()) {
...@@ -4250,7 +4246,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4250,7 +4246,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
private AccessibleContext getCurrentAccessibleContext() { private AccessibleContext getCurrentAccessibleContext() {
Component c = getCurrentComponent(); Component c = getCurrentComponent();
if (c instanceof Accessible) { if (c instanceof Accessible) {
return (((Accessible) c).getAccessibleContext()); return c.getAccessibleContext();
} else { } else {
return null; return null;
} }
...@@ -4573,7 +4569,7 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -4573,7 +4569,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
private AccessibleContext getCurrentAccessibleContext() { private AccessibleContext getCurrentAccessibleContext() {
Component c = getCurrentComponent(); Component c = getCurrentComponent();
if (c instanceof Accessible) { if (c instanceof Accessible) {
return (((Accessible) c).getAccessibleContext()); return c.getAccessibleContext();
} else { } else {
return null; return null;
} }
...@@ -5117,12 +5113,8 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -5117,12 +5113,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
public boolean isVisible() { public boolean isVisible() {
Rectangle pathBounds = tree.getPathBounds(path); Rectangle pathBounds = tree.getPathBounds(path);
Rectangle parentBounds = tree.getVisibleRect(); Rectangle parentBounds = tree.getVisibleRect();
if (pathBounds != null && parentBounds != null && return pathBounds != null && parentBounds != null &&
parentBounds.intersects(pathBounds)) { parentBounds.intersects(pathBounds);
return true;
} else {
return false;
}
} }
public void setVisible(boolean b) { public void setVisible(boolean b) {
......
...@@ -389,7 +389,7 @@ public class JViewport extends JComponent implements Accessible ...@@ -389,7 +389,7 @@ public class JViewport extends JComponent implements Accessible
// could be bigger than invalid size. // could be bigger than invalid size.
validateView(); validateView();
} }
int dx = 0, dy = 0; int dx, dy;
dx = positionAdjustment(getWidth(), contentRect.width, contentRect.x); dx = positionAdjustment(getWidth(), contentRect.width, contentRect.x);
dy = positionAdjustment(getHeight(), contentRect.height, contentRect.y); dy = positionAdjustment(getHeight(), contentRect.height, contentRect.y);
...@@ -682,10 +682,7 @@ public class JViewport extends JComponent implements Accessible ...@@ -682,10 +682,7 @@ public class JViewport extends JComponent implements Accessible
* @see JComponent#isPaintingOrigin() * @see JComponent#isPaintingOrigin()
*/ */
boolean isPaintingOrigin() { boolean isPaintingOrigin() {
if (scrollMode == BACKINGSTORE_SCROLL_MODE) { return scrollMode == BACKINGSTORE_SCROLL_MODE;
return true;
}
return false;
} }
...@@ -903,11 +900,7 @@ public class JViewport extends JComponent implements Accessible ...@@ -903,11 +900,7 @@ public class JViewport extends JComponent implements Accessible
*/ */
public void setScrollMode(int mode) { public void setScrollMode(int mode) {
scrollMode = mode; scrollMode = mode;
if (mode == BACKINGSTORE_SCROLL_MODE) { backingStore = mode == BACKINGSTORE_SCROLL_MODE;
backingStore = true;
} else {
backingStore = false;
}
} }
/** /**
...@@ -958,10 +951,10 @@ public class JViewport extends JComponent implements Accessible ...@@ -958,10 +951,10 @@ public class JViewport extends JComponent implements Accessible
} }
} }
private final boolean isBlitting() { private boolean isBlitting() {
Component view = getView(); Component view = getView();
return (scrollMode == BLIT_SCROLL_MODE) && return (scrollMode == BLIT_SCROLL_MODE) &&
(view instanceof JComponent) && ((JComponent)view).isOpaque(); (view instanceof JComponent) && view.isOpaque();
} }
...@@ -1380,8 +1373,7 @@ public class JViewport extends JComponent implements Accessible ...@@ -1380,8 +1373,7 @@ public class JViewport extends JComponent implements Accessible
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
/** /**
......
...@@ -185,7 +185,7 @@ public class JWindow extends Window implements Accessible, ...@@ -185,7 +185,7 @@ public class JWindow extends Window implements Accessible,
super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner); super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner);
if (owner == null) { if (owner == null) {
WindowListener ownerShutdownListener = WindowListener ownerShutdownListener =
(WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); SwingUtilities.getSharedOwnerFrameShutdownListener();
addWindowListener(ownerShutdownListener); addWindowListener(ownerShutdownListener);
} }
windowInit(); windowInit();
...@@ -212,7 +212,7 @@ public class JWindow extends Window implements Accessible, ...@@ -212,7 +212,7 @@ public class JWindow extends Window implements Accessible,
owner); owner);
if (owner == null) { if (owner == null) {
WindowListener ownerShutdownListener = WindowListener ownerShutdownListener =
(WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); SwingUtilities.getSharedOwnerFrameShutdownListener();
addWindowListener(ownerShutdownListener); addWindowListener(ownerShutdownListener);
} }
windowInit(); windowInit();
...@@ -250,7 +250,7 @@ public class JWindow extends Window implements Accessible, ...@@ -250,7 +250,7 @@ public class JWindow extends Window implements Accessible,
owner, gc); owner, gc);
if (owner == null) { if (owner == null) {
WindowListener ownerShutdownListener = WindowListener ownerShutdownListener =
(WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); SwingUtilities.getSharedOwnerFrameShutdownListener();
addWindowListener(ownerShutdownListener); addWindowListener(ownerShutdownListener);
} }
windowInit(); windowInit();
......
...@@ -68,13 +68,13 @@ class KeyboardManager { ...@@ -68,13 +68,13 @@ class KeyboardManager {
/** /**
* maps top-level containers to a sub-hashtable full of keystrokes * maps top-level containers to a sub-hashtable full of keystrokes
*/ */
Hashtable containerMap = new Hashtable(); Hashtable<Container, Hashtable> containerMap = new Hashtable<Container, Hashtable>();
/** /**
* Maps component/keystroke pairs to a topLevel container * Maps component/keystroke pairs to a topLevel container
* This is mainly used for fast unregister operations * This is mainly used for fast unregister operations
*/ */
Hashtable componentKeyStrokeMap = new Hashtable(); Hashtable<ComponentKeyStrokePair, Container> componentKeyStrokeMap = new Hashtable<ComponentKeyStrokePair, Container>();
public static KeyboardManager getCurrentManager() { public static KeyboardManager getCurrentManager() {
return currentManager; return currentManager;
...@@ -95,7 +95,7 @@ class KeyboardManager { ...@@ -95,7 +95,7 @@ class KeyboardManager {
if (topContainer == null) { if (topContainer == null) {
return; return;
} }
Hashtable keyMap = (Hashtable)containerMap.get(topContainer); Hashtable keyMap = containerMap.get(topContainer);
if (keyMap == null) { // lazy evaluate one if (keyMap == null) { // lazy evaluate one
keyMap = registerNewTopContainer(topContainer); keyMap = registerNewTopContainer(topContainer);
...@@ -114,8 +114,8 @@ class KeyboardManager { ...@@ -114,8 +114,8 @@ class KeyboardManager {
// Then add the old compoennt and the new compoent to the vector // Then add the old compoennt and the new compoent to the vector
// then insert the vector in the table // then insert the vector in the table
if (tmp != c) { // this means this is already registered for this component, no need to dup if (tmp != c) { // this means this is already registered for this component, no need to dup
Vector v = new Vector(); Vector<JComponent> v = new Vector<JComponent>();
v.addElement(tmp); v.addElement((JComponent) tmp);
v.addElement(c); v.addElement(c);
keyMap.put(k, v); keyMap.put(k, v);
} }
...@@ -154,13 +154,13 @@ class KeyboardManager { ...@@ -154,13 +154,13 @@ class KeyboardManager {
ComponentKeyStrokePair ckp = new ComponentKeyStrokePair(c,ks); ComponentKeyStrokePair ckp = new ComponentKeyStrokePair(c,ks);
Object topContainer = componentKeyStrokeMap.get(ckp); Container topContainer = componentKeyStrokeMap.get(ckp);
if (topContainer == null) { // never heard of this pairing, so bail if (topContainer == null) { // never heard of this pairing, so bail
return; return;
} }
Hashtable keyMap = (Hashtable)containerMap.get(topContainer); Hashtable keyMap = containerMap.get(topContainer);
if (keyMap == null) { // this should never happen, but I'm being safe if (keyMap == null) { // this should never happen, but I'm being safe
Thread.dumpStack(); Thread.dumpStack();
return; return;
...@@ -221,7 +221,7 @@ class KeyboardManager { ...@@ -221,7 +221,7 @@ class KeyboardManager {
ks=KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), !pressed); ks=KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), !pressed);
} }
Hashtable keyMap = (Hashtable)containerMap.get(topAncestor); Hashtable keyMap = containerMap.get(topAncestor);
if (keyMap != null) { // this container isn't registered, so bail if (keyMap != null) { // this container isn't registered, so bail
Object tmp = keyMap.get(ks); Object tmp = keyMap.get(ks);
...@@ -293,7 +293,7 @@ class KeyboardManager { ...@@ -293,7 +293,7 @@ class KeyboardManager {
if (top == null) { if (top == null) {
return; return;
} }
Hashtable keyMap = (Hashtable)containerMap.get(top); Hashtable keyMap = containerMap.get(top);
if (keyMap == null) { // lazy evaluate one if (keyMap == null) { // lazy evaluate one
keyMap = registerNewTopContainer(top); keyMap = registerNewTopContainer(top);
...@@ -314,11 +314,11 @@ class KeyboardManager { ...@@ -314,11 +314,11 @@ class KeyboardManager {
public void unregisterMenuBar(JMenuBar mb) { public void unregisterMenuBar(JMenuBar mb) {
Object topContainer = getTopAncestor(mb); Container topContainer = getTopAncestor(mb);
if (topContainer == null) { if (topContainer == null) {
return; return;
} }
Hashtable keyMap = (Hashtable)containerMap.get(topContainer); Hashtable keyMap = containerMap.get(topContainer);
if (keyMap!=null) { if (keyMap!=null) {
Vector v = (Vector)keyMap.get(JMenuBar.class); Vector v = (Vector)keyMap.get(JMenuBar.class);
if (v != null) { if (v != null) {
......
...@@ -39,7 +39,7 @@ import java.awt.Window; ...@@ -39,7 +39,7 @@ import java.awt.Window;
* *
* @author David Mendenhall * @author David Mendenhall
*/ */
final class LayoutComparator implements Comparator, java.io.Serializable { final class LayoutComparator implements Comparator<Component>, java.io.Serializable {
private static final int ROW_TOLERANCE = 10; private static final int ROW_TOLERANCE = 10;
...@@ -51,10 +51,7 @@ final class LayoutComparator implements Comparator, java.io.Serializable { ...@@ -51,10 +51,7 @@ final class LayoutComparator implements Comparator, java.io.Serializable {
leftToRight = orientation.isLeftToRight(); leftToRight = orientation.isLeftToRight();
} }
public int compare(Object o1, Object o2) { public int compare(Component a, Component b) {
Component a = (Component)o1;
Component b = (Component)o2;
if (a == b) { if (a == b) {
return 0; return 0;
} }
...@@ -65,9 +62,9 @@ final class LayoutComparator implements Comparator, java.io.Serializable { ...@@ -65,9 +62,9 @@ final class LayoutComparator implements Comparator, java.io.Serializable {
// each Component and then search from the Window down until the // each Component and then search from the Window down until the
// hierarchy branches. // hierarchy branches.
if (a.getParent() != b.getParent()) { if (a.getParent() != b.getParent()) {
LinkedList aAncestory, bAncestory; LinkedList<Component> aAncestory = new LinkedList<Component>();
for(aAncestory = new LinkedList(); a != null; a = a.getParent()) { for(; a != null; a = a.getParent()) {
aAncestory.add(a); aAncestory.add(a);
if (a instanceof Window) { if (a instanceof Window) {
break; break;
...@@ -78,7 +75,9 @@ final class LayoutComparator implements Comparator, java.io.Serializable { ...@@ -78,7 +75,9 @@ final class LayoutComparator implements Comparator, java.io.Serializable {
throw new ClassCastException(); throw new ClassCastException();
} }
for(bAncestory = new LinkedList(); b != null; b = b.getParent()) { LinkedList<Component> bAncestory = new LinkedList<Component>();
for(; b != null; b = b.getParent()) {
bAncestory.add(b); bAncestory.add(b);
if (b instanceof Window) { if (b instanceof Window) {
break; break;
...@@ -89,18 +88,18 @@ final class LayoutComparator implements Comparator, java.io.Serializable { ...@@ -89,18 +88,18 @@ final class LayoutComparator implements Comparator, java.io.Serializable {
throw new ClassCastException(); throw new ClassCastException();
} }
for (ListIterator for (ListIterator<Component>
aIter = aAncestory.listIterator(aAncestory.size()), aIter = aAncestory.listIterator(aAncestory.size()),
bIter = bAncestory.listIterator(bAncestory.size()); ;) { bIter = bAncestory.listIterator(bAncestory.size()); ;) {
if (aIter.hasPrevious()) { if (aIter.hasPrevious()) {
a = (Component)aIter.previous(); a = aIter.previous();
} else { } else {
// a is an ancestor of b // a is an ancestor of b
return -1; return -1;
} }
if (bIter.hasPrevious()) { if (bIter.hasPrevious()) {
b = (Component)bIter.previous(); b = bIter.previous();
} else { } else {
// b is an ancestor of a // b is an ancestor of a
return 1; return 1;
......
...@@ -65,7 +65,7 @@ public class LayoutFocusTraversalPolicy extends SortingFocusTraversalPolicy ...@@ -65,7 +65,7 @@ public class LayoutFocusTraversalPolicy extends SortingFocusTraversalPolicy
* Constructs a LayoutFocusTraversalPolicy with the passed in * Constructs a LayoutFocusTraversalPolicy with the passed in
* <code>Comparator</code>. * <code>Comparator</code>.
*/ */
LayoutFocusTraversalPolicy(Comparator c) { LayoutFocusTraversalPolicy(Comparator<? super Component> c) {
super(c); super(c);
} }
......
...@@ -48,8 +48,8 @@ final class LegacyGlueFocusTraversalPolicy extends FocusTraversalPolicy ...@@ -48,8 +48,8 @@ final class LegacyGlueFocusTraversalPolicy extends FocusTraversalPolicy
private transient FocusTraversalPolicy delegatePolicy; private transient FocusTraversalPolicy delegatePolicy;
private transient DefaultFocusManager delegateManager; private transient DefaultFocusManager delegateManager;
private HashMap forwardMap = new HashMap(), private HashMap<Component, Component> forwardMap = new HashMap<Component, Component>(),
backwardMap = new HashMap(); backwardMap = new HashMap<Component, Component>();
LegacyGlueFocusTraversalPolicy(FocusTraversalPolicy delegatePolicy) { LegacyGlueFocusTraversalPolicy(FocusTraversalPolicy delegatePolicy) {
this.delegatePolicy = delegatePolicy; this.delegatePolicy = delegatePolicy;
...@@ -70,11 +70,11 @@ final class LegacyGlueFocusTraversalPolicy extends FocusTraversalPolicy ...@@ -70,11 +70,11 @@ final class LegacyGlueFocusTraversalPolicy extends FocusTraversalPolicy
public Component getComponentAfter(Container focusCycleRoot, public Component getComponentAfter(Container focusCycleRoot,
Component aComponent) { Component aComponent) {
Component hardCoded = aComponent, prevHardCoded; Component hardCoded = aComponent, prevHardCoded;
HashSet sanity = new HashSet(); HashSet<Component> sanity = new HashSet<Component>();
do { do {
prevHardCoded = hardCoded; prevHardCoded = hardCoded;
hardCoded = (Component)forwardMap.get(hardCoded); hardCoded = forwardMap.get(hardCoded);
if (hardCoded == null) { if (hardCoded == null) {
if (delegatePolicy != null && if (delegatePolicy != null &&
prevHardCoded.isFocusCycleRoot(focusCycleRoot)) { prevHardCoded.isFocusCycleRoot(focusCycleRoot)) {
...@@ -99,11 +99,11 @@ final class LegacyGlueFocusTraversalPolicy extends FocusTraversalPolicy ...@@ -99,11 +99,11 @@ final class LegacyGlueFocusTraversalPolicy extends FocusTraversalPolicy
public Component getComponentBefore(Container focusCycleRoot, public Component getComponentBefore(Container focusCycleRoot,
Component aComponent) { Component aComponent) {
Component hardCoded = aComponent, prevHardCoded; Component hardCoded = aComponent, prevHardCoded;
HashSet sanity = new HashSet(); HashSet<Component> sanity = new HashSet<Component>();
do { do {
prevHardCoded = hardCoded; prevHardCoded = hardCoded;
hardCoded = (Component)backwardMap.get(hardCoded); hardCoded = backwardMap.get(hardCoded);
if (hardCoded == null) { if (hardCoded == null) {
if (delegatePolicy != null && if (delegatePolicy != null &&
prevHardCoded.isFocusCycleRoot(focusCycleRoot)) { prevHardCoded.isFocusCycleRoot(focusCycleRoot)) {
......
...@@ -37,7 +37,7 @@ import sun.awt.AppContext; ...@@ -37,7 +37,7 @@ import sun.awt.AppContext;
* @author Arnaud Weber * @author Arnaud Weber
*/ */
public class MenuSelectionManager { public class MenuSelectionManager {
private Vector selection = new Vector(); private Vector<MenuElement> selection = new Vector<MenuElement>();
/* diagnostic aids -- should be false for production builds. */ /* diagnostic aids -- should be false for production builds. */
private static final boolean TRACE = false; // trace creates and disposes private static final boolean TRACE = false; // trace creates and disposes
...@@ -100,14 +100,14 @@ public class MenuSelectionManager { ...@@ -100,14 +100,14 @@ public class MenuSelectionManager {
} }
for(i=0,c=path.length;i<c;i++) { for(i=0,c=path.length;i<c;i++) {
if(i < currentSelectionCount && (MenuElement)selection.elementAt(i) == path[i]) if (i < currentSelectionCount && selection.elementAt(i) == path[i])
firstDifference++; firstDifference++;
else else
break; break;
} }
for(i=currentSelectionCount - 1 ; i >= firstDifference ; i--) { for(i=currentSelectionCount - 1 ; i >= firstDifference ; i--) {
MenuElement me = (MenuElement)selection.elementAt(i); MenuElement me = selection.elementAt(i);
selection.removeElementAt(i); selection.removeElementAt(i);
me.menuSelectionChanged(false); me.menuSelectionChanged(false);
} }
...@@ -131,7 +131,7 @@ public class MenuSelectionManager { ...@@ -131,7 +131,7 @@ public class MenuSelectionManager {
MenuElement res[] = new MenuElement[selection.size()]; MenuElement res[] = new MenuElement[selection.size()];
int i,c; int i,c;
for(i=0,c=selection.size();i<c;i++) for(i=0,c=selection.size();i<c;i++)
res[i] = (MenuElement) selection.elementAt(i); res[i] = selection.elementAt(i);
return res; return res;
} }
...@@ -172,8 +172,7 @@ public class MenuSelectionManager { ...@@ -172,8 +172,7 @@ public class MenuSelectionManager {
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
/** /**
...@@ -258,8 +257,8 @@ public class MenuSelectionManager { ...@@ -258,8 +257,8 @@ public class MenuSelectionManager {
if(!mc.isShowing()) if(!mc.isShowing())
continue; continue;
if(mc instanceof JComponent) { if(mc instanceof JComponent) {
cWidth = ((JComponent)mc).getWidth(); cWidth = mc.getWidth();
cHeight = ((JComponent)mc).getHeight(); cHeight = mc.getHeight();
} else { } else {
r2 = mc.getBounds(); r2 = mc.getBounds();
cWidth = r2.width; cWidth = r2.width;
...@@ -338,7 +337,7 @@ public class MenuSelectionManager { ...@@ -338,7 +337,7 @@ public class MenuSelectionManager {
for(i=0,j=path.length; i<j ;i++){ for(i=0,j=path.length; i<j ;i++){
for (int k=0; k<=i; k++) for (int k=0; k<=i; k++)
System.out.print(" "); System.out.print(" ");
MenuElement me = (MenuElement) path[i]; MenuElement me = path[i];
if(me instanceof JMenuItem) { if(me instanceof JMenuItem) {
System.out.println(((JMenuItem)me).getText() + ", "); System.out.println(((JMenuItem)me).getText() + ", ");
} else if (me instanceof JMenuBar) { } else if (me instanceof JMenuBar) {
...@@ -399,8 +398,8 @@ public class MenuSelectionManager { ...@@ -399,8 +398,8 @@ public class MenuSelectionManager {
if(!mc.isShowing()) if(!mc.isShowing())
continue; continue;
if(mc instanceof JComponent) { if(mc instanceof JComponent) {
cWidth = ((JComponent)mc).getWidth(); cWidth = mc.getWidth();
cHeight = ((JComponent)mc).getHeight(); cHeight = mc.getHeight();
} else { } else {
r2 = mc.getBounds(); r2 = mc.getBounds();
cWidth = r2.width; cWidth = r2.width;
...@@ -429,7 +428,7 @@ public class MenuSelectionManager { ...@@ -429,7 +428,7 @@ public class MenuSelectionManager {
*/ */
public void processKeyEvent(KeyEvent e) { public void processKeyEvent(KeyEvent e) {
MenuElement[] sel2 = new MenuElement[0]; MenuElement[] sel2 = new MenuElement[0];
sel2 = (MenuElement[])selection.toArray(sel2); sel2 = selection.toArray(sel2);
int selSize = sel2.length; int selSize = sel2.length;
MenuElement[] path; MenuElement[] path;
...@@ -474,7 +473,7 @@ public class MenuSelectionManager { ...@@ -474,7 +473,7 @@ public class MenuSelectionManager {
*/ */
public boolean isComponentPartOfCurrentMenu(Component c) { public boolean isComponentPartOfCurrentMenu(Component c) {
if(selection.size() > 0) { if(selection.size() > 0) {
MenuElement me = (MenuElement)selection.elementAt(0); MenuElement me = selection.elementAt(0);
return isComponentPartOfCurrentMenu(me,c); return isComponentPartOfCurrentMenu(me,c);
} else } else
return false; return false;
......
...@@ -56,8 +56,7 @@ class MultiUIDefaults extends UIDefaults ...@@ -56,8 +56,7 @@ class MultiUIDefaults extends UIDefaults
return value; return value;
} }
for(int i = 0; i < tables.length; i++) { for (UIDefaults table : tables) {
UIDefaults table = tables[i];
value = (table != null) ? table.get(key) : null; value = (table != null) ? table.get(key) : null;
if (value != null) { if (value != null) {
return value; return value;
...@@ -75,8 +74,7 @@ class MultiUIDefaults extends UIDefaults ...@@ -75,8 +74,7 @@ class MultiUIDefaults extends UIDefaults
return value; return value;
} }
for(int i = 0; i < tables.length; i++) { for (UIDefaults table : tables) {
UIDefaults table = tables[i];
value = (table != null) ? table.get(key,l) : null; value = (table != null) ? table.get(key,l) : null;
if (value != null) { if (value != null) {
return value; return value;
...@@ -89,8 +87,7 @@ class MultiUIDefaults extends UIDefaults ...@@ -89,8 +87,7 @@ class MultiUIDefaults extends UIDefaults
public int size() { public int size() {
int n = super.size(); int n = super.size();
for(int i = 0; i < tables.length; i++) { for (UIDefaults table : tables) {
UIDefaults table = tables[i];
n += (table != null) ? table.size() : 0; n += (table != null) ? table.size() : 0;
} }
return n; return n;
...@@ -102,7 +99,7 @@ class MultiUIDefaults extends UIDefaults ...@@ -102,7 +99,7 @@ class MultiUIDefaults extends UIDefaults
} }
public Enumeration keys() public Enumeration<Object> keys()
{ {
Enumeration[] enums = new Enumeration[1 + tables.length]; Enumeration[] enums = new Enumeration[1 + tables.length];
enums[0] = super.keys(); enums[0] = super.keys();
...@@ -116,7 +113,7 @@ class MultiUIDefaults extends UIDefaults ...@@ -116,7 +113,7 @@ class MultiUIDefaults extends UIDefaults
} }
public Enumeration elements() public Enumeration<Object> elements()
{ {
Enumeration[] enums = new Enumeration[1 + tables.length]; Enumeration[] enums = new Enumeration[1 + tables.length];
enums[0] = super.elements(); enums[0] = super.elements();
...@@ -137,7 +134,7 @@ class MultiUIDefaults extends UIDefaults ...@@ -137,7 +134,7 @@ class MultiUIDefaults extends UIDefaults
} }
} }
private static class MultiUIDefaultsEnumerator implements Enumeration private static class MultiUIDefaultsEnumerator implements Enumeration<Object>
{ {
Enumeration[] enums; Enumeration[] enums;
int n = 0; int n = 0;
...@@ -175,8 +172,7 @@ class MultiUIDefaults extends UIDefaults ...@@ -175,8 +172,7 @@ class MultiUIDefaults extends UIDefaults
return value; return value;
} }
for(int i = 0; i < tables.length; i++) { for (UIDefaults table : tables) {
UIDefaults table = tables[i];
value = (table != null) ? table.remove(key) : null; value = (table != null) ? table.remove(key) : null;
if (value != null) { if (value != null) {
return value; return value;
...@@ -189,8 +185,7 @@ class MultiUIDefaults extends UIDefaults ...@@ -189,8 +185,7 @@ class MultiUIDefaults extends UIDefaults
public void clear() { public void clear() {
super.clear(); super.clear();
for(int i = 0; i < tables.length; i++) { for (UIDefaults table : tables) {
UIDefaults table = tables[i];
if (table != null) { if (table != null) {
table.clear(); table.clear();
} }
......
...@@ -313,9 +313,9 @@ public class PopupFactory { ...@@ -313,9 +313,9 @@ public class PopupFactory {
if(contents instanceof JPopupMenu) { if(contents instanceof JPopupMenu) {
JPopupMenu jpm = (JPopupMenu) contents; JPopupMenu jpm = (JPopupMenu) contents;
Component popComps[] = jpm.getComponents(); Component popComps[] = jpm.getComponents();
for(int i=0;i<popComps.length;i++) { for (Component popComp : popComps) {
if(!(popComps[i] instanceof MenuElement) && if (!(popComp instanceof MenuElement) &&
!(popComps[i] instanceof JSeparator)) { !(popComp instanceof JSeparator)) {
focusPopup = true; focusPopup = true;
break; break;
} }
...@@ -357,17 +357,16 @@ public class PopupFactory { ...@@ -357,17 +357,16 @@ public class PopupFactory {
*/ */
private static HeavyWeightPopup getRecycledHeavyWeightPopup(Window w) { private static HeavyWeightPopup getRecycledHeavyWeightPopup(Window w) {
synchronized (HeavyWeightPopup.class) { synchronized (HeavyWeightPopup.class) {
List cache; List<HeavyWeightPopup> cache;
Map heavyPopupCache = getHeavyWeightPopupCache(); Map<Window, List<HeavyWeightPopup>> heavyPopupCache = getHeavyWeightPopupCache();
if (heavyPopupCache.containsKey(w)) { if (heavyPopupCache.containsKey(w)) {
cache = (List)heavyPopupCache.get(w); cache = heavyPopupCache.get(w);
} else { } else {
return null; return null;
} }
int c; if (cache.size() > 0) {
if ((c = cache.size()) > 0) { HeavyWeightPopup r = cache.get(0);
HeavyWeightPopup r = (HeavyWeightPopup)cache.get(0);
cache.remove(0); cache.remove(0);
return r; return r;
} }
...@@ -380,13 +379,13 @@ public class PopupFactory { ...@@ -380,13 +379,13 @@ public class PopupFactory {
* <code>Window</code> to a <code>List</code> of * <code>Window</code> to a <code>List</code> of
* <code>HeavyWeightPopup</code>s. * <code>HeavyWeightPopup</code>s.
*/ */
private static Map getHeavyWeightPopupCache() { private static Map<Window, List<HeavyWeightPopup>> getHeavyWeightPopupCache() {
synchronized (HeavyWeightPopup.class) { synchronized (HeavyWeightPopup.class) {
Map cache = (Map)SwingUtilities.appContextGet( Map<Window, List<HeavyWeightPopup>> cache = (Map<Window, List<HeavyWeightPopup>>)SwingUtilities.appContextGet(
heavyWeightPopupCacheKey); heavyWeightPopupCacheKey);
if (cache == null) { if (cache == null) {
cache = new HashMap(2); cache = new HashMap<Window, List<HeavyWeightPopup>>(2);
SwingUtilities.appContextPut(heavyWeightPopupCacheKey, SwingUtilities.appContextPut(heavyWeightPopupCacheKey,
cache); cache);
} }
...@@ -399,13 +398,13 @@ public class PopupFactory { ...@@ -399,13 +398,13 @@ public class PopupFactory {
*/ */
private static void recycleHeavyWeightPopup(HeavyWeightPopup popup) { private static void recycleHeavyWeightPopup(HeavyWeightPopup popup) {
synchronized (HeavyWeightPopup.class) { synchronized (HeavyWeightPopup.class) {
List cache; List<HeavyWeightPopup> cache;
Object window = SwingUtilities.getWindowAncestor( Window window = SwingUtilities.getWindowAncestor(
popup.getComponent()); popup.getComponent());
Map heavyPopupCache = getHeavyWeightPopupCache(); Map<Window, List<HeavyWeightPopup>> heavyPopupCache = getHeavyWeightPopupCache();
if (window instanceof Popup.DefaultFrame || if (window instanceof Popup.DefaultFrame ||
!((Window)window).isVisible()) { !window.isVisible()) {
// If the Window isn't visible, we don't cache it as we // If the Window isn't visible, we don't cache it as we
// likely won't ever get a windowClosed event to clean up. // likely won't ever get a windowClosed event to clean up.
// We also don't cache DefaultFrames as this indicates // We also don't cache DefaultFrames as this indicates
...@@ -414,28 +413,27 @@ public class PopupFactory { ...@@ -414,28 +413,27 @@ public class PopupFactory {
popup._dispose(); popup._dispose();
return; return;
} else if (heavyPopupCache.containsKey(window)) { } else if (heavyPopupCache.containsKey(window)) {
cache = (List)heavyPopupCache.get(window); cache = heavyPopupCache.get(window);
} else { } else {
cache = new ArrayList(); cache = new ArrayList<HeavyWeightPopup>();
heavyPopupCache.put(window, cache); heavyPopupCache.put(window, cache);
// Clean up if the Window is closed // Clean up if the Window is closed
final Window w = (Window)window; final Window w = window;
w.addWindowListener(new WindowAdapter() { w.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) { public void windowClosed(WindowEvent e) {
List popups; List<HeavyWeightPopup> popups;
synchronized(HeavyWeightPopup.class) { synchronized(HeavyWeightPopup.class) {
Map heavyPopupCache2 = Map<Window, List<HeavyWeightPopup>> heavyPopupCache2 =
getHeavyWeightPopupCache(); getHeavyWeightPopupCache();
popups = (List)heavyPopupCache2.remove(w); popups = heavyPopupCache2.remove(w);
} }
if (popups != null) { if (popups != null) {
for (int counter = popups.size() - 1; for (int counter = popups.size() - 1;
counter >= 0; counter--) { counter >= 0; counter--) {
((HeavyWeightPopup)popups.get(counter)). popups.get(counter)._dispose();
_dispose();
} }
} }
} }
...@@ -534,10 +532,9 @@ public class PopupFactory { ...@@ -534,10 +532,9 @@ public class PopupFactory {
Window[] ownedWindows = w.getOwnedWindows(); Window[] ownedWindows = w.getOwnedWindows();
if(ownedWindows != null) { if(ownedWindows != null) {
Rectangle bnd = component.getBounds(); Rectangle bnd = component.getBounds();
for(int i=0; i<ownedWindows.length;i++) { for (Window window : ownedWindows) {
Window owned = ownedWindows[i]; if (window.isVisible() &&
if (owned.isVisible() && bnd.intersects(window.getBounds())) {
bnd.intersects(owned.getBounds())) {
return true; return true;
} }
...@@ -667,11 +664,11 @@ public class PopupFactory { ...@@ -667,11 +664,11 @@ public class PopupFactory {
/** /**
* Returns the cache to use for heavy weight popups. * Returns the cache to use for heavy weight popups.
*/ */
private static List getLightWeightPopupCache() { private static List<LightWeightPopup> getLightWeightPopupCache() {
List cache = (List)SwingUtilities.appContextGet( List<LightWeightPopup> cache = (List<LightWeightPopup>)SwingUtilities.appContextGet(
lightWeightPopupCacheKey); lightWeightPopupCacheKey);
if (cache == null) { if (cache == null) {
cache = new ArrayList(); cache = new ArrayList<LightWeightPopup>();
SwingUtilities.appContextPut(lightWeightPopupCacheKey, cache); SwingUtilities.appContextPut(lightWeightPopupCacheKey, cache);
} }
return cache; return cache;
...@@ -682,7 +679,7 @@ public class PopupFactory { ...@@ -682,7 +679,7 @@ public class PopupFactory {
*/ */
private static void recycleLightWeightPopup(LightWeightPopup popup) { private static void recycleLightWeightPopup(LightWeightPopup popup) {
synchronized (LightWeightPopup.class) { synchronized (LightWeightPopup.class) {
List lightPopupCache = getLightWeightPopupCache(); List<LightWeightPopup> lightPopupCache = getLightWeightPopupCache();
if (lightPopupCache.size() < MAX_CACHE_SIZE) { if (lightPopupCache.size() < MAX_CACHE_SIZE) {
lightPopupCache.add(popup); lightPopupCache.add(popup);
} }
...@@ -695,11 +692,9 @@ public class PopupFactory { ...@@ -695,11 +692,9 @@ public class PopupFactory {
*/ */
private static LightWeightPopup getRecycledLightWeightPopup() { private static LightWeightPopup getRecycledLightWeightPopup() {
synchronized (LightWeightPopup.class) { synchronized (LightWeightPopup.class) {
List lightPopupCache = getLightWeightPopupCache(); List<LightWeightPopup> lightPopupCache = getLightWeightPopupCache();
int c; if (lightPopupCache.size() > 0) {
if((c = lightPopupCache.size()) > 0) { LightWeightPopup r = lightPopupCache.get(0);
LightWeightPopup r = (LightWeightPopup)lightPopupCache.
get(0);
lightPopupCache.remove(0); lightPopupCache.remove(0);
return r; return r;
} }
...@@ -755,8 +750,7 @@ public class PopupFactory { ...@@ -755,8 +750,7 @@ public class PopupFactory {
component.setLocation(p.x, p.y); component.setLocation(p.x, p.y);
if (parent instanceof JLayeredPane) { if (parent instanceof JLayeredPane) {
((JLayeredPane)parent).add(component, parent.add(component, JLayeredPane.POPUP_LAYER, 0);
JLayeredPane.POPUP_LAYER, 0);
} else { } else {
parent.add(component); parent.add(component);
} }
...@@ -826,12 +820,12 @@ public class PopupFactory { ...@@ -826,12 +820,12 @@ public class PopupFactory {
/** /**
* Returns the cache to use for medium weight popups. * Returns the cache to use for medium weight popups.
*/ */
private static List getMediumWeightPopupCache() { private static List<MediumWeightPopup> getMediumWeightPopupCache() {
List cache = (List)SwingUtilities.appContextGet( List<MediumWeightPopup> cache = (List<MediumWeightPopup>)SwingUtilities.appContextGet(
mediumWeightPopupCacheKey); mediumWeightPopupCacheKey);
if (cache == null) { if (cache == null) {
cache = new ArrayList(); cache = new ArrayList<MediumWeightPopup>();
SwingUtilities.appContextPut(mediumWeightPopupCacheKey, cache); SwingUtilities.appContextPut(mediumWeightPopupCacheKey, cache);
} }
return cache; return cache;
...@@ -842,7 +836,7 @@ public class PopupFactory { ...@@ -842,7 +836,7 @@ public class PopupFactory {
*/ */
private static void recycleMediumWeightPopup(MediumWeightPopup popup) { private static void recycleMediumWeightPopup(MediumWeightPopup popup) {
synchronized (MediumWeightPopup.class) { synchronized (MediumWeightPopup.class) {
List mediumPopupCache = getMediumWeightPopupCache(); List<MediumWeightPopup> mediumPopupCache = getMediumWeightPopupCache();
if (mediumPopupCache.size() < MAX_CACHE_SIZE) { if (mediumPopupCache.size() < MAX_CACHE_SIZE) {
mediumPopupCache.add(popup); mediumPopupCache.add(popup);
} }
...@@ -855,12 +849,9 @@ public class PopupFactory { ...@@ -855,12 +849,9 @@ public class PopupFactory {
*/ */
private static MediumWeightPopup getRecycledMediumWeightPopup() { private static MediumWeightPopup getRecycledMediumWeightPopup() {
synchronized (MediumWeightPopup.class) { synchronized (MediumWeightPopup.class) {
java.util.List mediumPopupCache = List<MediumWeightPopup> mediumPopupCache = getMediumWeightPopupCache();
getMediumWeightPopupCache(); if (mediumPopupCache.size() > 0) {
int c; MediumWeightPopup r = mediumPopupCache.get(0);
if ((c=mediumPopupCache.size()) > 0) {
MediumWeightPopup r = (MediumWeightPopup)mediumPopupCache.
get(0);
mediumPopupCache.remove(0); mediumPopupCache.remove(0);
return r; return r;
} }
...@@ -904,7 +895,7 @@ public class PopupFactory { ...@@ -904,7 +895,7 @@ public class PopupFactory {
x, y); x, y);
component.setVisible(false); component.setVisible(false);
component.setLocation(p.x, p.y); component.setLocation(p.x, p.y);
((JLayeredPane)parent).add(component, JLayeredPane.POPUP_LAYER, parent.add(component, JLayeredPane.POPUP_LAYER,
0); 0);
} else { } else {
Point p = SwingUtilities.convertScreenLocationToParent(parent, Point p = SwingUtilities.convertScreenLocationToParent(parent,
......
...@@ -589,7 +589,7 @@ public class RepaintManager ...@@ -589,7 +589,7 @@ public class RepaintManager
*/ */
private synchronized boolean extendDirtyRegion( private synchronized boolean extendDirtyRegion(
Component c, int x, int y, int w, int h) { Component c, int x, int y, int w, int h) {
Rectangle r = (Rectangle)dirtyComponents.get(c); Rectangle r = dirtyComponents.get(c);
if (r != null) { if (r != null) {
// A non-null r implies c is already marked as dirty, // A non-null r implies c is already marked as dirty,
// and that the parent is valid. Therefore we can // and that the parent is valid. Therefore we can
...@@ -609,9 +609,9 @@ public class RepaintManager ...@@ -609,9 +609,9 @@ public class RepaintManager
if (delegate != null) { if (delegate != null) {
return delegate.getDirtyRegion(aComponent); return delegate.getDirtyRegion(aComponent);
} }
Rectangle r = null; Rectangle r;
synchronized(this) { synchronized(this) {
r = (Rectangle)dirtyComponents.get(aComponent); r = dirtyComponents.get(aComponent);
} }
if(r == null) if(r == null)
return new Rectangle(0,0,0,0); return new Rectangle(0,0,0,0);
...@@ -745,8 +745,8 @@ public class RepaintManager ...@@ -745,8 +745,8 @@ public class RepaintManager
Rectangle rect; Rectangle rect;
int localBoundsX = 0; int localBoundsX = 0;
int localBoundsY = 0; int localBoundsY = 0;
int localBoundsH = 0; int localBoundsH;
int localBoundsW = 0; int localBoundsW;
Enumeration keys; Enumeration keys;
roots = new ArrayList<Component>(count); roots = new ArrayList<Component>(count);
...@@ -853,7 +853,7 @@ public class RepaintManager ...@@ -853,7 +853,7 @@ public class RepaintManager
dx = rootDx = 0; dx = rootDx = 0;
dy = rootDy = 0; dy = rootDy = 0;
tmp.setBounds((Rectangle) dirtyComponents.get(dirtyComponent)); tmp.setBounds(dirtyComponents.get(dirtyComponent));
// System.out.println("Collect dirty component for bound " + tmp + // System.out.println("Collect dirty component for bound " + tmp +
// "component bounds is " + cBounds);; // "component bounds is " + cBounds);;
...@@ -900,7 +900,7 @@ public class RepaintManager ...@@ -900,7 +900,7 @@ public class RepaintManager
Rectangle r; Rectangle r;
tmp.setLocation(tmp.x + rootDx - dx, tmp.setLocation(tmp.x + rootDx - dx,
tmp.y + rootDy - dy); tmp.y + rootDy - dy);
r = (Rectangle)dirtyComponents.get(rootDirtyComponent); r = dirtyComponents.get(rootDirtyComponent);
SwingUtilities.computeUnion(tmp.x,tmp.y,tmp.width,tmp.height,r); SwingUtilities.computeUnion(tmp.x,tmp.y,tmp.width,tmp.height,r);
} }
...@@ -985,7 +985,7 @@ public class RepaintManager ...@@ -985,7 +985,7 @@ public class RepaintManager
private Image _getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight) { private Image _getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight) {
Dimension maxSize = getDoubleBufferMaximumSize(); Dimension maxSize = getDoubleBufferMaximumSize();
DoubleBufferInfo doubleBuffer = null; DoubleBufferInfo doubleBuffer;
int width, height; int width, height;
if (standardDoubleBuffer == null) { if (standardDoubleBuffer == null) {
...@@ -1054,7 +1054,7 @@ public class RepaintManager ...@@ -1054,7 +1054,7 @@ public class RepaintManager
Iterator gcs = volatileMap.keySet().iterator(); Iterator gcs = volatileMap.keySet().iterator();
while (gcs.hasNext()) { while (gcs.hasNext()) {
GraphicsConfiguration gc = (GraphicsConfiguration)gcs.next(); GraphicsConfiguration gc = (GraphicsConfiguration)gcs.next();
VolatileImage image = (VolatileImage)volatileMap.get(gc); VolatileImage image = volatileMap.get(gc);
if (image.getWidth() > width || image.getHeight() > height) { if (image.getWidth() > width || image.getHeight() > height) {
image.flush(); image.flush();
gcs.remove(); gcs.remove();
...@@ -1222,7 +1222,7 @@ public class RepaintManager ...@@ -1222,7 +1222,7 @@ public class RepaintManager
*/ */
void beginPaint() { void beginPaint() {
boolean multiThreadedPaint = false; boolean multiThreadedPaint = false;
int paintDepth = 0; int paintDepth;
Thread currentThread = Thread.currentThread(); Thread currentThread = Thread.currentThread();
synchronized(this) { synchronized(this) {
paintDepth = this.paintDepth; paintDepth = this.paintDepth;
......
...@@ -79,7 +79,7 @@ public class SortingFocusTraversalPolicy ...@@ -79,7 +79,7 @@ public class SortingFocusTraversalPolicy
* sorted list should be reused if possible. * sorted list should be reused if possible.
*/ */
transient private Container cachedRoot; transient private Container cachedRoot;
transient private List cachedCycle; transient private List<Component> cachedCycle;
// Delegate our fitness test to ContainerOrder so that we only have to // Delegate our fitness test to ContainerOrder so that we only have to
// code the algorithm once. // code the algorithm once.
...@@ -111,7 +111,7 @@ public class SortingFocusTraversalPolicy ...@@ -111,7 +111,7 @@ public class SortingFocusTraversalPolicy
return cycle; return cycle;
} }
private int getComponentIndex(List<Component> cycle, Component aComponent) { private int getComponentIndex(List<Component> cycle, Component aComponent) {
int index = 0; int index;
try { try {
index = Collections.binarySearch(cycle, aComponent, comparator); index = Collections.binarySearch(cycle, aComponent, comparator);
} catch (ClassCastException e) { } catch (ClassCastException e) {
...@@ -130,14 +130,14 @@ public class SortingFocusTraversalPolicy ...@@ -130,14 +130,14 @@ public class SortingFocusTraversalPolicy
return index; return index;
} }
private void enumerateAndSortCycle(Container focusCycleRoot, List cycle) { private void enumerateAndSortCycle(Container focusCycleRoot, List<Component> cycle) {
if (focusCycleRoot.isShowing()) { if (focusCycleRoot.isShowing()) {
enumerateCycle(focusCycleRoot, cycle); enumerateCycle(focusCycleRoot, cycle);
Collections.sort(cycle, comparator); Collections.sort(cycle, comparator);
} }
} }
private void enumerateCycle(Container container, List cycle) { private void enumerateCycle(Container container, List<Component> cycle) {
if (!(container.isVisible() && container.isDisplayable())) { if (!(container.isVisible() && container.isDisplayable())) {
return; return;
} }
...@@ -145,8 +145,7 @@ public class SortingFocusTraversalPolicy ...@@ -145,8 +145,7 @@ public class SortingFocusTraversalPolicy
cycle.add(container); cycle.add(container);
Component[] components = container.getComponents(); Component[] components = container.getComponents();
for (int i = 0; i < components.length; i++) { for (Component comp : components) {
Component comp = components[i];
if (comp instanceof Container) { if (comp instanceof Container) {
Container cont = (Container)comp; Container cont = (Container)comp;
...@@ -385,8 +384,8 @@ public class SortingFocusTraversalPolicy ...@@ -385,8 +384,8 @@ public class SortingFocusTraversalPolicy
return getLastComponent(aContainer); return getLastComponent(aContainer);
} }
Component comp = null; Component comp;
Component tryComp = null; Component tryComp;
for (index--; index>=0; index--) { for (index--; index>=0; index--) {
comp = cycle.get(index); comp = cycle.get(index);
...@@ -442,8 +441,7 @@ public class SortingFocusTraversalPolicy ...@@ -442,8 +441,7 @@ public class SortingFocusTraversalPolicy
} }
if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle); if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle);
for (int i = 0; i < cycle.size(); i++) { for (Component comp : cycle) {
Component comp = cycle.get(i);
if (accept(comp)) { if (accept(comp)) {
return comp; return comp;
} else if (comp instanceof Container && comp != aContainer) { } else if (comp instanceof Container && comp != aContainer) {
......
...@@ -185,11 +185,11 @@ import java.util.*; ...@@ -185,11 +185,11 @@ import java.util.*;
* @since 1.4 * @since 1.4
*/ */
public class SpringLayout implements LayoutManager2 { public class SpringLayout implements LayoutManager2 {
private Map componentConstraints = new HashMap(); private Map<Component, Constraints> componentConstraints = new HashMap<Component, Constraints>();
private Spring cyclicReference = Spring.constant(Spring.UNSET); private Spring cyclicReference = Spring.constant(Spring.UNSET);
private Set cyclicSprings; private Set<Spring> cyclicSprings;
private Set acyclicSprings; private Set<Spring> acyclicSprings;
/** /**
...@@ -415,8 +415,7 @@ public class SpringLayout implements LayoutManager2 { ...@@ -415,8 +415,7 @@ public class SpringLayout implements LayoutManager2 {
} }
if (!valid) { if (!valid) {
String[] all = horizontal ? ALL_HORIZONTAL : ALL_VERTICAL; String[] all = horizontal ? ALL_HORIZONTAL : ALL_VERTICAL;
for (int i = 0; i < all.length; i++) { for (String s : all) {
String s = all[i];
if (!history.contains(s)) { if (!history.contains(s)) {
setConstraint(s, null); setConstraint(s, null);
} }
...@@ -822,8 +821,7 @@ public class SpringLayout implements LayoutManager2 { ...@@ -822,8 +821,7 @@ public class SpringLayout implements LayoutManager2 {
/*pp*/ void reset() { /*pp*/ void reset() {
Spring[] allSprings = {x, y, width, height, east, south, Spring[] allSprings = {x, y, width, height, east, south,
horizontalCenter, verticalCenter, baseline}; horizontalCenter, verticalCenter, baseline};
for (int i = 0; i < allSprings.length; i++) { for (Spring s : allSprings) {
Spring s = allSprings[i];
if (s != null) { if (s != null) {
s.setValue(Spring.UNSET); s.setValue(Spring.UNSET);
} }
...@@ -881,8 +879,8 @@ public class SpringLayout implements LayoutManager2 { ...@@ -881,8 +879,8 @@ public class SpringLayout implements LayoutManager2 {
public SpringLayout() {} public SpringLayout() {}
private void resetCyclicStatuses() { private void resetCyclicStatuses() {
cyclicSprings = new HashSet(); cyclicSprings = new HashSet<Spring>();
acyclicSprings = new HashSet(); acyclicSprings = new HashSet<Spring>();
} }
private void setParent(Container p) { private void setParent(Container p) {
...@@ -1145,7 +1143,7 @@ public class SpringLayout implements LayoutManager2 { ...@@ -1145,7 +1143,7 @@ public class SpringLayout implements LayoutManager2 {
* @return the constraints for the specified component * @return the constraints for the specified component
*/ */
public Constraints getConstraints(Component c) { public Constraints getConstraints(Component c) {
Constraints result = (Constraints)componentConstraints.get(c); Constraints result = componentConstraints.get(c);
if (result == null) { if (result == null) {
if (c instanceof javax.swing.JComponent) { if (c instanceof javax.swing.JComponent) {
Object cp = ((javax.swing.JComponent)c).getClientProperty(SpringLayout.class); Object cp = ((javax.swing.JComponent)c).getClientProperty(SpringLayout.class);
......
...@@ -108,11 +108,8 @@ public class SwingUtilities implements SwingConstants ...@@ -108,11 +108,8 @@ public class SwingUtilities implements SwingConstants
* Return true if <code>a</code> contains <code>b</code> * Return true if <code>a</code> contains <code>b</code>
*/ */
public static final boolean isRectangleContainingRectangle(Rectangle a,Rectangle b) { public static final boolean isRectangleContainingRectangle(Rectangle a,Rectangle b) {
if (b.x >= a.x && (b.x + b.width) <= (a.x + a.width) && return b.x >= a.x && (b.x + b.width) <= (a.x + a.width) &&
b.y >= a.y && (b.y + b.height) <= (a.y + a.height)) { b.y >= a.y && (b.y + b.height) <= (a.y + a.height);
return true;
}
return false;
} }
/** /**
...@@ -272,8 +269,7 @@ public class SwingUtilities implements SwingConstants ...@@ -272,8 +269,7 @@ public class SwingUtilities implements SwingConstants
} }
if (parent instanceof Container) { if (parent instanceof Container) {
Component components[] = ((Container)parent).getComponents(); Component components[] = ((Container)parent).getComponents();
for (int i = 0 ; i < components.length ; i++) { for (Component comp : components) {
Component comp = components[i];
if (comp != null && comp.isVisible()) { if (comp != null && comp.isVisible()) {
Point loc = comp.getLocation(); Point loc = comp.getLocation();
if (comp instanceof Container) { if (comp instanceof Container) {
...@@ -376,8 +372,8 @@ public class SwingUtilities implements SwingConstants ...@@ -376,8 +372,8 @@ public class SwingUtilities implements SwingConstants
do { do {
if(c instanceof JComponent) { if(c instanceof JComponent) {
x = ((JComponent)c).getX(); x = c.getX();
y = ((JComponent)c).getY(); y = c.getY();
} else if(c instanceof java.applet.Applet || } else if(c instanceof java.applet.Applet ||
c instanceof java.awt.Window) { c instanceof java.awt.Window) {
try { try {
...@@ -415,8 +411,8 @@ public class SwingUtilities implements SwingConstants ...@@ -415,8 +411,8 @@ public class SwingUtilities implements SwingConstants
do { do {
if(c instanceof JComponent) { if(c instanceof JComponent) {
x = ((JComponent)c).getX(); x = c.getX();
y = ((JComponent)c).getY(); y = c.getY();
} else if(c instanceof java.applet.Applet || } else if(c instanceof java.applet.Applet ||
c instanceof java.awt.Window) { c instanceof java.awt.Window) {
try { try {
...@@ -980,7 +976,7 @@ public class SwingUtilities implements SwingConstants ...@@ -980,7 +976,7 @@ public class SwingUtilities implements SwingConstants
*/ */
int gap; int gap;
View v = null; View v;
if (textIsEmpty) { if (textIsEmpty) {
textR.width = textR.height = 0; textR.width = textR.height = 0;
text = ""; text = "";
...@@ -1248,8 +1244,8 @@ public class SwingUtilities implements SwingConstants ...@@ -1248,8 +1244,8 @@ public class SwingUtilities implements SwingConstants
children = ((Container)c).getComponents(); children = ((Container)c).getComponents();
} }
if (children != null) { if (children != null) {
for(int i = 0; i < children.length; i++) { for (Component child : children) {
updateComponentTreeUI0(children[i]); updateComponentTreeUI0(child);
} }
} }
} }
...@@ -1702,7 +1698,7 @@ public class SwingUtilities implements SwingConstants ...@@ -1702,7 +1698,7 @@ public class SwingUtilities implements SwingConstants
*/ */
public static void replaceUIActionMap(JComponent component, public static void replaceUIActionMap(JComponent component,
ActionMap uiActionMap) { ActionMap uiActionMap) {
ActionMap map = component.getActionMap((uiActionMap != null));; ActionMap map = component.getActionMap((uiActionMap != null));
while (map != null) { while (map != null) {
ActionMap parent = map.getParent(); ActionMap parent = map.getParent();
...@@ -1770,8 +1766,7 @@ public class SwingUtilities implements SwingConstants ...@@ -1770,8 +1766,7 @@ public class SwingUtilities implements SwingConstants
*/ */
void installListeners() { void installListeners() {
Window[] windows = getOwnedWindows(); Window[] windows = getOwnedWindows();
for (int ind = 0; ind < windows.length; ind++){ for (Window window : windows) {
Window window = windows[ind];
if (window != null) { if (window != null) {
window.removeWindowListener(this); window.removeWindowListener(this);
window.addWindowListener(this); window.addWindowListener(this);
...@@ -1786,8 +1781,7 @@ public class SwingUtilities implements SwingConstants ...@@ -1786,8 +1781,7 @@ public class SwingUtilities implements SwingConstants
public void windowClosed(WindowEvent e) { public void windowClosed(WindowEvent e) {
synchronized(getTreeLock()) { synchronized(getTreeLock()) {
Window[] windows = getOwnedWindows(); Window[] windows = getOwnedWindows();
for (int ind = 0; ind < windows.length; ind++) { for (Window window : windows) {
Window window = windows[ind];
if (window != null) { if (window != null) {
if (window.isDisplayable()) { if (window.isDisplayable()) {
return; return;
...@@ -1875,7 +1869,7 @@ public class SwingUtilities implements SwingConstants ...@@ -1875,7 +1869,7 @@ public class SwingUtilities implements SwingConstants
} }
static Class loadSystemClass(String className) throws ClassNotFoundException { static Class<?> loadSystemClass(String className) throws ClassNotFoundException {
return Class.forName(className, true, Thread.currentThread(). return Class.forName(className, true, Thread.currentThread().
getContextClassLoader()); getContextClassLoader());
} }
......
...@@ -270,8 +270,7 @@ public class Timer implements Serializable ...@@ -270,8 +270,7 @@ public class Timer implements Serializable
* @since 1.4 * @since 1.4
*/ */
public ActionListener[] getActionListeners() { public ActionListener[] getActionListeners() {
return (ActionListener[])listenerList.getListeners( return listenerList.getListeners(ActionListener.class);
ActionListener.class);
} }
......
...@@ -97,7 +97,7 @@ class TimerQueue implements Runnable ...@@ -97,7 +97,7 @@ class TimerQueue implements Runnable
final ThreadGroup threadGroup = final ThreadGroup threadGroup =
AppContext.getAppContext().getThreadGroup(); AppContext.getAppContext().getThreadGroup();
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Object>() {
public Object run() { public Object run() {
Thread timerThread = new Thread(threadGroup, TimerQueue.this, Thread timerThread = new Thread(threadGroup, TimerQueue.this,
"TimerQueue"); "TimerQueue");
...@@ -226,7 +226,7 @@ class TimerQueue implements Runnable ...@@ -226,7 +226,7 @@ class TimerQueue implements Runnable
/** /**
* Returns nanosecond time offset by origin * Returns nanosecond time offset by origin
*/ */
private final static long now() { private static long now() {
return System.nanoTime() - NANO_ORIGIN; return System.nanoTime() - NANO_ORIGIN;
} }
......
...@@ -72,11 +72,11 @@ import sun.util.CoreResourceBundleControl; ...@@ -72,11 +72,11 @@ import sun.util.CoreResourceBundleControl;
*/ */
public class UIDefaults extends Hashtable<Object,Object> public class UIDefaults extends Hashtable<Object,Object>
{ {
private static final Object PENDING = new String("Pending"); private static final Object PENDING = "Pending";
private SwingPropertyChangeSupport changeSupport; private SwingPropertyChangeSupport changeSupport;
private Vector resourceBundles; private Vector<String> resourceBundles;
private Locale defaultLocale = Locale.getDefault(); private Locale defaultLocale = Locale.getDefault();
...@@ -86,7 +86,7 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -86,7 +86,7 @@ public class UIDefaults extends Hashtable<Object,Object>
* Access to this should be done while holding a lock on the * Access to this should be done while holding a lock on the
* UIDefaults, eg synchronized(this). * UIDefaults, eg synchronized(this).
*/ */
private Map resourceCache; private Map<Locale, Map<String, Object>> resourceCache;
/** /**
* Creates an empty defaults table. * Creates an empty defaults table.
...@@ -106,7 +106,7 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -106,7 +106,7 @@ public class UIDefaults extends Hashtable<Object,Object>
*/ */
public UIDefaults(int initialCapacity, float loadFactor) { public UIDefaults(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor); super(initialCapacity, loadFactor);
resourceCache = new HashMap(); resourceCache = new HashMap<Locale, Map<String, Object>>();
} }
...@@ -281,24 +281,24 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -281,24 +281,24 @@ public class UIDefaults extends Hashtable<Object,Object>
if( defaultLocale == null ) if( defaultLocale == null )
return null; return null;
else else
l = (Locale)defaultLocale; l = defaultLocale;
} }
synchronized(this) { synchronized(this) {
return getResourceCache(l).get((String)key); return getResourceCache(l).get(key);
} }
} }
/** /**
* Returns a Map of the known resources for the given locale. * Returns a Map of the known resources for the given locale.
*/ */
private Map getResourceCache(Locale l) { private Map<String, Object> getResourceCache(Locale l) {
Map values = (Map)resourceCache.get(l); Map<String, Object> values = resourceCache.get(l);
if (values == null) { if (values == null) {
values = new HashMap(); values = new HashMap<String, Object>();
for (int i=resourceBundles.size()-1; i >= 0; i--) { for (int i=resourceBundles.size()-1; i >= 0; i--) {
String bundleName = (String)resourceBundles.get(i); String bundleName = resourceBundles.get(i);
try { try {
Control c = CoreResourceBundleControl.getRBControlInstance(bundleName); Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
ResourceBundle b; ResourceBundle b;
...@@ -751,7 +751,7 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -751,7 +751,7 @@ public class UIDefaults extends Hashtable<Object,Object>
Object cl = get("ClassLoader"); Object cl = get("ClassLoader");
ClassLoader uiClassLoader = ClassLoader uiClassLoader =
(cl != null) ? (ClassLoader)cl : target.getClass().getClassLoader(); (cl != null) ? (ClassLoader)cl : target.getClass().getClassLoader();
Class uiClass = getUIClass(target.getUIClassID(), uiClassLoader); Class<? extends ComponentUI> uiClass = getUIClass(target.getUIClassID(), uiClassLoader);
Object uiObject = null; Object uiObject = null;
if (uiClass == null) { if (uiClass == null) {
...@@ -761,8 +761,7 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -761,8 +761,7 @@ public class UIDefaults extends Hashtable<Object,Object>
try { try {
Method m = (Method)get(uiClass); Method m = (Method)get(uiClass);
if (m == null) { if (m == null) {
Class acClass = javax.swing.JComponent.class; m = uiClass.getMethod("createUI", new Class[]{JComponent.class});
m = uiClass.getMethod("createUI", new Class[]{acClass});
put(uiClass, m); put(uiClass, m);
} }
uiObject = MethodUtil.invoke(m, null, new Object[]{target}); uiObject = MethodUtil.invoke(m, null, new Object[]{target});
...@@ -862,7 +861,7 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -862,7 +861,7 @@ public class UIDefaults extends Hashtable<Object,Object>
return; return;
} }
if( resourceBundles == null ) { if( resourceBundles == null ) {
resourceBundles = new Vector(5); resourceBundles = new Vector<String>(5);
} }
if (!resourceBundles.contains(bundleName)) { if (!resourceBundles.contains(bundleName)) {
resourceBundles.add( bundleName ); resourceBundles.add( bundleName );
...@@ -1064,7 +1063,7 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -1064,7 +1063,7 @@ public class UIDefaults extends Hashtable<Object,Object>
className = c; className = c;
methodName = m; methodName = m;
if (o != null) { if (o != null) {
args = (Object[])o.clone(); args = o.clone();
} }
} }
...@@ -1079,10 +1078,10 @@ public class UIDefaults extends Hashtable<Object,Object> ...@@ -1079,10 +1078,10 @@ public class UIDefaults extends Hashtable<Object,Object>
// In order to pick up the security policy in effect at the // In order to pick up the security policy in effect at the
// time of creation we use a doPrivileged with the // time of creation we use a doPrivileged with the
// AccessControlContext that was in place when this was created. // AccessControlContext that was in place when this was created.
return AccessController.doPrivileged(new PrivilegedAction() { return AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() { public Object run() {
try { try {
Class c; Class<?> c;
Object cl; Object cl;
// See if we should use a separate ClassLoader // See if we should use a separate ClassLoader
if (table == null || !((cl = table.get("ClassLoader")) if (table == null || !((cl = table.get("ClassLoader"))
......
...@@ -191,7 +191,7 @@ public class UIManager implements Serializable ...@@ -191,7 +191,7 @@ public class UIManager implements Serializable
MultiUIDefaults multiUIDefaults = new MultiUIDefaults(tables); MultiUIDefaults multiUIDefaults = new MultiUIDefaults(tables);
LookAndFeel lookAndFeel; LookAndFeel lookAndFeel;
LookAndFeel multiLookAndFeel = null; LookAndFeel multiLookAndFeel = null;
Vector auxLookAndFeels = null; Vector<LookAndFeel> auxLookAndFeels = null;
SwingPropertyChangeSupport changeSupport; SwingPropertyChangeSupport changeSupport;
UIDefaults getLookAndFeelDefaults() { return tables[0]; } UIDefaults getLookAndFeelDefaults() { return tables[0]; }
...@@ -378,7 +378,7 @@ public class UIManager implements Serializable ...@@ -378,7 +378,7 @@ public class UIManager implements Serializable
private static LookAndFeelInfo[] installedLAFs; private static LookAndFeelInfo[] installedLAFs;
static { static {
ArrayList iLAFs = new ArrayList(4); ArrayList<LookAndFeelInfo> iLAFs = new ArrayList<LookAndFeelInfo>(4);
iLAFs.add(new LookAndFeelInfo( iLAFs.add(new LookAndFeelInfo(
"Metal", "javax.swing.plaf.metal.MetalLookAndFeel")); "Metal", "javax.swing.plaf.metal.MetalLookAndFeel"));
iLAFs.add(new LookAndFeelInfo("CDE/Motif", iLAFs.add(new LookAndFeelInfo("CDE/Motif",
...@@ -400,8 +400,7 @@ public class UIManager implements Serializable ...@@ -400,8 +400,7 @@ public class UIManager implements Serializable
iLAFs.add(new LookAndFeelInfo("GTK+", iLAFs.add(new LookAndFeelInfo("GTK+",
"com.sun.java.swing.plaf.gtk.GTKLookAndFeel")); "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"));
} }
installedLAFs = (LookAndFeelInfo[])iLAFs.toArray( installedLAFs = iLAFs.toArray(new LookAndFeelInfo[iLAFs.size()]);
new LookAndFeelInfo[iLAFs.size()]);
} }
...@@ -640,7 +639,7 @@ public class UIManager implements Serializable ...@@ -640,7 +639,7 @@ public class UIManager implements Serializable
* @see #getSystemLookAndFeelClassName * @see #getSystemLookAndFeelClassName
*/ */
public static String getCrossPlatformLookAndFeelClassName() { public static String getCrossPlatformLookAndFeelClassName() {
String laf = (String)AccessController.doPrivileged( String laf = AccessController.doPrivileged(
new GetPropertyAction("swing.crossplatformlaf")); new GetPropertyAction("swing.crossplatformlaf"));
if (laf != null) { if (laf != null) {
return laf; return laf;
...@@ -1079,9 +1078,9 @@ public class UIManager implements Serializable ...@@ -1079,9 +1078,9 @@ public class UIManager implements Serializable
// for that. // for that.
return; return;
} }
Vector v = getLAFState().auxLookAndFeels; Vector<LookAndFeel> v = getLAFState().auxLookAndFeels;
if (v == null) { if (v == null) {
v = new Vector(); v = new Vector<LookAndFeel>();
} }
if (!v.contains(laf)) { if (!v.contains(laf)) {
...@@ -1115,7 +1114,7 @@ public class UIManager implements Serializable ...@@ -1115,7 +1114,7 @@ public class UIManager implements Serializable
boolean result; boolean result;
Vector v = getLAFState().auxLookAndFeels; Vector<LookAndFeel> v = getLAFState().auxLookAndFeels;
if ((v == null) || (v.size() == 0)) { if ((v == null) || (v.size() == 0)) {
return false; return false;
} }
...@@ -1151,14 +1150,14 @@ public class UIManager implements Serializable ...@@ -1151,14 +1150,14 @@ public class UIManager implements Serializable
static public LookAndFeel[] getAuxiliaryLookAndFeels() { static public LookAndFeel[] getAuxiliaryLookAndFeels() {
maybeInitialize(); maybeInitialize();
Vector v = getLAFState().auxLookAndFeels; Vector<LookAndFeel> v = getLAFState().auxLookAndFeels;
if ((v == null) || (v.size() == 0)) { if ((v == null) || (v.size() == 0)) {
return null; return null;
} }
else { else {
LookAndFeel[] rv = new LookAndFeel[v.size()]; LookAndFeel[] rv = new LookAndFeel[v.size()];
for (int i = 0; i < rv.length; i++) { for (int i = 0; i < rv.length; i++) {
rv[i] = (LookAndFeel)v.elementAt(i); rv[i] = v.elementAt(i);
} }
return rv; return rv;
} }
...@@ -1225,7 +1224,7 @@ public class UIManager implements Serializable ...@@ -1225,7 +1224,7 @@ public class UIManager implements Serializable
final Properties props = new Properties(); final Properties props = new Properties();
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Object>() {
public Object run() { public Object run() {
try { try {
File file = new File(makeSwingPropertiesFilename()); File file = new File(makeSwingPropertiesFilename());
...@@ -1284,7 +1283,7 @@ public class UIManager implements Serializable ...@@ -1284,7 +1283,7 @@ public class UIManager implements Serializable
* property. For example given "swing.installedlafs=motif,windows" * property. For example given "swing.installedlafs=motif,windows"
* lafs = {"motif", "windows"}. * lafs = {"motif", "windows"}.
*/ */
Vector lafs = new Vector(); Vector<String> lafs = new Vector<String>();
StringTokenizer st = new StringTokenizer(ilafsString, ",", false); StringTokenizer st = new StringTokenizer(ilafsString, ",", false);
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
lafs.addElement(st.nextToken()); lafs.addElement(st.nextToken());
...@@ -1294,9 +1293,8 @@ public class UIManager implements Serializable ...@@ -1294,9 +1293,8 @@ public class UIManager implements Serializable
* list. If they both exist then add a LookAndFeelInfo to * list. If they both exist then add a LookAndFeelInfo to
* the installedLafs array. * the installedLafs array.
*/ */
Vector ilafs = new Vector(lafs.size()); Vector<LookAndFeelInfo> ilafs = new Vector<LookAndFeelInfo>(lafs.size());
for(int i = 0; i < lafs.size(); i++) { for (String laf : lafs) {
String laf = (String)lafs.elementAt(i);
String name = swingProps.getProperty(makeInstalledLAFKey(laf, "name"), laf); String name = swingProps.getProperty(makeInstalledLAFKey(laf, "name"), laf);
String cls = swingProps.getProperty(makeInstalledLAFKey(laf, "class")); String cls = swingProps.getProperty(makeInstalledLAFKey(laf, "class"));
if (cls != null) { if (cls != null) {
...@@ -1306,7 +1304,7 @@ public class UIManager implements Serializable ...@@ -1306,7 +1304,7 @@ public class UIManager implements Serializable
installedLAFs = new LookAndFeelInfo[ilafs.size()]; installedLAFs = new LookAndFeelInfo[ilafs.size()];
for(int i = 0; i < ilafs.size(); i++) { for(int i = 0; i < ilafs.size(); i++) {
installedLAFs[i] = (LookAndFeelInfo)(ilafs.elementAt(i)); installedLAFs[i] = ilafs.elementAt(i);
} }
} }
...@@ -1350,7 +1348,7 @@ public class UIManager implements Serializable ...@@ -1350,7 +1348,7 @@ public class UIManager implements Serializable
return; return;
} }
Vector auxLookAndFeels = new Vector(); Vector<LookAndFeel> auxLookAndFeels = new Vector<LookAndFeel>();
StringTokenizer p = new StringTokenizer(auxLookAndFeelNames,","); StringTokenizer p = new StringTokenizer(auxLookAndFeelNames,",");
String factoryName; String factoryName;
...@@ -1451,7 +1449,7 @@ public class UIManager implements Serializable ...@@ -1451,7 +1449,7 @@ public class UIManager implements Serializable
Component c = e.getComponent(); Component c = e.getComponent();
if ((!(c instanceof JComponent) || if ((!(c instanceof JComponent) ||
(c != null && !((JComponent)c).isEnabled())) && (c != null && !c.isEnabled())) &&
JComponent.KeyboardState.shouldProcess(e) && JComponent.KeyboardState.shouldProcess(e) &&
SwingUtilities.processKeyBindings(e)) { SwingUtilities.processKeyBindings(e)) {
e.consume(); e.consume();
......
...@@ -136,8 +136,8 @@ public abstract class FileSystemView { ...@@ -136,8 +136,8 @@ public abstract class FileSystemView {
} }
File[] roots = getRoots(); File[] roots = getRoots();
for (int i = 0; i < roots.length; i++) { for (File root : roots) {
if (roots[i].equals(f)) { if (root.equals(f)) {
return true; return true;
} }
} }
...@@ -252,8 +252,8 @@ public abstract class FileSystemView { ...@@ -252,8 +252,8 @@ public abstract class FileSystemView {
return true; return true;
} }
File[] children = getFiles(folder, false); File[] children = getFiles(folder, false);
for (int i = 0; i < children.length; i++) { for (File child : children) {
if (file.equals(children[i])) { if (file.equals(child)) {
return true; return true;
} }
} }
...@@ -276,9 +276,9 @@ public abstract class FileSystemView { ...@@ -276,9 +276,9 @@ public abstract class FileSystemView {
public File getChild(File parent, String fileName) { public File getChild(File parent, String fileName) {
if (parent instanceof ShellFolder) { if (parent instanceof ShellFolder) {
File[] children = getFiles(parent, false); File[] children = getFiles(parent, false);
for (int i = 0; i < children.length; i++) { for (File child : children) {
if (children[i].getName().equals(fileName)) { if (child.getName().equals(fileName)) {
return children[i]; return child;
} }
} }
} }
...@@ -444,7 +444,7 @@ public abstract class FileSystemView { ...@@ -444,7 +444,7 @@ public abstract class FileSystemView {
* Gets the list of shown (i.e. not hidden) files. * Gets the list of shown (i.e. not hidden) files.
*/ */
public File[] getFiles(File dir, boolean useFileHiding) { public File[] getFiles(File dir, boolean useFileHiding) {
Vector files = new Vector(); Vector<File> files = new Vector<File>();
// add all files in dir // add all files in dir
...@@ -483,7 +483,7 @@ public abstract class FileSystemView { ...@@ -483,7 +483,7 @@ public abstract class FileSystemView {
} }
} }
return (File[])files.toArray(new File[files.size()]); return files.toArray(new File[files.size()]);
} }
...@@ -590,7 +590,7 @@ class UnixFileSystemView extends FileSystemView { ...@@ -590,7 +590,7 @@ class UnixFileSystemView extends FileSystemView {
if(containingDir == null) { if(containingDir == null) {
throw new IOException("Containing directory is null:"); throw new IOException("Containing directory is null:");
} }
File newFolder = null; File newFolder;
// Unix - using OpenWindows' default folder name. Can't find one for Motif/CDE. // Unix - using OpenWindows' default folder name. Can't find one for Motif/CDE.
newFolder = createFileObject(containingDir, newFolderString); newFolder = createFileObject(containingDir, newFolderString);
int i = 1; int i = 1;
...@@ -614,11 +614,7 @@ class UnixFileSystemView extends FileSystemView { ...@@ -614,11 +614,7 @@ class UnixFileSystemView extends FileSystemView {
} }
public boolean isDrive(File dir) { public boolean isDrive(File dir) {
if (isFloppyDrive(dir)) { return isFloppyDrive(dir);
return true;
} else {
return false;
}
} }
public boolean isFloppyDrive(File dir) { public boolean isFloppyDrive(File dir) {
...@@ -700,9 +696,8 @@ class WindowsFileSystemView extends FileSystemView { ...@@ -700,9 +696,8 @@ class WindowsFileSystemView extends FileSystemView {
if(containingDir == null) { if(containingDir == null) {
throw new IOException("Containing directory is null:"); throw new IOException("Containing directory is null:");
} }
File newFolder = null;
// Using NT's default folder name // Using NT's default folder name
newFolder = createFileObject(containingDir, newFolderString); File newFolder = createFileObject(containingDir, newFolderString);
int i = 2; int i = 2;
while (newFolder.exists() && (i < 100)) { while (newFolder.exists() && (i < 100)) {
newFolder = createFileObject(containingDir, MessageFormat.format( newFolder = createFileObject(containingDir, MessageFormat.format(
...@@ -770,9 +765,8 @@ class GenericFileSystemView extends FileSystemView { ...@@ -770,9 +765,8 @@ class GenericFileSystemView extends FileSystemView {
if(containingDir == null) { if(containingDir == null) {
throw new IOException("Containing directory is null:"); throw new IOException("Containing directory is null:");
} }
File newFolder = null;
// Using NT's default folder name // Using NT's default folder name
newFolder = createFileObject(containingDir, newFolderString); File newFolder = createFileObject(containingDir, newFolderString);
if(newFolder.exists()) { if(newFolder.exists()) {
throw new IOException("Directory already exists:" + newFolder.getAbsolutePath()); throw new IOException("Directory already exists:" + newFolder.getAbsolutePath());
......
...@@ -176,8 +176,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable ...@@ -176,8 +176,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable
* @since 1.4 * @since 1.4
*/ */
public TableModelListener[] getTableModelListeners() { public TableModelListener[] getTableModelListeners() {
return (TableModelListener[])listenerList.getListeners( return listenerList.getListeners(TableModelListener.class);
TableModelListener.class);
} }
// //
......
...@@ -681,9 +681,9 @@ public class DefaultTableModel extends AbstractTableModel implements Serializabl ...@@ -681,9 +681,9 @@ public class DefaultTableModel extends AbstractTableModel implements Serializabl
if (anArray == null) { if (anArray == null) {
return null; return null;
} }
Vector v = new Vector(anArray.length); Vector<Object> v = new Vector<Object>(anArray.length);
for (int i=0; i < anArray.length; i++) { for (Object o : anArray) {
v.addElement(anArray[i]); v.addElement(o);
} }
return v; return v;
} }
...@@ -698,9 +698,9 @@ public class DefaultTableModel extends AbstractTableModel implements Serializabl ...@@ -698,9 +698,9 @@ public class DefaultTableModel extends AbstractTableModel implements Serializabl
if (anArray == null) { if (anArray == null) {
return null; return null;
} }
Vector v = new Vector(anArray.length); Vector<Vector> v = new Vector<Vector>(anArray.length);
for (int i=0; i < anArray.length; i++) { for (Object[] o : anArray) {
v.addElement(convertToVector(anArray[i])); v.addElement(convertToVector(o));
} }
return v; return v;
} }
......
...@@ -551,7 +551,7 @@ public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor, ...@@ -551,7 +551,7 @@ public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor,
// Serialization support. // Serialization support.
private void writeObject(ObjectOutputStream s) throws IOException { private void writeObject(ObjectOutputStream s) throws IOException {
Vector values = new Vector(); Vector<Object> values = new Vector<Object>();
s.defaultWriteObject(); s.defaultWriteObject();
// Save the realEditor, if its Serializable. // Save the realEditor, if its Serializable.
......
...@@ -453,8 +453,7 @@ public class DefaultTreeModel implements Serializable, TreeModel { ...@@ -453,8 +453,7 @@ public class DefaultTreeModel implements Serializable, TreeModel {
* @since 1.4 * @since 1.4
*/ */
public TreeModelListener[] getTreeModelListeners() { public TreeModelListener[] getTreeModelListeners() {
return (TreeModelListener[])listenerList.getListeners( return listenerList.getListeners(TreeModelListener.class);
TreeModelListener.class);
} }
/** /**
...@@ -652,7 +651,7 @@ public class DefaultTreeModel implements Serializable, TreeModel { ...@@ -652,7 +651,7 @@ public class DefaultTreeModel implements Serializable, TreeModel {
// Serialization support. // Serialization support.
private void writeObject(ObjectOutputStream s) throws IOException { private void writeObject(ObjectOutputStream s) throws IOException {
Vector values = new Vector(); Vector<Object> values = new Vector<Object>();
s.defaultWriteObject(); s.defaultWriteObject();
// Save the root, if its Serializable. // Save the root, if its Serializable.
......
...@@ -61,7 +61,7 @@ import javax.swing.DefaultListSelectionModel; ...@@ -61,7 +61,7 @@ import javax.swing.DefaultListSelectionModel;
* *
* @author Scott Violet * @author Scott Violet
*/ */
public class DefaultTreeSelectionModel extends Object implements Cloneable, Serializable, TreeSelectionModel public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeSelectionModel
{ {
/** Property name for selectionMode. */ /** Property name for selectionMode. */
public static final String SELECTION_MODE_PROPERTY = "selectionMode"; public static final String SELECTION_MODE_PROPERTY = "selectionMode";
...@@ -98,8 +98,8 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -98,8 +98,8 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
/** Used to make sure the paths are unique, will contain all the paths /** Used to make sure the paths are unique, will contain all the paths
* in <code>selection</code>. * in <code>selection</code>.
*/ */
private Hashtable uniquePaths; private Hashtable<TreePath, Boolean> uniquePaths;
private Hashtable lastPaths; private Hashtable<TreePath, Boolean> lastPaths;
private TreePath[] tempPaths; private TreePath[] tempPaths;
...@@ -111,8 +111,8 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -111,8 +111,8 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
listSelectionModel = new DefaultListSelectionModel(); listSelectionModel = new DefaultListSelectionModel();
selectionMode = DISCONTIGUOUS_TREE_SELECTION; selectionMode = DISCONTIGUOUS_TREE_SELECTION;
leadIndex = leadRow = -1; leadIndex = leadRow = -1;
uniquePaths = new Hashtable(); uniquePaths = new Hashtable<TreePath, Boolean>();
lastPaths = new Hashtable(); lastPaths = new Hashtable<TreePath, Boolean>();
tempPaths = new TreePath[1]; tempPaths = new TreePath[1];
} }
...@@ -245,7 +245,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -245,7 +245,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
} }
TreePath beginLeadPath = leadPath; TreePath beginLeadPath = leadPath;
Vector cPaths = new Vector(newCount + oldCount); Vector<PathPlaceHolder> cPaths = new Vector<PathPlaceHolder>(newCount + oldCount);
List<TreePath> newSelectionAsList = List<TreePath> newSelectionAsList =
new ArrayList<TreePath>(newCount); new ArrayList<TreePath>(newCount);
...@@ -276,7 +276,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -276,7 +276,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
selection = newSelection; selection = newSelection;
Hashtable tempHT = uniquePaths; Hashtable<TreePath, Boolean> tempHT = uniquePaths;
uniquePaths = lastPaths; uniquePaths = lastPaths;
lastPaths = tempHT; lastPaths = tempHT;
...@@ -348,7 +348,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -348,7 +348,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
int counter, validCount; int counter, validCount;
int oldCount; int oldCount;
TreePath beginLeadPath = leadPath; TreePath beginLeadPath = leadPath;
Vector cPaths = null; Vector<PathPlaceHolder> cPaths = null;
if(selection == null) if(selection == null)
oldCount = 0; oldCount = 0;
...@@ -363,7 +363,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -363,7 +363,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
if (uniquePaths.get(paths[counter]) == null) { if (uniquePaths.get(paths[counter]) == null) {
validCount++; validCount++;
if(cPaths == null) if(cPaths == null)
cPaths = new Vector(); cPaths = new Vector<PathPlaceHolder>();
cPaths.addElement(new PathPlaceHolder cPaths.addElement(new PathPlaceHolder
(paths[counter], true)); (paths[counter], true));
uniquePaths.put(paths[counter], Boolean.TRUE); uniquePaths.put(paths[counter], Boolean.TRUE);
...@@ -388,12 +388,11 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -388,12 +388,11 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
if(validCount != paths.length) { if(validCount != paths.length) {
/* Some of the paths in paths are already in /* Some of the paths in paths are already in
the selection. */ the selection. */
Enumeration newPaths = lastPaths.keys(); Enumeration<TreePath> newPaths = lastPaths.keys();
counter = oldCount; counter = oldCount;
while (newPaths.hasMoreElements()) { while (newPaths.hasMoreElements()) {
newSelection[counter++] = (TreePath)newPaths. newSelection[counter++] = newPaths.nextElement();
nextElement();
} }
} }
else { else {
...@@ -448,7 +447,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -448,7 +447,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
clearSelection(); clearSelection();
} }
else { else {
Vector pathsToRemove = null; Vector<PathPlaceHolder> pathsToRemove = null;
/* Find the paths that can be removed. */ /* Find the paths that can be removed. */
for (int removeCounter = paths.length - 1; removeCounter >= 0; for (int removeCounter = paths.length - 1; removeCounter >= 0;
...@@ -456,7 +455,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -456,7 +455,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
if(paths[removeCounter] != null) { if(paths[removeCounter] != null) {
if (uniquePaths.get(paths[removeCounter]) != null) { if (uniquePaths.get(paths[removeCounter]) != null) {
if(pathsToRemove == null) if(pathsToRemove == null)
pathsToRemove = new Vector(paths.length); pathsToRemove = new Vector<PathPlaceHolder>(paths.length);
uniquePaths.remove(paths[removeCounter]); uniquePaths.remove(paths[removeCounter]);
pathsToRemove.addElement(new PathPlaceHolder pathsToRemove.addElement(new PathPlaceHolder
(paths[removeCounter], false)); (paths[removeCounter], false));
...@@ -471,14 +470,13 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -471,14 +470,13 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
selection = null; selection = null;
} }
else { else {
Enumeration pEnum = uniquePaths.keys(); Enumeration<TreePath> pEnum = uniquePaths.keys();
int validCount = 0; int validCount = 0;
selection = new TreePath[selection.length - selection = new TreePath[selection.length -
removeCount]; removeCount];
while (pEnum.hasMoreElements()) { while (pEnum.hasMoreElements()) {
selection[validCount++] = (TreePath)pEnum. selection[validCount++] = pEnum.nextElement();
nextElement();
} }
} }
if (leadPath != null && if (leadPath != null &&
...@@ -613,8 +611,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -613,8 +611,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
* @since 1.4 * @since 1.4
*/ */
public TreeSelectionListener[] getTreeSelectionListeners() { public TreeSelectionListener[] getTreeSelectionListeners() {
return (TreeSelectionListener[])listenerList.getListeners( return listenerList.getListeners(TreeSelectionListener.class);
TreeSelectionListener.class);
} }
/** /**
...@@ -1081,7 +1078,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -1081,7 +1078,7 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
PathPlaceHolder placeholder; PathPlaceHolder placeholder;
for(int counter = 0; counter < cPathCount; counter++) { for(int counter = 0; counter < cPathCount; counter++) {
placeholder = (PathPlaceHolder)changedPaths.elementAt(counter); placeholder = changedPaths.elementAt(counter);
newness[counter] = placeholder.isNew; newness[counter] = placeholder.isNew;
paths[counter] = placeholder.path; paths[counter] = placeholder.path;
} }
...@@ -1177,8 +1174,8 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri ...@@ -1177,8 +1174,8 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri
clone.listenerList = new EventListenerList(); clone.listenerList = new EventListenerList();
clone.listSelectionModel = (DefaultListSelectionModel) clone.listSelectionModel = (DefaultListSelectionModel)
listSelectionModel.clone(); listSelectionModel.clone();
clone.uniquePaths = new Hashtable(); clone.uniquePaths = new Hashtable<TreePath, Boolean>();
clone.lastPaths = new Hashtable(); clone.lastPaths = new Hashtable<TreePath, Boolean>();
clone.tempPaths = new TreePath[1]; clone.tempPaths = new TreePath[1];
return clone; return clone;
} }
......
...@@ -64,21 +64,21 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache { ...@@ -64,21 +64,21 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
/** /**
* Maps from TreePath to a FHTreeStateNode. * Maps from TreePath to a FHTreeStateNode.
*/ */
private Hashtable treePathMapping; private Hashtable<TreePath, FHTreeStateNode> treePathMapping;
/** /**
* Used for getting path/row information. * Used for getting path/row information.
*/ */
private SearchInfo info; private SearchInfo info;
private Stack tempStacks; private Stack<Stack<TreePath>> tempStacks;
public FixedHeightLayoutCache() { public FixedHeightLayoutCache() {
super(); super();
tempStacks = new Stack(); tempStacks = new Stack<Stack<TreePath>>();
boundsBuffer = new Rectangle(); boundsBuffer = new Rectangle();
treePathMapping = new Hashtable(); treePathMapping = new Hashtable<TreePath, FHTreeStateNode>();
info = new SearchInfo(); info = new SearchInfo();
setRowHeight(1); setRowHeight(1);
} }
...@@ -592,7 +592,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache { ...@@ -592,7 +592,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
* return null, if you to create a node use getNodeForPath. * return null, if you to create a node use getNodeForPath.
*/ */
private FHTreeStateNode getMapping(TreePath path) { private FHTreeStateNode getMapping(TreePath path) {
return (FHTreeStateNode)treePathMapping.get(path); return treePathMapping.get(path);
} }
/** /**
...@@ -695,13 +695,13 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache { ...@@ -695,13 +695,13 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
return null; return null;
// Check all the parent paths, until a match is found. // Check all the parent paths, until a match is found.
Stack paths; Stack<TreePath> paths;
if(tempStacks.size() == 0) { if(tempStacks.size() == 0) {
paths = new Stack(); paths = new Stack<TreePath>();
} }
else { else {
paths = (Stack)tempStacks.pop(); paths = tempStacks.pop();
} }
try { try {
...@@ -714,7 +714,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache { ...@@ -714,7 +714,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
// Found a match, create entries for all paths in // Found a match, create entries for all paths in
// paths. // paths.
while(node != null && paths.size() > 0) { while(node != null && paths.size() > 0) {
path = (TreePath)paths.pop(); path = paths.pop();
node = node.createChildFor(path. node = node.createChildFor(path.
getLastPathComponent()); getLastPathComponent());
} }
......
...@@ -56,7 +56,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { ...@@ -56,7 +56,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
* The array of nodes that are currently visible, in the order they * The array of nodes that are currently visible, in the order they
* are displayed. * are displayed.
*/ */
private Vector visibleNodes; private Vector<Object> visibleNodes;
/** /**
* This is set to true if one of the entries has an invalid size. * This is set to true if one of the entries has an invalid size.
...@@ -79,20 +79,20 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { ...@@ -79,20 +79,20 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
/** /**
* Maps from <code>TreePath</code> to a <code>TreeStateNode</code>. * Maps from <code>TreePath</code> to a <code>TreeStateNode</code>.
*/ */
private Hashtable treePathMapping; private Hashtable<TreePath, TreeStateNode> treePathMapping;
/** /**
* A stack of stacks. * A stack of stacks.
*/ */
private Stack tempStacks; private Stack<Stack<TreePath>> tempStacks;
public VariableHeightLayoutCache() { public VariableHeightLayoutCache() {
super(); super();
tempStacks = new Stack(); tempStacks = new Stack<Stack<TreePath>>();
visibleNodes = new Vector(); visibleNodes = new Vector<Object>();
boundsBuffer = new Rectangle(); boundsBuffer = new Rectangle();
treePathMapping = new Hashtable(); treePathMapping = new Hashtable<TreePath, TreeStateNode>();
} }
/** /**
...@@ -704,7 +704,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { ...@@ -704,7 +704,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
* return null, if you to create a node use getNodeForPath. * return null, if you to create a node use getNodeForPath.
*/ */
private TreeStateNode getMapping(TreePath path) { private TreeStateNode getMapping(TreePath path) {
return (TreeStateNode)treePathMapping.get(path); return treePathMapping.get(path);
} }
/** /**
...@@ -824,13 +824,13 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { ...@@ -824,13 +824,13 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
} }
// Check all the parent paths, until a match is found. // Check all the parent paths, until a match is found.
Stack paths; Stack<TreePath> paths;
if(tempStacks.size() == 0) { if(tempStacks.size() == 0) {
paths = new Stack(); paths = new Stack<TreePath>();
} }
else { else {
paths = (Stack)tempStacks.pop(); paths = tempStacks.pop();
} }
try { try {
...@@ -843,7 +843,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { ...@@ -843,7 +843,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
// Found a match, create entries for all paths in // Found a match, create entries for all paths in
// paths. // paths.
while(node != null && paths.size() > 0) { while(node != null && paths.size() > 0) {
path = (TreePath)paths.pop(); path = paths.pop();
node.getLoadedChildren(shouldCreate); node.getLoadedChildren(shouldCreate);
int childIndex = treeModel. int childIndex = treeModel.
......
...@@ -116,7 +116,7 @@ public class StateEdit ...@@ -116,7 +116,7 @@ public class StateEdit
protected void init (StateEditable anObject, String name) { protected void init (StateEditable anObject, String name) {
this.object = anObject; this.object = anObject;
this.preState = new Hashtable(11); this.preState = new Hashtable<Object, Object>(11);
this.object.storeState(this.preState); this.object.storeState(this.preState);
this.postState = null; this.postState = null;
this.undoRedoName = name; this.undoRedoName = name;
...@@ -133,7 +133,7 @@ public class StateEdit ...@@ -133,7 +133,7 @@ public class StateEdit
* ends the edit. * ends the edit.
*/ */
public void end() { public void end() {
this.postState = new Hashtable(11); this.postState = new Hashtable<Object, Object>(11);
this.object.storeState(this.postState); this.object.storeState(this.postState);
this.removeRedundantState(); this.removeRedundantState();
} }
...@@ -170,7 +170,7 @@ public class StateEdit ...@@ -170,7 +170,7 @@ public class StateEdit
* Remove redundant key/values in state hashtables. * Remove redundant key/values in state hashtables.
*/ */
protected void removeRedundantState() { protected void removeRedundantState() {
Vector uselessKeys = new Vector(); Vector<Object> uselessKeys = new Vector<Object>();
Enumeration myKeys = preState.keys(); Enumeration myKeys = preState.keys();
// Locate redundant state // Locate redundant state
......
...@@ -166,12 +166,10 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener { ...@@ -166,12 +166,10 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener {
* @see AbstractUndoableEdit#die * @see AbstractUndoableEdit#die
*/ */
public synchronized void discardAllEdits() { public synchronized void discardAllEdits() {
Enumeration cursor = edits.elements(); for (UndoableEdit e : edits) {
while (cursor.hasMoreElements()) {
UndoableEdit e = (UndoableEdit)cursor.nextElement();
e.die(); e.die();
} }
edits = new Vector(); edits = new Vector<UndoableEdit>();
indexOfNextAdd = 0; indexOfNextAdd = 0;
// PENDING(rjrjr) when vector grows a removeRange() method // PENDING(rjrjr) when vector grows a removeRange() method
// (expected in JDK 1.2), trimEdits() will be nice and // (expected in JDK 1.2), trimEdits() will be nice and
...@@ -240,7 +238,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener { ...@@ -240,7 +238,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener {
// System.out.println("Trimming " + from + " " + to + " with index " + // System.out.println("Trimming " + from + " " + to + " with index " +
// indexOfNextAdd); // indexOfNextAdd);
for (int i = to; from <= i; i--) { for (int i = to; from <= i; i--) {
UndoableEdit e = (UndoableEdit)edits.elementAt(i); UndoableEdit e = edits.elementAt(i);
// System.out.println("JUM: Discarding " + // System.out.println("JUM: Discarding " +
// e.getUndoPresentationName()); // e.getUndoPresentationName());
e.die(); e.die();
...@@ -293,7 +291,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener { ...@@ -293,7 +291,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener {
protected UndoableEdit editToBeUndone() { protected UndoableEdit editToBeUndone() {
int i = indexOfNextAdd; int i = indexOfNextAdd;
while (i > 0) { while (i > 0) {
UndoableEdit edit = (UndoableEdit)edits.elementAt(--i); UndoableEdit edit = edits.elementAt(--i);
if (edit.isSignificant()) { if (edit.isSignificant()) {
return edit; return edit;
} }
...@@ -314,7 +312,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener { ...@@ -314,7 +312,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener {
int i = indexOfNextAdd; int i = indexOfNextAdd;
while (i < count) { while (i < count) {
UndoableEdit edit = (UndoableEdit)edits.elementAt(i++); UndoableEdit edit = edits.elementAt(i++);
if (edit.isSignificant()) { if (edit.isSignificant()) {
return edit; return edit;
} }
...@@ -333,7 +331,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener { ...@@ -333,7 +331,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener {
protected void undoTo(UndoableEdit edit) throws CannotUndoException { protected void undoTo(UndoableEdit edit) throws CannotUndoException {
boolean done = false; boolean done = false;
while (!done) { while (!done) {
UndoableEdit next = (UndoableEdit)edits.elementAt(--indexOfNextAdd); UndoableEdit next = edits.elementAt(--indexOfNextAdd);
next.undo(); next.undo();
done = next == edit; done = next == edit;
} }
...@@ -349,7 +347,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener { ...@@ -349,7 +347,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener {
protected void redoTo(UndoableEdit edit) throws CannotRedoException { protected void redoTo(UndoableEdit edit) throws CannotRedoException {
boolean done = false; boolean done = false;
while (!done) { while (!done) {
UndoableEdit next = (UndoableEdit)edits.elementAt(indexOfNextAdd++); UndoableEdit next = edits.elementAt(indexOfNextAdd++);
next.redo(); next.redo();
done = next == edit; done = next == edit;
} }
......
...@@ -89,8 +89,7 @@ public class UndoableEditSupport { ...@@ -89,8 +89,7 @@ public class UndoableEditSupport {
* @since 1.4 * @since 1.4
*/ */
public synchronized UndoableEditListener[] getUndoableEditListeners() { public synchronized UndoableEditListener[] getUndoableEditListeners() {
return (UndoableEditListener[])(listeners.toArray( return listeners.toArray(new UndoableEditListener[0]);
new UndoableEditListener[0]));
} }
/** /**
......
...@@ -114,7 +114,7 @@ public class AccessibleMethod { ...@@ -114,7 +114,7 @@ public class AccessibleMethod {
/** The action used to fetch the method and make it accessible */ /** The action used to fetch the method and make it accessible */
private static class AccessMethodAction implements PrivilegedExceptionAction<Method> { private static class AccessMethodAction implements PrivilegedExceptionAction<Method> {
private final Class klass; private final Class<?> klass;
private final String methodName; private final String methodName;
private final Class[] paramTypes; private final Class[] paramTypes;
......
...@@ -546,8 +546,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { ...@@ -546,8 +546,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
public static void addActionsToMap(ActionMap map, Action[] actions) { public static void addActionsToMap(ActionMap map, Action[] actions) {
if (map != null && actions != null) { if (map != null && actions != null) {
for (int i = 0; i < actions.length; i++) { for (Action a : actions) {
Action a = actions[i];
String cmd = (String)a.getValue(Action.ACTION_COMMAND_KEY); String cmd = (String)a.getValue(Action.ACTION_COMMAND_KEY);
if (cmd == null) { if (cmd == null) {
cmd = (String)a.getValue(Action.NAME); cmd = (String)a.getValue(Action.NAME);
...@@ -715,13 +714,13 @@ public class FilePane extends JPanel implements PropertyChangeListener { ...@@ -715,13 +714,13 @@ public class FilePane extends JPanel implements PropertyChangeListener {
visibleColumns.toArray(columns); visibleColumns.toArray(columns);
columnMap = Arrays.copyOf(columnMap, columns.length); columnMap = Arrays.copyOf(columnMap, columns.length);
List<RowSorter.SortKey> sortKeys = List<? extends RowSorter.SortKey> sortKeys =
(rowSorter == null) ? null : rowSorter.getSortKeys(); (rowSorter == null) ? null : rowSorter.getSortKeys();
fireTableStructureChanged(); fireTableStructureChanged();
restoreSortKeys(sortKeys); restoreSortKeys(sortKeys);
} }
private void restoreSortKeys(List<RowSorter.SortKey> sortKeys) { private void restoreSortKeys(List<? extends RowSorter.SortKey> sortKeys) {
if (sortKeys != null) { if (sortKeys != null) {
// check if preserved sortKeys are valid for this folder // check if preserved sortKeys are valid for this folder
for (int i = 0; i < sortKeys.size(); i++) { for (int i = 0; i < sortKeys.size(); i++) {
...@@ -886,7 +885,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { ...@@ -886,7 +885,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
return rowSorter; return rowSorter;
} }
private class DetailsTableRowSorter extends TableRowSorter { private class DetailsTableRowSorter extends TableRowSorter<TableModel> {
public DetailsTableRowSorter() { public DetailsTableRowSorter() {
setModelWrapper(new SorterModelWrapper()); setModelWrapper(new SorterModelWrapper());
} }
...@@ -906,8 +905,8 @@ public class FilePane extends JPanel implements PropertyChangeListener { ...@@ -906,8 +905,8 @@ public class FilePane extends JPanel implements PropertyChangeListener {
updateComparators(detailsTableModel.getColumns()); updateComparators(detailsTableModel.getColumns());
} }
private class SorterModelWrapper extends ModelWrapper { private class SorterModelWrapper extends ModelWrapper<TableModel, Integer> {
public Object getModel() { public TableModel getModel() {
return getDetailsTableModel(); return getDetailsTableModel();
} }
...@@ -923,7 +922,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { ...@@ -923,7 +922,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
return FilePane.this.getModel().getElementAt(row); return FilePane.this.getModel().getElementAt(row);
} }
public Object getIdentifier(int row) { public Integer getIdentifier(int row) {
return row; return row;
} }
} }
...@@ -1718,9 +1717,9 @@ public class FilePane extends JPanel implements PropertyChangeListener { ...@@ -1718,9 +1717,9 @@ public class FilePane extends JPanel implements PropertyChangeListener {
private void updateViewMenu() { private void updateViewMenu() {
if (viewMenu != null) { if (viewMenu != null) {
Component[] comps = viewMenu.getMenuComponents(); Component[] comps = viewMenu.getMenuComponents();
for (int i = 0; i < comps.length; i++) { for (Component comp : comps) {
if (comps[i] instanceof JRadioButtonMenuItem) { if (comp instanceof JRadioButtonMenuItem) {
JRadioButtonMenuItem mi = (JRadioButtonMenuItem)comps[i]; JRadioButtonMenuItem mi = (JRadioButtonMenuItem) comp;
if (((ViewTypeAction)mi.getAction()).viewType == viewType) { if (((ViewTypeAction)mi.getAction()).viewType == viewType) {
mi.setSelected(true); mi.setSelected(true);
} }
......
...@@ -54,15 +54,14 @@ public class SwingLazyValue implements UIDefaults.LazyValue { ...@@ -54,15 +54,14 @@ public class SwingLazyValue implements UIDefaults.LazyValue {
className = c; className = c;
methodName = m; methodName = m;
if (o != null) { if (o != null) {
args = (Object[])o.clone(); args = o.clone();
} }
} }
public Object createValue(final UIDefaults table) { public Object createValue(final UIDefaults table) {
try { try {
Class c;
Object cl; Object cl;
c = Class.forName(className, true, null); Class<?> c = Class.forName(className, true, null);
if (methodName != null) { if (methodName != null) {
Class[] types = getClassArray(args); Class[] types = getClassArray(args);
Method m = c.getMethod(methodName, types); Method m = c.getMethod(methodName, types);
......
...@@ -460,7 +460,7 @@ public class SwingUtilities2 { ...@@ -460,7 +460,7 @@ public class SwingUtilities2 {
return clipString; return clipString;
} }
boolean needsTextLayout = false; boolean needsTextLayout;
synchronized (charsBufferLock) { synchronized (charsBufferLock) {
if (charsBuffer == null || charsBuffer.length < stringLength) { if (charsBuffer == null || charsBuffer.length < stringLength) {
...@@ -715,11 +715,8 @@ public class SwingUtilities2 { ...@@ -715,11 +715,8 @@ public class SwingUtilities2 {
// See if coords are inside // See if coords are inside
// ASSUME: mouse x,y will never be < cell's x,y // ASSUME: mouse x,y will never be < cell's x,y
assert (p.x >= cellBounds.x && p.y >= cellBounds.y); assert (p.x >= cellBounds.x && p.y >= cellBounds.y);
if (p.x > cellBounds.x + cellBounds.width || return p.x > cellBounds.x + cellBounds.width ||
p.y > cellBounds.y + cellBounds.height) { p.y > cellBounds.y + cellBounds.height;
return true;
}
return false;
} }
/** /**
...@@ -1239,12 +1236,11 @@ public class SwingUtilities2 { ...@@ -1239,12 +1236,11 @@ public class SwingUtilities2 {
private static synchronized boolean inputEvent_canAccessSystemClipboard(InputEvent ie) { private static synchronized boolean inputEvent_canAccessSystemClipboard(InputEvent ie) {
if (inputEvent_CanAccessSystemClipboard_Field == null) { if (inputEvent_CanAccessSystemClipboard_Field == null) {
inputEvent_CanAccessSystemClipboard_Field = inputEvent_CanAccessSystemClipboard_Field =
(Field)AccessController.doPrivileged( AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Field>() {
public Object run() { public Field run() {
Field field = null;
try { try {
field = InputEvent.class. Field field = InputEvent.class.
getDeclaredField("canAccessSystemClipboard"); getDeclaredField("canAccessSystemClipboard");
field.setAccessible(true); field.setAccessible(true);
return field; return field;
...@@ -1419,10 +1415,10 @@ public class SwingUtilities2 { ...@@ -1419,10 +1415,10 @@ public class SwingUtilities2 {
* Class.getResourceAsStream just returns raw * Class.getResourceAsStream just returns raw
* bytes, which we can convert to an image. * bytes, which we can convert to an image.
*/ */
byte[] buffer = (byte[]) byte[] buffer =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<byte[]>() {
public Object run() { public byte[] run() {
try { try {
InputStream resource = null; InputStream resource = null;
Class<?> srchClass = baseClass; Class<?> srchClass = baseClass;
...@@ -1489,7 +1485,7 @@ public class SwingUtilities2 { ...@@ -1489,7 +1485,7 @@ public class SwingUtilities2 {
return true; return true;
} }
// Else probably Solaris or Linux in which case may be remote X11 // Else probably Solaris or Linux in which case may be remote X11
Class x11Class = Class.forName("sun.awt.X11GraphicsEnvironment"); Class<?> x11Class = Class.forName("sun.awt.X11GraphicsEnvironment");
Method isDisplayLocalMethod = x11Class.getMethod( Method isDisplayLocalMethod = x11Class.getMethod(
"isDisplayLocal", new Class[0]); "isDisplayLocal", new Class[0]);
return (Boolean)isDisplayLocalMethod.invoke(null, (Object[])null); return (Boolean)isDisplayLocalMethod.invoke(null, (Object[])null);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册