提交 852d7734 编写于 作者: R rupashka

6727661: Code improvement and warnings removing from the swing/plaf packages

Summary: Removed unnecessary castings and other warnings
Reviewed-by: alexp
Contributed-by: NFlorian Brunner <fbrunnerlist@gmx.ch>
上级 b819df42
...@@ -49,8 +49,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue { ...@@ -49,8 +49,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/** /**
* ReferenceQueue of unreferenced WeakPCLs. * ReferenceQueue of unreferenced WeakPCLs.
*/ */
private static ReferenceQueue queue; private static ReferenceQueue<DesktopProperty> queue;
/** /**
* PropertyChangeListener attached to the Toolkit. * PropertyChangeListener attached to the Toolkit.
...@@ -76,7 +75,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue { ...@@ -76,7 +75,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
static { static {
queue = new ReferenceQueue(); queue = new ReferenceQueue<DesktopProperty>();
} }
/** /**
...@@ -117,8 +116,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue { ...@@ -117,8 +116,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
XPStyle.invalidateStyle(); XPStyle.invalidateStyle();
} }
Frame appFrames[] = Frame.getFrames(); Frame appFrames[] = Frame.getFrames();
for (int j=0; j < appFrames.length; j++) { for (Frame appFrame : appFrames) {
updateWindowUI(appFrames[j]); updateWindowUI(appFrame);
} }
} }
...@@ -128,8 +127,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue { ...@@ -128,8 +127,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
private static void updateWindowUI(Window window) { private static void updateWindowUI(Window window) {
SwingUtilities.updateComponentTreeUI(window); SwingUtilities.updateComponentTreeUI(window);
Window ownedWins[] = window.getOwnedWindows(); Window ownedWins[] = window.getOwnedWindows();
for (int i=0; i < ownedWins.length; i++) { for (Window ownedWin : ownedWins) {
updateWindowUI(ownedWins[i]); updateWindowUI(ownedWin);
} }
} }
...@@ -270,13 +269,13 @@ public class DesktopProperty implements UIDefaults.ActiveValue { ...@@ -270,13 +269,13 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
* is handled via a WeakReference so as not to pin down the * is handled via a WeakReference so as not to pin down the
* DesktopProperty. * DesktopProperty.
*/ */
private static class WeakPCL extends WeakReference private static class WeakPCL extends WeakReference<DesktopProperty>
implements PropertyChangeListener { implements PropertyChangeListener {
private Toolkit kit; private Toolkit kit;
private String key; private String key;
private LookAndFeel laf; private LookAndFeel laf;
WeakPCL(Object target, Toolkit kit, String key, LookAndFeel laf) { WeakPCL(DesktopProperty target, Toolkit kit, String key, LookAndFeel laf) {
super(target, queue); super(target, queue);
this.kit = kit; this.kit = kit;
this.key = key; this.key = key;
...@@ -284,7 +283,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue { ...@@ -284,7 +283,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
} }
public void propertyChange(PropertyChangeEvent pce) { public void propertyChange(PropertyChangeEvent pce) {
DesktopProperty property = (DesktopProperty)get(); DesktopProperty property = get();
if (property == null || laf != UIManager.getLookAndFeel()) { if (property == null || laf != UIManager.getLookAndFeel()) {
// The property was GC'ed, we're no longer interested in // The property was GC'ed, we're no longer interested in
......
...@@ -96,7 +96,7 @@ public class WindowsDesktopManager extends DefaultDesktopManager ...@@ -96,7 +96,7 @@ public class WindowsDesktopManager extends DefaultDesktopManager
} }
} catch (PropertyVetoException e) {} } catch (PropertyVetoException e) {}
if (f != currentFrame) { if (f != currentFrame) {
currentFrameRef = new WeakReference(f); currentFrameRef = new WeakReference<JInternalFrame>(f);
} }
} }
......
...@@ -983,7 +983,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI { ...@@ -983,7 +983,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
} else if (s.equals("componentOrientation")) { } else if (s.equals("componentOrientation")) {
ComponentOrientation o = (ComponentOrientation)e.getNewValue(); ComponentOrientation o = (ComponentOrientation)e.getNewValue();
JFileChooser cc = (JFileChooser)e.getSource(); JFileChooser cc = (JFileChooser)e.getSource();
if (o != (ComponentOrientation)e.getOldValue()) { if (o != e.getOldValue()) {
cc.applyComponentOrientation(o); cc.applyComponentOrientation(o);
} }
} else if (s.equals("ancestor")) { } else if (s.equals("ancestor")) {
...@@ -1123,7 +1123,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI { ...@@ -1123,7 +1123,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
* Data model for a type-face selection combo-box. * Data model for a type-face selection combo-box.
*/ */
protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel { protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
Vector directories = new Vector(); Vector<File> directories = new Vector<File>();
int[] depths = null; int[] depths = null;
File selectedDirectory = null; File selectedDirectory = null;
JFileChooser chooser = getFileChooser(); JFileChooser chooser = getFileChooser();
...@@ -1162,7 +1162,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI { ...@@ -1162,7 +1162,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
// Get the canonical (full) path. This has the side // Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path, // benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar // for example /foo/bar/ becomes /foo/bar
File canonical = null; File canonical;
try { try {
canonical = directory.getCanonicalFile(); canonical = directory.getCanonicalFile();
} catch (IOException e) { } catch (IOException e) {
...@@ -1175,7 +1175,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI { ...@@ -1175,7 +1175,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical) File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical; : canonical;
File f = sf; File f = sf;
Vector path = new Vector(10); Vector<File> path = new Vector<File>(10);
do { do {
path.addElement(f); path.addElement(f);
} while ((f = f.getParentFile()) != null); } while ((f = f.getParentFile()) != null);
...@@ -1183,7 +1183,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI { ...@@ -1183,7 +1183,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
int pathCount = path.size(); int pathCount = path.size();
// Insert chain at appropriate place in vector // Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) { for (int i = 0; i < pathCount; i++) {
f = (File)path.get(i); f = path.get(i);
if (directories.contains(f)) { if (directories.contains(f)) {
int topIndex = directories.indexOf(f); int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) { for (int j = i-1; j >= 0; j--) {
...@@ -1202,12 +1202,12 @@ public class WindowsFileChooserUI extends BasicFileChooserUI { ...@@ -1202,12 +1202,12 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
private void calculateDepths() { private void calculateDepths() {
depths = new int[directories.size()]; depths = new int[directories.size()];
for (int i = 0; i < depths.length; i++) { for (int i = 0; i < depths.length; i++) {
File dir = (File)directories.get(i); File dir = directories.get(i);
File parent = dir.getParentFile(); File parent = dir.getParentFile();
depths[i] = 0; depths[i] = 0;
if (parent != null) { if (parent != null) {
for (int j = i-1; j >= 0; j--) { for (int j = i-1; j >= 0; j--) {
if (parent.equals((File)directories.get(j))) { if (parent.equals(directories.get(j))) {
depths[i] = depths[j] + 1; depths[i] = depths[j] + 1;
break; break;
} }
...@@ -1306,8 +1306,8 @@ public class WindowsFileChooserUI extends BasicFileChooserUI { ...@@ -1306,8 +1306,8 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
FileFilter currentFilter = getFileChooser().getFileFilter(); FileFilter currentFilter = getFileChooser().getFileFilter();
boolean found = false; boolean found = false;
if(currentFilter != null) { if(currentFilter != null) {
for(int i=0; i < filters.length; i++) { for (FileFilter filter : filters) {
if(filters[i] == currentFilter) { if (filter == currentFilter) {
found = true; found = true;
} }
} }
......
...@@ -258,8 +258,8 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane { ...@@ -258,8 +258,8 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
g.fillRect(0, 0, w, h); g.fillRect(0, 0, w, h);
} }
Icon icon = getIcon(); Icon icon = getIcon();
int iconWidth = 0; int iconWidth;
int iconHeight = 0; int iconHeight;
if (icon != null && if (icon != null &&
(iconWidth = icon.getIconWidth()) > 0 && (iconWidth = icon.getIconWidth()) > 0 &&
(iconHeight = icon.getIconHeight()) > 0) { (iconHeight = icon.getIconHeight()) > 0) {
...@@ -304,18 +304,18 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane { ...@@ -304,18 +304,18 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
} }
protected void addSystemMenuItems(JPopupMenu menu) { protected void addSystemMenuItems(JPopupMenu menu) {
JMenuItem mi = (JMenuItem)menu.add(restoreAction); JMenuItem mi = menu.add(restoreAction);
mi.setMnemonic('R'); mi.setMnemonic('R');
mi = (JMenuItem)menu.add(moveAction); mi = menu.add(moveAction);
mi.setMnemonic('M'); mi.setMnemonic('M');
mi = (JMenuItem)menu.add(sizeAction); mi = menu.add(sizeAction);
mi.setMnemonic('S'); mi.setMnemonic('S');
mi = (JMenuItem)menu.add(iconifyAction); mi = menu.add(iconifyAction);
mi.setMnemonic('n'); mi.setMnemonic('n');
mi = (JMenuItem)menu.add(maximizeAction); mi = menu.add(maximizeAction);
mi.setMnemonic('x'); mi.setMnemonic('x');
systemPopupMenu.add(new JSeparator()); systemPopupMenu.add(new JSeparator());
mi = (JMenuItem)menu.add(closeAction); mi = menu.add(closeAction);
mi.setMnemonic('C'); mi.setMnemonic('C');
} }
...@@ -441,7 +441,7 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane { ...@@ -441,7 +441,7 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
public class WindowsPropertyChangeHandler extends PropertyChangeHandler { public class WindowsPropertyChangeHandler extends PropertyChangeHandler {
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
String prop = (String)evt.getPropertyName(); String prop = evt.getPropertyName();
// Update the internal frame icon for the system menu. // Update the internal frame icon for the system menu.
if (JInternalFrame.FRAME_ICON_PROPERTY.equals(prop) && if (JInternalFrame.FRAME_ICON_PROPERTY.equals(prop) &&
......
...@@ -369,21 +369,21 @@ public class WindowsScrollBarUI extends BasicScrollBarUI { ...@@ -369,21 +369,21 @@ public class WindowsScrollBarUI extends BasicScrollBarUI {
*/ */
private static class Grid { private static class Grid {
private static final int BUFFER_SIZE = 64; private static final int BUFFER_SIZE = 64;
private static HashMap map; private static HashMap<String, WeakReference<Grid>> map;
private BufferedImage image; private BufferedImage image;
static { static {
map = new HashMap(); map = new HashMap<String, WeakReference<Grid>>();
} }
public static Grid getGrid(Color fg, Color bg) { public static Grid getGrid(Color fg, Color bg) {
String key = fg.getRGB() + " " + bg.getRGB(); String key = fg.getRGB() + " " + bg.getRGB();
WeakReference ref = (WeakReference)map.get(key); WeakReference<Grid> ref = map.get(key);
Grid grid = (ref == null) ? null : (Grid)ref.get(); Grid grid = (ref == null) ? null : ref.get();
if (grid == null) { if (grid == null) {
grid = new Grid(fg, bg); grid = new Grid(fg, bg);
map.put(key, new WeakReference(grid)); map.put(key, new WeakReference<Grid>(grid));
} }
return grid; return grid;
} }
......
...@@ -53,13 +53,13 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI { ...@@ -53,13 +53,13 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
* Keys to use for forward focus traversal when the JComponent is * Keys to use for forward focus traversal when the JComponent is
* managing focus. * managing focus.
*/ */
private static Set managingFocusForwardTraversalKeys; private static Set<KeyStroke> managingFocusForwardTraversalKeys;
/** /**
* Keys to use for backward focus traversal when the JComponent is * Keys to use for backward focus traversal when the JComponent is
* managing focus. * managing focus.
*/ */
private static Set managingFocusBackwardTraversalKeys; private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
private boolean contentOpaque = true; private boolean contentOpaque = true;
...@@ -69,13 +69,13 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI { ...@@ -69,13 +69,13 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
// focus forward traversal key // focus forward traversal key
if (managingFocusForwardTraversalKeys==null) { if (managingFocusForwardTraversalKeys==null) {
managingFocusForwardTraversalKeys = new HashSet(); managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
} }
tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys); tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
// focus backward traversal key // focus backward traversal key
if (managingFocusBackwardTraversalKeys==null) { if (managingFocusBackwardTraversalKeys==null) {
managingFocusBackwardTraversalKeys = new HashSet(); managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusBackwardTraversalKeys.add( KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK)); managingFocusBackwardTraversalKeys.add( KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
} }
tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys); tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);
......
...@@ -165,7 +165,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener, ...@@ -165,7 +165,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
JRootPane root = b.getRootPane(); JRootPane root = b.getRootPane();
if (root != null) { if (root != null) {
BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType( BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType(
((AbstractButton)b).getUI(), BasicButtonUI.class); b.getUI(), BasicButtonUI.class);
if (ui != null && DefaultLookup.getBoolean(b, ui, if (ui != null && DefaultLookup.getBoolean(b, ui,
ui.getPropertyPrefix() + ui.getPropertyPrefix() +
"defaultButtonFollowsFocus", true)) { "defaultButtonFollowsFocus", true)) {
...@@ -185,7 +185,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener, ...@@ -185,7 +185,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
JButton initialDefault = (JButton)root.getClientProperty("initialDefaultButton"); JButton initialDefault = (JButton)root.getClientProperty("initialDefaultButton");
if (b != initialDefault) { if (b != initialDefault) {
BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType( BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType(
((AbstractButton)b).getUI(), BasicButtonUI.class); b.getUI(), BasicButtonUI.class);
if (ui != null && DefaultLookup.getBoolean(b, ui, if (ui != null && DefaultLookup.getBoolean(b, ui,
ui.getPropertyPrefix() + ui.getPropertyPrefix() +
"defaultButtonFollowsFocus", true)) { "defaultButtonFollowsFocus", true)) {
...@@ -239,7 +239,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener, ...@@ -239,7 +239,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
} }
} }
} }
}; }
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) { if (SwingUtilities.isLeftMouseButton(e)) {
...@@ -253,7 +253,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener, ...@@ -253,7 +253,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
model.setPressed(false); model.setPressed(false);
model.setArmed(false); model.setArmed(false);
} }
}; }
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
AbstractButton b = (AbstractButton) e.getSource(); AbstractButton b = (AbstractButton) e.getSource();
...@@ -263,7 +263,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener, ...@@ -263,7 +263,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
} }
if (model.isPressed()) if (model.isPressed())
model.setArmed(true); model.setArmed(true);
}; }
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
AbstractButton b = (AbstractButton) e.getSource(); AbstractButton b = (AbstractButton) e.getSource();
...@@ -272,7 +272,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener, ...@@ -272,7 +272,7 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
model.setRollover(false); model.setRollover(false);
} }
model.setArmed(false); model.setArmed(false);
}; }
/** /**
......
...@@ -237,7 +237,7 @@ public class BasicButtonUI extends ButtonUI{ ...@@ -237,7 +237,7 @@ public class BasicButtonUI extends ButtonUI{
/* the fallback icon should be based on the selected state */ /* the fallback icon should be based on the selected state */
if (model.isSelected()) { if (model.isSelected()) {
selectedIcon = (Icon) b.getSelectedIcon(); selectedIcon = b.getSelectedIcon();
if (selectedIcon != null) { if (selectedIcon != null) {
icon = selectedIcon; icon = selectedIcon;
} }
...@@ -245,31 +245,31 @@ public class BasicButtonUI extends ButtonUI{ ...@@ -245,31 +245,31 @@ public class BasicButtonUI extends ButtonUI{
if(!model.isEnabled()) { if(!model.isEnabled()) {
if(model.isSelected()) { if(model.isSelected()) {
tmpIcon = (Icon) b.getDisabledSelectedIcon(); tmpIcon = b.getDisabledSelectedIcon();
if (tmpIcon == null) { if (tmpIcon == null) {
tmpIcon = selectedIcon; tmpIcon = selectedIcon;
} }
} }
if (tmpIcon == null) { if (tmpIcon == null) {
tmpIcon = (Icon) b.getDisabledIcon(); tmpIcon = b.getDisabledIcon();
} }
} else if(model.isPressed() && model.isArmed()) { } else if(model.isPressed() && model.isArmed()) {
tmpIcon = (Icon) b.getPressedIcon(); tmpIcon = b.getPressedIcon();
if(tmpIcon != null) { if(tmpIcon != null) {
// revert back to 0 offset // revert back to 0 offset
clearTextShiftOffset(); clearTextShiftOffset();
} }
} else if(b.isRolloverEnabled() && model.isRollover()) { } else if(b.isRolloverEnabled() && model.isRollover()) {
if(model.isSelected()) { if(model.isSelected()) {
tmpIcon = (Icon) b.getRolloverSelectedIcon(); tmpIcon = b.getRolloverSelectedIcon();
if (tmpIcon == null) { if (tmpIcon == null) {
tmpIcon = selectedIcon; tmpIcon = selectedIcon;
} }
} }
if (tmpIcon == null) { if (tmpIcon == null) {
tmpIcon = (Icon) b.getRolloverIcon(); tmpIcon = b.getRolloverIcon();
} }
} }
...@@ -451,9 +451,9 @@ public class BasicButtonUI extends ButtonUI{ ...@@ -451,9 +451,9 @@ public class BasicButtonUI extends ButtonUI{
MouseMotionListener[] listeners = b.getMouseMotionListeners(); MouseMotionListener[] listeners = b.getMouseMotionListeners();
if (listeners != null) { if (listeners != null) {
for (int counter = 0; counter < listeners.length; counter++) { for (MouseMotionListener listener : listeners) {
if (listeners[counter] instanceof BasicButtonListener) { if (listener instanceof BasicButtonListener) {
return (BasicButtonListener)listeners[counter]; return (BasicButtonListener) listener;
} }
} }
} }
......
...@@ -92,7 +92,7 @@ public class BasicComboBoxEditor implements ComboBoxEditor,FocusListener { ...@@ -92,7 +92,7 @@ public class BasicComboBoxEditor implements ComboBoxEditor,FocusListener {
return oldValue; return oldValue;
} else { } else {
// Must take the value from the editor and get the value and cast it to the new type. // Must take the value from the editor and get the value and cast it to the new type.
Class cls = oldValue.getClass(); Class<?> cls = oldValue.getClass();
try { try {
Method method = cls.getMethod("valueOf", new Class[]{String.class}); Method method = cls.getMethod("valueOf", new Class[]{String.class});
newValue = method.invoke(oldValue, new Object[] { editor.getText()}); newValue = method.invoke(oldValue, new Object[] { editor.getText()});
......
...@@ -43,10 +43,10 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -43,10 +43,10 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
private JFileChooser filechooser = null; private JFileChooser filechooser = null;
// PENDING(jeff) pick the size more sensibly // PENDING(jeff) pick the size more sensibly
private Vector fileCache = new Vector(50); private Vector<File> fileCache = new Vector<File>(50);
private LoadFilesThread loadThread = null; private LoadFilesThread loadThread = null;
private Vector files = null; private Vector<File> files = null;
private Vector directories = null; private Vector<File> directories = null;
private int fetchID = 0; private int fetchID = 0;
private PropertyChangeSupport changeSupport; private PropertyChangeSupport changeSupport;
...@@ -106,14 +106,14 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -106,14 +106,14 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
if (files != null) { if (files != null) {
return files; return files;
} }
files = new Vector(); files = new Vector<File>();
directories = new Vector(); directories = new Vector<File>();
directories.addElement(filechooser.getFileSystemView().createFileObject( directories.addElement(filechooser.getFileSystemView().createFileObject(
filechooser.getCurrentDirectory(), "..") filechooser.getCurrentDirectory(), "..")
); );
for (int i = 0; i < getSize(); i++) { for (int i = 0; i < getSize(); i++) {
File f = (File)fileCache.get(i); File f = fileCache.get(i);
if (filechooser.isTraversable(f)) { if (filechooser.isTraversable(f)) {
directories.add(f); directories.add(f);
} else { } else {
...@@ -215,7 +215,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -215,7 +215,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
class LoadFilesThread extends Thread { class LoadFilesThread extends Thread {
File currentDirectory = null; File currentDirectory = null;
int fid; int fid;
Vector runnables = new Vector(10); Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
public LoadFilesThread(File currentDirectory, int fid) { public LoadFilesThread(File currentDirectory, int fid) {
super("Basic L&F File Loading Thread"); super("Basic L&F File Loading Thread");
...@@ -223,7 +223,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -223,7 +223,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
this.fid = fid; this.fid = fid;
} }
private void invokeLater(Runnable runnable) { private void invokeLater(DoChangeContents runnable) {
runnables.addElement(runnable); runnables.addElement(runnable);
SwingUtilities.invokeLater(runnable); SwingUtilities.invokeLater(runnable);
} }
...@@ -245,9 +245,9 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -245,9 +245,9 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
} }
// run through the file list, add directories and selectable files to fileCache // run through the file list, add directories and selectable files to fileCache
for (int i = 0; i < list.length; i++) { for (File file : list) {
if(filechooser.accept(list[i])) { if (filechooser.accept(file)) {
acceptsList.addElement(list[i]); acceptsList.addElement(file);
} }
} }
...@@ -258,11 +258,11 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -258,11 +258,11 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
// First sort alphabetically by filename // First sort alphabetically by filename
sort(acceptsList); sort(acceptsList);
Vector newDirectories = new Vector(50); Vector<File> newDirectories = new Vector<File>(50);
Vector newFiles = new Vector(); Vector<File> newFiles = new Vector<File>();
// run through list grabbing directories in chunks of ten // run through list grabbing directories in chunks of ten
for(int i = 0; i < acceptsList.size(); i++) { for(int i = 0; i < acceptsList.size(); i++) {
File f = (File) acceptsList.elementAt(i); File f = acceptsList.elementAt(i);
boolean isTraversable = filechooser.isTraversable(f); boolean isTraversable = filechooser.isTraversable(f);
if (isTraversable) { if (isTraversable) {
newDirectories.addElement(f); newDirectories.addElement(f);
...@@ -274,7 +274,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -274,7 +274,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
} }
} }
Vector newFileCache = new Vector(newDirectories); Vector<File> newFileCache = new Vector<File>(newDirectories);
newFileCache.addAll(newFiles); newFileCache.addAll(newFiles);
int newSize = newFileCache.size(); int newSize = newFileCache.size();
...@@ -320,7 +320,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -320,7 +320,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
if(isInterrupted()) { if(isInterrupted()) {
return; return;
} }
invokeLater(new DoChangeContents(null, 0, new Vector(fileCache.subList(start, end)), invokeLater(new DoChangeContents(null, 0, new Vector<File>(fileCache.subList(start, end)),
start, fid)); start, fid));
newFileCache = null; newFileCache = null;
} }
...@@ -334,9 +334,9 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -334,9 +334,9 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
} }
public void cancelRunnables(Vector runnables) { public void cancelRunnables(Vector<DoChangeContents> runnables) {
for(int i = 0; i < runnables.size(); i++) { for (DoChangeContents runnable : runnables) {
((DoChangeContents)runnables.elementAt(i)).cancel(); runnable.cancel();
} }
} }
...@@ -449,15 +449,14 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh ...@@ -449,15 +449,14 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
class DoChangeContents implements Runnable { class DoChangeContents implements Runnable {
private List addFiles; private List<File> addFiles;
private List remFiles; private List<File> remFiles;
private boolean doFire = true; private boolean doFire = true;
private int fid; private int fid;
private int addStart = 0; private int addStart = 0;
private int remStart = 0; private int remStart = 0;
private int change;
public DoChangeContents(List addFiles, int addStart, List remFiles, int remStart, int fid) { public DoChangeContents(List<File> addFiles, int addStart, List<File> remFiles, int remStart, int fid) {
this.addFiles = addFiles; this.addFiles = addFiles;
this.addStart = addStart; this.addStart = addStart;
this.remFiles = remFiles; this.remFiles = remFiles;
......
...@@ -159,9 +159,9 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -159,9 +159,9 @@ public class BasicFileChooserUI extends FileChooserUI {
} }
public void uninstallUI(JComponent c) { public void uninstallUI(JComponent c) {
uninstallListeners((JFileChooser) filechooser); uninstallListeners(filechooser);
uninstallComponents((JFileChooser) filechooser); uninstallComponents(filechooser);
uninstallDefaults((JFileChooser) filechooser); uninstallDefaults(filechooser);
if(accessoryPanel != null) { if(accessoryPanel != null) {
accessoryPanel.removeAll(); accessoryPanel.removeAll();
...@@ -506,9 +506,9 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -506,9 +506,9 @@ public class BasicFileChooserUI extends FileChooserUI {
setDirectorySelected(true); setDirectorySelected(true);
setDirectory(((File)objects[0])); setDirectory(((File)objects[0]));
} else { } else {
ArrayList fList = new ArrayList(objects.length); ArrayList<File> fList = new ArrayList<File>(objects.length);
for (int i = 0; i < objects.length; i++) { for (Object object : objects) {
File f = (File)objects[i]; File f = (File) object;
boolean isDir = f.isDirectory(); boolean isDir = f.isDirectory();
if ((chooser.isFileSelectionEnabled() && !isDir) if ((chooser.isFileSelectionEnabled() && !isDir)
|| (chooser.isDirectorySelectionEnabled() || (chooser.isDirectorySelectionEnabled()
...@@ -518,7 +518,7 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -518,7 +518,7 @@ public class BasicFileChooserUI extends FileChooserUI {
} }
} }
if (fList.size() > 0) { if (fList.size() > 0) {
files = (File[])fList.toArray(new File[fList.size()]); files = fList.toArray(new File[fList.size()]);
} }
setDirectorySelected(false); setDirectorySelected(false);
} }
...@@ -853,7 +853,7 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -853,7 +853,7 @@ public class BasicFileChooserUI extends FileChooserUI {
} }
if (chooser.isMultiSelectionEnabled() && filename.startsWith("\"")) { if (chooser.isMultiSelectionEnabled() && filename.startsWith("\"")) {
ArrayList fList = new ArrayList(); ArrayList<File> fList = new ArrayList<File>();
filename = filename.substring(1); filename = filename.substring(1);
if (filename.endsWith("\"")) { if (filename.endsWith("\"")) {
...@@ -889,7 +889,7 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -889,7 +889,7 @@ public class BasicFileChooserUI extends FileChooserUI {
fList.add(file); fList.add(file);
} while (filename.length() > 0); } while (filename.length() > 0);
if (fList.size() > 0) { if (fList.size() > 0) {
selectedFiles = (File[])fList.toArray(new File[fList.size()]); selectedFiles = fList.toArray(new File[fList.size()]);
} }
resetGlobFilter(); resetGlobFilter();
} else { } else {
...@@ -1213,7 +1213,7 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -1213,7 +1213,7 @@ public class BasicFileChooserUI extends FileChooserUI {
} }
public Icon getCachedIcon(File f) { public Icon getCachedIcon(File f) {
return (Icon) iconCache.get(f); return iconCache.get(f);
} }
public void cacheIcon(File f, Icon i) { public void cacheIcon(File f, Icon i) {
...@@ -1296,8 +1296,7 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -1296,8 +1296,7 @@ public class BasicFileChooserUI extends FileChooserUI {
htmlBuf.append("<html>\n<body>\n<ul>\n"); htmlBuf.append("<html>\n<body>\n<ul>\n");
for (int i = 0; i < values.length; i++) { for (Object obj : values) {
Object obj = values[i];
String val = ((obj == null) ? "" : obj.toString()); String val = ((obj == null) ? "" : obj.toString());
plainBuf.append(val + "\n"); plainBuf.append(val + "\n");
htmlBuf.append(" <li>" + val + "\n"); htmlBuf.append(" <li>" + val + "\n");
...@@ -1337,9 +1336,9 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -1337,9 +1336,9 @@ public class BasicFileChooserUI extends FileChooserUI {
*/ */
protected Object getRicherData(DataFlavor flavor) { protected Object getRicherData(DataFlavor flavor) {
if (DataFlavor.javaFileListFlavor.equals(flavor)) { if (DataFlavor.javaFileListFlavor.equals(flavor)) {
ArrayList files = new ArrayList(); ArrayList<Object> files = new ArrayList<Object>();
for (int i = 0; i < fileData.length; i++) { for (Object file : this.fileData) {
files.add(fileData[i]); files.add(file);
} }
return files; return files;
} }
......
...@@ -266,7 +266,7 @@ public class BasicGraphicsUtils ...@@ -266,7 +266,7 @@ public class BasicGraphicsUtils
return null; return null;
} }
Icon icon = (Icon) b.getIcon(); Icon icon = b.getIcon();
String text = b.getText(); String text = b.getText();
Font font = b.getFont(); Font font = b.getFont();
...@@ -277,7 +277,7 @@ public class BasicGraphicsUtils ...@@ -277,7 +277,7 @@ public class BasicGraphicsUtils
Rectangle viewR = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE); Rectangle viewR = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE);
SwingUtilities.layoutCompoundLabel( SwingUtilities.layoutCompoundLabel(
(JComponent) b, fm, text, icon, b, fm, text, icon,
b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewR, iconR, textR, (text == null ? 0 : textIconGap) viewR, iconR, textR, (text == null ? 0 : textIconGap)
......
...@@ -269,18 +269,18 @@ public class BasicInternalFrameTitlePane extends JComponent ...@@ -269,18 +269,18 @@ public class BasicInternalFrameTitlePane extends JComponent
} }
protected void addSystemMenuItems(JMenu systemMenu) { protected void addSystemMenuItems(JMenu systemMenu) {
JMenuItem mi = (JMenuItem)systemMenu.add(restoreAction); JMenuItem mi = systemMenu.add(restoreAction);
mi.setMnemonic('R'); mi.setMnemonic('R');
mi = (JMenuItem)systemMenu.add(moveAction); mi = systemMenu.add(moveAction);
mi.setMnemonic('M'); mi.setMnemonic('M');
mi = (JMenuItem)systemMenu.add(sizeAction); mi = systemMenu.add(sizeAction);
mi.setMnemonic('S'); mi.setMnemonic('S');
mi = (JMenuItem)systemMenu.add(iconifyAction); mi = systemMenu.add(iconifyAction);
mi.setMnemonic('n'); mi.setMnemonic('n');
mi = (JMenuItem)systemMenu.add(maximizeAction); mi = systemMenu.add(maximizeAction);
mi.setMnemonic('x'); mi.setMnemonic('x');
systemMenu.add(new JSeparator()); systemMenu.add(new JSeparator());
mi = (JMenuItem)systemMenu.add(closeAction); mi = systemMenu.add(closeAction);
mi.setMnemonic('C'); mi.setMnemonic('C');
} }
...@@ -414,7 +414,7 @@ public class BasicInternalFrameTitlePane extends JComponent ...@@ -414,7 +414,7 @@ public class BasicInternalFrameTitlePane extends JComponent
// PropertyChangeListener // PropertyChangeListener
// //
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
String prop = (String)evt.getPropertyName(); String prop = evt.getPropertyName();
if (prop == JInternalFrame.IS_SELECTED_PROPERTY) { if (prop == JInternalFrame.IS_SELECTED_PROPERTY) {
repaint(); repaint();
...@@ -429,19 +429,19 @@ public class BasicInternalFrameTitlePane extends JComponent ...@@ -429,19 +429,19 @@ public class BasicInternalFrameTitlePane extends JComponent
} }
if ("closable" == prop) { if ("closable" == prop) {
if ((Boolean)evt.getNewValue() == Boolean.TRUE) { if (evt.getNewValue() == Boolean.TRUE) {
add(closeButton); add(closeButton);
} else { } else {
remove(closeButton); remove(closeButton);
} }
} else if ("maximizable" == prop) { } else if ("maximizable" == prop) {
if ((Boolean)evt.getNewValue() == Boolean.TRUE) { if (evt.getNewValue() == Boolean.TRUE) {
add(maxButton); add(maxButton);
} else { } else {
remove(maxButton); remove(maxButton);
} }
} else if ("iconable" == prop) { } else if ("iconable" == prop) {
if ((Boolean)evt.getNewValue() == Boolean.TRUE) { if (evt.getNewValue() == Boolean.TRUE) {
add(iconButton); add(iconButton);
} else { } else {
remove(iconButton); remove(iconButton);
...@@ -781,7 +781,7 @@ public class BasicInternalFrameTitlePane extends JComponent ...@@ -781,7 +781,7 @@ public class BasicInternalFrameTitlePane extends JComponent
} }
} }
public boolean isFocusTraversable() { return false; } public boolean isFocusTraversable() { return false; }
public void requestFocus() {}; public void requestFocus() {}
public AccessibleContext getAccessibleContext() { public AccessibleContext getAccessibleContext() {
AccessibleContext ac = super.getAccessibleContext(); AccessibleContext ac = super.getAccessibleContext();
if (uiKey != null) { if (uiKey != null) {
...@@ -790,6 +790,6 @@ public class BasicInternalFrameTitlePane extends JComponent ...@@ -790,6 +790,6 @@ public class BasicInternalFrameTitlePane extends JComponent
} }
return ac; return ac;
} }
}; // end NoFocusButton } // end NoFocusButton
} // End Title Pane Class } // End Title Pane Class
...@@ -318,7 +318,7 @@ public class BasicInternalFrameUI extends InternalFrameUI ...@@ -318,7 +318,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
if (resizing) { if (resizing) {
return; return;
} }
Cursor s = (Cursor)frame.getLastCursor(); Cursor s = frame.getLastCursor();
if (s == null) { if (s == null) {
s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
} }
...@@ -336,13 +336,13 @@ public class BasicInternalFrameUI extends InternalFrameUI ...@@ -336,13 +336,13 @@ public class BasicInternalFrameUI extends InternalFrameUI
public Dimension getPreferredSize(JComponent x) { public Dimension getPreferredSize(JComponent x) {
if((JComponent)frame == x) if(frame == x)
return frame.getLayout().preferredLayoutSize(x); return frame.getLayout().preferredLayoutSize(x);
return new Dimension(100, 100); return new Dimension(100, 100);
} }
public Dimension getMinimumSize(JComponent x) { public Dimension getMinimumSize(JComponent x) {
if((JComponent)frame == x) { if(frame == x) {
return frame.getLayout().minimumLayoutSize(x); return frame.getLayout().minimumLayoutSize(x);
} }
return new Dimension(0, 0); return new Dimension(0, 0);
...@@ -1093,7 +1093,7 @@ public class BasicInternalFrameUI extends InternalFrameUI ...@@ -1093,7 +1093,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
updateFrameCursor(); updateFrameCursor();
} }
}; /// End BorderListener Class } /// End BorderListener Class
protected class ComponentHandler implements ComponentListener { protected class ComponentHandler implements ComponentListener {
// NOTE: This class exists only for backward compatability. All // NOTE: This class exists only for backward compatability. All
...@@ -1196,7 +1196,6 @@ public class BasicInternalFrameUI extends InternalFrameUI ...@@ -1196,7 +1196,6 @@ public class BasicInternalFrameUI extends InternalFrameUI
} }
} }
private static boolean isDragging = false;
private class Handler implements ComponentListener, InternalFrameListener, private class Handler implements ComponentListener, InternalFrameListener,
LayoutManager, MouseInputListener, PropertyChangeListener, LayoutManager, MouseInputListener, PropertyChangeListener,
WindowFocusListener, SwingConstants { WindowFocusListener, SwingConstants {
...@@ -1373,9 +1372,6 @@ public class BasicInternalFrameUI extends InternalFrameUI ...@@ -1373,9 +1372,6 @@ public class BasicInternalFrameUI extends InternalFrameUI
// MouseInputListener // MouseInputListener
private Component mouseEventTarget = null;
private Component dragSource = null;
public void mousePressed(MouseEvent e) { } public void mousePressed(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { } public void mouseEntered(MouseEvent e) { }
...@@ -1392,7 +1388,7 @@ public class BasicInternalFrameUI extends InternalFrameUI ...@@ -1392,7 +1388,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
// PropertyChangeListener // PropertyChangeListener
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
String prop = (String)evt.getPropertyName(); String prop = evt.getPropertyName();
JInternalFrame f = (JInternalFrame)evt.getSource(); JInternalFrame f = (JInternalFrame)evt.getSource();
Object newValue = evt.getNewValue(); Object newValue = evt.getNewValue();
Object oldValue = evt.getOldValue(); Object oldValue = evt.getOldValue();
......
...@@ -2102,8 +2102,6 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab ...@@ -2102,8 +2102,6 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
* <code>soundFile</code> passed into this method, it will * <code>soundFile</code> passed into this method, it will
* return <code>null</code>. * return <code>null</code>.
* *
* @param baseClass used as the root class/location to get the
* soundFile from
* @param soundFile the name of the audio file to be retrieved * @param soundFile the name of the audio file to be retrieved
* from disk * from disk
* @return A byte[] with audio data or null * @return A byte[] with audio data or null
...@@ -2120,9 +2118,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab ...@@ -2120,9 +2118,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
* Class.getResourceAsStream just returns raw * Class.getResourceAsStream just returns raw
* bytes, which we can convert to a sound. * bytes, which we can convert to a sound.
*/ */
byte[] buffer = (byte[])AccessController.doPrivileged( byte[] buffer = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<byte[]>() {
public Object run() { public byte[] run() {
try { try {
InputStream resource = BasicLookAndFeel.this. InputStream resource = BasicLookAndFeel.this.
getClass().getResourceAsStream(soundFile); getClass().getResourceAsStream(soundFile);
...@@ -2184,9 +2182,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab ...@@ -2184,9 +2182,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
UIManager.get("AuditoryCues.playList"); UIManager.get("AuditoryCues.playList");
if (audioStrings != null) { if (audioStrings != null) {
// create a HashSet to help us decide to play or not // create a HashSet to help us decide to play or not
HashSet audioCues = new HashSet(); HashSet<Object> audioCues = new HashSet<Object>();
for (int i = 0; i < audioStrings.length; i++) { for (Object audioString : audioStrings) {
audioCues.add(audioStrings[i]); audioCues.add(audioString);
} }
// get the name of the Action // get the name of the Action
String actionName = (String)audioAction.getValue(Action.NAME); String actionName = (String)audioAction.getValue(Action.NAME);
...@@ -2237,7 +2235,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab ...@@ -2237,7 +2235,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
* This class contains listener that watches for all the mouse * This class contains listener that watches for all the mouse
* events that can possibly invoke popup on the component * events that can possibly invoke popup on the component
*/ */
class AWTEventHelper implements AWTEventListener,PrivilegedAction { class AWTEventHelper implements AWTEventListener,PrivilegedAction<Object> {
AWTEventHelper() { AWTEventHelper() {
super(); super();
AccessController.doPrivileged(this); AccessController.doPrivileged(this);
......
...@@ -1041,15 +1041,15 @@ public class BasicMenuItemUI extends MenuItemUI ...@@ -1041,15 +1041,15 @@ public class BasicMenuItemUI extends MenuItemUI
Icon icon; Icon icon;
ButtonModel model = li.mi.getModel(); ButtonModel model = li.mi.getModel();
if (!model.isEnabled()) { if (!model.isEnabled()) {
icon = (Icon) li.mi.getDisabledIcon(); icon = li.mi.getDisabledIcon();
} else if (model.isPressed() && model.isArmed()) { } else if (model.isPressed() && model.isArmed()) {
icon = (Icon) li.mi.getPressedIcon(); icon = li.mi.getPressedIcon();
if (icon == null) { if (icon == null) {
// Use default icon // Use default icon
icon = (Icon) li.mi.getIcon(); icon = li.mi.getIcon();
} }
} else { } else {
icon = (Icon) li.mi.getIcon(); icon = li.mi.getIcon();
} }
if (icon != null) { if (icon != null) {
...@@ -1601,7 +1601,7 @@ public class BasicMenuItemUI extends MenuItemUI ...@@ -1601,7 +1601,7 @@ public class BasicMenuItemUI extends MenuItemUI
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 == null) else if (me == null)
......
...@@ -123,9 +123,9 @@ public class BasicMenuUI extends BasicMenuItemUI ...@@ -123,9 +123,9 @@ public class BasicMenuUI extends BasicMenuItemUI
InputMap windowInputMap = SwingUtilities.getUIInputMap( InputMap windowInputMap = SwingUtilities.getUIInputMap(
menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW); menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (lastMnemonic != 0 && windowInputMap != null) { if (lastMnemonic != 0 && windowInputMap != null) {
for (int i=0; i<shortcutKeys.length; i++) { for (int shortcutKey : shortcutKeys) {
windowInputMap.remove(KeyStroke.getKeyStroke windowInputMap.remove(KeyStroke.getKeyStroke
(lastMnemonic, shortcutKeys[i], false)); (lastMnemonic, shortcutKey, false));
} }
} }
if (mnemonic != 0) { if (mnemonic != 0) {
...@@ -135,10 +135,9 @@ public class BasicMenuUI extends BasicMenuItemUI ...@@ -135,10 +135,9 @@ public class BasicMenuUI extends BasicMenuItemUI
SwingUtilities.replaceUIInputMap(menuItem, JComponent. SwingUtilities.replaceUIInputMap(menuItem, JComponent.
WHEN_IN_FOCUSED_WINDOW, windowInputMap); WHEN_IN_FOCUSED_WINDOW, windowInputMap);
} }
for (int i=0; i<shortcutKeys.length; i++) { for (int shortcutKey : shortcutKeys) {
windowInputMap.put(KeyStroke.getKeyStroke(mnemonic, windowInputMap.put(KeyStroke.getKeyStroke(mnemonic,
shortcutKeys[i], false), shortcutKey, false), "selectMenu");
"selectMenu");
} }
} }
lastMnemonic = mnemonic; lastMnemonic = mnemonic;
...@@ -264,14 +263,14 @@ public class BasicMenuUI extends BasicMenuItemUI ...@@ -264,14 +263,14 @@ public class BasicMenuUI extends BasicMenuItemUI
if(subElements.length > 0) { if(subElements.length > 0) {
me = new MenuElement[4]; me = new MenuElement[4];
me[0] = (MenuElement) cnt; me[0] = (MenuElement) cnt;
me[1] = (MenuElement) menu; me[1] = menu;
me[2] = (MenuElement) menu.getPopupMenu(); me[2] = menu.getPopupMenu();
me[3] = subElements[0]; me[3] = subElements[0];
} else { } else {
me = new MenuElement[3]; me = new MenuElement[3];
me[0] = (MenuElement)cnt; me[0] = (MenuElement)cnt;
me[1] = menu; me[1] = menu;
me[2] = (MenuElement) menu.getPopupMenu(); me[2] = menu.getPopupMenu();
} }
defaultManager.setSelectedPath(me); defaultManager.setSelectedPath(me);
} }
...@@ -606,7 +605,7 @@ public class BasicMenuUI extends BasicMenuItemUI ...@@ -606,7 +605,7 @@ public class BasicMenuUI extends BasicMenuItemUI
MenuSelectionManager manager = e.getMenuSelectionManager(); MenuSelectionManager manager = e.getMenuSelectionManager();
if (key == Character.toLowerCase(e.getKeyChar())) { if (key == Character.toLowerCase(e.getKeyChar())) {
JPopupMenu popupMenu = ((JMenu)menuItem).getPopupMenu(); JPopupMenu popupMenu = ((JMenu)menuItem).getPopupMenu();
ArrayList newList = new ArrayList(Arrays.asList(path)); ArrayList<MenuElement> newList = new ArrayList<MenuElement>(Arrays.asList(path));
newList.add(popupMenu); newList.add(popupMenu);
MenuElement subs[] = popupMenu.getSubElements(); MenuElement subs[] = popupMenu.getSubElements();
MenuElement sub = MenuElement sub =
...@@ -614,8 +613,8 @@ public class BasicMenuUI extends BasicMenuItemUI ...@@ -614,8 +613,8 @@ public class BasicMenuUI extends BasicMenuItemUI
if(sub != null) { if(sub != null) {
newList.add(sub); newList.add(sub);
} }
MenuElement newPath[] = new MenuElement[0];; MenuElement newPath[] = new MenuElement[0];
newPath = (MenuElement[]) newList.toArray(newPath); newPath = newList.toArray(newPath);
manager.setSelectedPath(newPath); manager.setSelectedPath(newPath);
e.consume(); e.consume();
} else if (((JMenu)menuItem).isTopLevelMenu() } else if (((JMenu)menuItem).isTopLevelMenu()
......
...@@ -109,7 +109,7 @@ public class BasicOptionPaneUI extends OptionPaneUI { ...@@ -109,7 +109,7 @@ public class BasicOptionPaneUI extends OptionPaneUI {
static { static {
newline = (String)java.security.AccessController.doPrivileged( newline = java.security.AccessController.doPrivileged(
new GetPropertyAction("line.separator")); new GetPropertyAction("line.separator"));
if (newline == null) { if (newline == null) {
newline = "\n"; newline = "\n";
...@@ -262,7 +262,7 @@ public class BasicOptionPaneUI extends OptionPaneUI { ...@@ -262,7 +262,7 @@ public class BasicOptionPaneUI extends OptionPaneUI {
* <code>getMinimumOptionPaneSize</code>. * <code>getMinimumOptionPaneSize</code>.
*/ */
public Dimension getPreferredSize(JComponent c) { public Dimension getPreferredSize(JComponent c) {
if ((JOptionPane)c == optionPane) { if (c == optionPane) {
Dimension ourMin = getMinimumOptionPaneSize(); Dimension ourMin = getMinimumOptionPaneSize();
LayoutManager lm = c.getLayout(); LayoutManager lm = c.getLayout();
...@@ -366,8 +366,8 @@ public class BasicOptionPaneUI extends OptionPaneUI { ...@@ -366,8 +366,8 @@ public class BasicOptionPaneUI extends OptionPaneUI {
} else if (msg instanceof Object[]) { } else if (msg instanceof Object[]) {
Object [] msgs = (Object[]) msg; Object [] msgs = (Object[]) msg;
for (int i = 0; i < msgs.length; i++) { for (Object o : msgs) {
addMessageComponents(container, cons, msgs[i], maxll, false); addMessageComponents(container, cons, o, maxll, false);
} }
} else if (msg instanceof Icon) { } else if (msg instanceof Icon) {
...@@ -381,7 +381,7 @@ public class BasicOptionPaneUI extends OptionPaneUI { ...@@ -381,7 +381,7 @@ public class BasicOptionPaneUI extends OptionPaneUI {
if (len <= 0) { if (len <= 0) {
return; return;
} }
int nl = -1; int nl;
int nll = 0; int nll = 0;
if ((nl = s.indexOf(newline)) >= 0) { if ((nl = s.indexOf(newline)) >= 0) {
...@@ -1320,7 +1320,7 @@ public class BasicOptionPaneUI extends OptionPaneUI { ...@@ -1320,7 +1320,7 @@ public class BasicOptionPaneUI extends OptionPaneUI {
else if (changeName == "componentOrientation") { else if (changeName == "componentOrientation") {
ComponentOrientation o = (ComponentOrientation)e.getNewValue(); ComponentOrientation o = (ComponentOrientation)e.getNewValue();
JOptionPane op = (JOptionPane)e.getSource(); JOptionPane op = (JOptionPane)e.getSource();
if (o != (ComponentOrientation)e.getOldValue()) { if (o != e.getOldValue()) {
op.applyComponentOrientation(o); op.applyComponentOrientation(o);
} }
} }
...@@ -1418,7 +1418,7 @@ public class BasicOptionPaneUI extends OptionPaneUI { ...@@ -1418,7 +1418,7 @@ public class BasicOptionPaneUI extends OptionPaneUI {
} }
JButton createButton() { JButton createButton() {
JButton button = null; JButton button;
if (minimumWidth > 0) { if (minimumWidth > 0) {
button = new ConstrainedButton(text, minimumWidth); button = new ConstrainedButton(text, minimumWidth);
......
...@@ -225,14 +225,14 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -225,14 +225,14 @@ public class BasicPopupMenuUI extends PopupMenuUI {
return popup; return popup;
} }
static List getPopups() { static List<JPopupMenu> getPopups() {
MenuSelectionManager msm = MenuSelectionManager.defaultManager(); MenuSelectionManager msm = MenuSelectionManager.defaultManager();
MenuElement[] p = msm.getSelectedPath(); MenuElement[] p = msm.getSelectedPath();
List list = new ArrayList(p.length); List<JPopupMenu> list = new ArrayList<JPopupMenu>(p.length);
for(int i = 0; i < p.length; i++) { for (MenuElement element : p) {
if (p[i] instanceof JPopupMenu) { if (element instanceof JPopupMenu) {
list.add((JPopupMenu)p[i]); list.add((JPopupMenu) element);
} }
} }
return list; return list;
...@@ -290,14 +290,14 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -290,14 +290,14 @@ public class BasicPopupMenuUI extends PopupMenuUI {
MenuElement subitem = findEnabledChild( MenuElement subitem = findEnabledChild(
subpopup.getSubElements(), -1, true); subpopup.getSubElements(), -1, true);
ArrayList lst = new ArrayList(Arrays.asList(e.getPath())); ArrayList<MenuElement> lst = new ArrayList<MenuElement>(Arrays.asList(e.getPath()));
lst.add(menuToOpen); lst.add(menuToOpen);
lst.add(subpopup); lst.add(subpopup);
if (subitem != null) { if (subitem != null) {
lst.add(subitem); lst.add(subitem);
} }
MenuElement newPath[] = new MenuElement[0];; MenuElement newPath[] = new MenuElement[0];
newPath = (MenuElement[])lst.toArray(newPath); newPath = lst.toArray(newPath);
MenuSelectionManager.defaultManager().setSelectedPath(newPath); MenuSelectionManager.defaultManager().setSelectedPath(newPath);
e.consume(); e.consume();
} }
...@@ -345,7 +345,7 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -345,7 +345,7 @@ public class BasicPopupMenuUI extends PopupMenuUI {
} }
if (matches == 0) { if (matches == 0) {
; // no op // no op
} else if (matches == 1) { } else if (matches == 1) {
// Invoke the menu action // Invoke the menu action
JMenuItem item = (JMenuItem)items[firstMatch]; JMenuItem item = (JMenuItem)items[firstMatch];
...@@ -362,7 +362,7 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -362,7 +362,7 @@ public class BasicPopupMenuUI extends PopupMenuUI {
// Select the menu item with the matching mnemonic. If // Select the menu item with the matching mnemonic. If
// the same mnemonic has been invoked then select the next // the same mnemonic has been invoked then select the next
// menu item in the cycle. // menu item in the cycle.
MenuElement newItem = null; MenuElement newItem;
newItem = items[indexes[(currentIndex + 1) % matches]]; newItem = items[indexes[(currentIndex + 1) % matches]];
...@@ -372,7 +372,6 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -372,7 +372,6 @@ public class BasicPopupMenuUI extends PopupMenuUI {
manager.setSelectedPath(newPath); manager.setSelectedPath(newPath);
e.consume(); e.consume();
} }
return;
} }
public void menuKeyReleased(MenuKeyEvent e) { public void menuKeyReleased(MenuKeyEvent e) {
...@@ -625,7 +624,7 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -625,7 +624,7 @@ public class BasicPopupMenuUI extends PopupMenuUI {
// 4234793: This action should call JPopupMenu.firePopupMenuCanceled but it's // 4234793: This action should call JPopupMenu.firePopupMenuCanceled but it's
// a protected method. The real solution could be to make // a protected method. The real solution could be to make
// firePopupMenuCanceled public and call it directly. // firePopupMenuCanceled public and call it directly.
JPopupMenu lastPopup = (JPopupMenu)getLastPopup(); JPopupMenu lastPopup = getLastPopup();
if (lastPopup != null) { if (lastPopup != null) {
lastPopup.putClientProperty("JPopupMenu.firePopupMenuCanceled", Boolean.TRUE); lastPopup.putClientProperty("JPopupMenu.firePopupMenuCanceled", Boolean.TRUE);
} }
...@@ -703,7 +702,7 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -703,7 +702,7 @@ public class BasicPopupMenuUI extends PopupMenuUI {
static MenuElement findEnabledChild(MenuElement e[], int fromIndex, static MenuElement findEnabledChild(MenuElement e[], int fromIndex,
boolean forward) { boolean forward) {
MenuElement result = null; MenuElement result;
if (forward) { if (forward) {
result = nextEnabledChild(e, fromIndex+1, e.length-1); result = nextEnabledChild(e, fromIndex+1, e.length-1);
if (result == null) result = nextEnabledChild(e, 0, fromIndex-1); if (result == null) result = nextEnabledChild(e, 0, fromIndex-1);
...@@ -752,7 +751,7 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -752,7 +751,7 @@ public class BasicPopupMenuUI extends PopupMenuUI {
// A grab needs to be added // A grab needs to be added
final Toolkit tk = Toolkit.getDefaultToolkit(); final Toolkit tk = Toolkit.getDefaultToolkit();
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Object>() {
public Object run() { public Object run() {
tk.addAWTEventListener(MouseGrabber.this, tk.addAWTEventListener(MouseGrabber.this,
AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK |
...@@ -785,7 +784,7 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -785,7 +784,7 @@ public class BasicPopupMenuUI extends PopupMenuUI {
final Toolkit tk = Toolkit.getDefaultToolkit(); final Toolkit tk = Toolkit.getDefaultToolkit();
// The grab should be removed // The grab should be removed
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Object>() {
public Object run() { public Object run() {
tk.removeAWTEventListener(MouseGrabber.this); tk.removeAWTEventListener(MouseGrabber.this);
return null; return null;
...@@ -911,10 +910,8 @@ public class BasicPopupMenuUI extends PopupMenuUI { ...@@ -911,10 +910,8 @@ public class BasicPopupMenuUI extends PopupMenuUI {
// 4234793: This action should call firePopupMenuCanceled but it's // 4234793: This action should call firePopupMenuCanceled but it's
// a protected method. The real solution could be to make // a protected method. The real solution could be to make
// firePopupMenuCanceled public and call it directly. // firePopupMenuCanceled public and call it directly.
List popups = getPopups(); List<JPopupMenu> popups = getPopups();
Iterator iter = popups.iterator(); for (JPopupMenu popup : popups) {
while (iter.hasNext()) {
JPopupMenu popup = (JPopupMenu) iter.next();
popup.putClientProperty("JPopupMenu.firePopupMenuCanceled", Boolean.TRUE); popup.putClientProperty("JPopupMenu.firePopupMenuCanceled", Boolean.TRUE);
} }
MenuSelectionManager.defaultManager().clearSelectedPath(); MenuSelectionManager.defaultManager().clearSelectedPath();
......
...@@ -150,15 +150,15 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI ...@@ -150,15 +150,15 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
} }
} else if(model.isSelected()) { } else if(model.isSelected()) {
if(b.isRolloverEnabled() && model.isRollover()) { if(b.isRolloverEnabled() && model.isRollover()) {
altIcon = (Icon) b.getRolloverSelectedIcon(); altIcon = b.getRolloverSelectedIcon();
if (altIcon == null) { if (altIcon == null) {
altIcon = (Icon) b.getSelectedIcon(); altIcon = b.getSelectedIcon();
} }
} else { } else {
altIcon = (Icon) b.getSelectedIcon(); altIcon = b.getSelectedIcon();
} }
} else if(b.isRolloverEnabled() && model.isRollover()) { } else if(b.isRolloverEnabled() && model.isRollover()) {
altIcon = (Icon) b.getRolloverIcon(); altIcon = b.getRolloverIcon();
} }
if(altIcon == null) { if(altIcon == null) {
...@@ -214,7 +214,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI ...@@ -214,7 +214,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
String text = b.getText(); String text = b.getText();
Icon buttonIcon = (Icon) b.getIcon(); Icon buttonIcon = b.getIcon();
if(buttonIcon == null) { if(buttonIcon == null) {
buttonIcon = getDefaultIcon(); buttonIcon = getDefaultIcon();
} }
......
...@@ -106,13 +106,13 @@ public class BasicSplitPaneUI extends SplitPaneUI ...@@ -106,13 +106,13 @@ public class BasicSplitPaneUI extends SplitPaneUI
* Keys to use for forward focus traversal when the JComponent is * Keys to use for forward focus traversal when the JComponent is
* managing focus. * managing focus.
*/ */
private static Set managingFocusForwardTraversalKeys; private static Set<KeyStroke> managingFocusForwardTraversalKeys;
/** /**
* Keys to use for backward focus traversal when the JComponent is * Keys to use for backward focus traversal when the JComponent is
* managing focus. * managing focus.
*/ */
private static Set managingFocusBackwardTraversalKeys; private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
/** /**
...@@ -370,7 +370,7 @@ public class BasicSplitPaneUI extends SplitPaneUI ...@@ -370,7 +370,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
// focus forward traversal key // focus forward traversal key
if (managingFocusForwardTraversalKeys==null) { if (managingFocusForwardTraversalKeys==null) {
managingFocusForwardTraversalKeys = new HashSet(); managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusForwardTraversalKeys.add( managingFocusForwardTraversalKeys.add(
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
} }
...@@ -378,7 +378,7 @@ public class BasicSplitPaneUI extends SplitPaneUI ...@@ -378,7 +378,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
managingFocusForwardTraversalKeys); managingFocusForwardTraversalKeys);
// focus backward traversal key // focus backward traversal key
if (managingFocusBackwardTraversalKeys==null) { if (managingFocusBackwardTraversalKeys==null) {
managingFocusBackwardTraversalKeys = new HashSet(); managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusBackwardTraversalKeys.add( managingFocusBackwardTraversalKeys.add(
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK)); KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
} }
...@@ -2170,7 +2170,7 @@ public class BasicSplitPaneUI extends SplitPaneUI ...@@ -2170,7 +2170,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
Component focusOn = (direction > 0) ? Component focusOn = (direction > 0) ?
policy.getComponentAfter(rootAncestor, splitPane) : policy.getComponentAfter(rootAncestor, splitPane) :
policy.getComponentBefore(rootAncestor, splitPane); policy.getComponentBefore(rootAncestor, splitPane);
HashSet focusFrom = new HashSet(); HashSet<Component> focusFrom = new HashSet<Component>();
if (splitPane.isAncestorOf(focusOn)) { if (splitPane.isAncestorOf(focusOn)) {
do { do {
focusFrom.add(focusOn); focusFrom.add(focusOn);
...@@ -2212,7 +2212,7 @@ public class BasicSplitPaneUI extends SplitPaneUI ...@@ -2212,7 +2212,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
private Component getNextSide(JSplitPane splitPane, Component focus) { private Component getNextSide(JSplitPane splitPane, Component focus) {
Component left = splitPane.getLeftComponent(); Component left = splitPane.getLeftComponent();
Component right = splitPane.getRightComponent(); Component right = splitPane.getRightComponent();
Component next = null; Component next;
if (focus!=null && SwingUtilities.isDescendingFrom(focus, left) && if (focus!=null && SwingUtilities.isDescendingFrom(focus, left) &&
right!=null) { right!=null) {
next = getFirstAvailableComponent(right); next = getFirstAvailableComponent(right);
......
...@@ -142,9 +142,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -142,9 +142,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
private Component visibleComponent; private Component visibleComponent;
// PENDING(api): See comment for ContainerHandler // PENDING(api): See comment for ContainerHandler
private Vector htmlViews; private Vector<View> htmlViews;
private Hashtable mnemonicToIndexMap; private Hashtable<Integer, Integer> mnemonicToIndexMap;
/** /**
* InputMap used for mnemonics. Only non-null if the JTabbedPane has * InputMap used for mnemonics. Only non-null if the JTabbedPane has
...@@ -546,7 +546,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -546,7 +546,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
* Installs the state needed for mnemonics. * Installs the state needed for mnemonics.
*/ */
private void initMnemonics() { private void initMnemonics() {
mnemonicToIndexMap = new Hashtable(); mnemonicToIndexMap = new Hashtable<Integer, Integer>();
mnemonicInputMap = new ComponentInputMapUIResource(tabPane); mnemonicInputMap = new ComponentInputMapUIResource(tabPane);
mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane, mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane,
JComponent.WHEN_IN_FOCUSED_WINDOW)); JComponent.WHEN_IN_FOCUSED_WINDOW));
...@@ -909,10 +909,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -909,10 +909,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
private static final int CROP_SEGMENT = 12; private static final int CROP_SEGMENT = 12;
private static Polygon createCroppedTabShape(int tabPlacement, Rectangle tabRect, int cropline) { private static Polygon createCroppedTabShape(int tabPlacement, Rectangle tabRect, int cropline) {
int rlen = 0; int rlen;
int start = 0; int start;
int end = 0; int end;
int ostart = 0; int ostart;
switch(tabPlacement) { switch(tabPlacement) {
case LEFT: case LEFT:
...@@ -1014,7 +1014,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -1014,7 +1014,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
tabPane.putClientProperty("html", v); tabPane.putClientProperty("html", v);
} }
SwingUtilities.layoutCompoundLabel((JComponent) tabPane, SwingUtilities.layoutCompoundLabel(tabPane,
metrics, title, icon, metrics, title, icon,
SwingUtilities.CENTER, SwingUtilities.CENTER,
SwingUtilities.CENTER, SwingUtilities.CENTER,
...@@ -1694,7 +1694,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -1694,7 +1694,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
*/ */
protected View getTextViewForTab(int tabIndex) { protected View getTextViewForTab(int tabIndex) {
if (htmlViews != null) { if (htmlViews != null) {
return (View)htmlViews.elementAt(tabIndex); return htmlViews.elementAt(tabIndex);
} }
return null; return null;
} }
...@@ -2230,8 +2230,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -2230,8 +2230,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
if (mnemonic >= 'a' && mnemonic <='z') { if (mnemonic >= 'a' && mnemonic <='z') {
mnemonic -= ('a' - 'A'); mnemonic -= ('a' - 'A');
} }
Integer index = (Integer)ui.mnemonicToIndexMap. Integer index = ui.mnemonicToIndexMap.get(Integer.valueOf(mnemonic));
get(Integer.valueOf(mnemonic));
if (index != null && pane.isEnabledAt(index.intValue())) { if (index != null && pane.isEnabledAt(index.intValue())) {
pane.setSelectedIndex(index.intValue()); pane.setSelectedIndex(index.intValue());
} }
...@@ -2292,8 +2291,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -2292,8 +2291,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
for (int i = 0; i < tabPane.getTabCount(); i++) { for (int i = 0; i < tabPane.getTabCount(); i++) {
Component component = tabPane.getComponentAt(i); Component component = tabPane.getComponentAt(i);
if (component != null) { if (component != null) {
Dimension size = zeroSize; Dimension size = minimum ? component.getMinimumSize() :
size = minimum? component.getMinimumSize() :
component.getPreferredSize(); component.getPreferredSize();
if (size != null) { if (size != null) {
...@@ -2305,7 +2303,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -2305,7 +2303,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
// Add content border insets to minimum size // Add content border insets to minimum size
width += cWidth; width += cWidth;
height += cHeight; height += cHeight;
int tabExtent = 0; int tabExtent;
// Calculate how much space the tabs will need, based on the // Calculate how much space the tabs will need, based on the
// minimum size required to display largest child + content border // minimum size required to display largest child + content border
...@@ -3143,7 +3141,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -3143,7 +3141,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
int fontHeight = metrics.getHeight(); int fontHeight = metrics.getHeight();
int selectedIndex = tabPane.getSelectedIndex(); int selectedIndex = tabPane.getSelectedIndex();
int i, j; int i;
boolean verticalTabRuns = (tabPlacement == LEFT || tabPlacement == RIGHT); boolean verticalTabRuns = (tabPlacement == LEFT || tabPlacement == RIGHT);
boolean leftToRight = BasicGraphicsUtils.isLeftToRight(tabPane); boolean leftToRight = BasicGraphicsUtils.isLeftToRight(tabPane);
int x = tabAreaInsets.left; int x = tabAreaInsets.left;
...@@ -3433,10 +3431,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -3433,10 +3431,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
} }
public String toString() { public String toString() {
return new String("viewport.viewSize="+viewport.getViewSize()+"\n"+ return "viewport.viewSize=" + viewport.getViewSize() + "\n" +
"viewport.viewRectangle="+viewport.getViewRect()+"\n"+ "viewport.viewRectangle="+viewport.getViewRect()+"\n"+
"leadingTabIndex="+leadingTabIndex+"\n"+ "leadingTabIndex="+leadingTabIndex+"\n"+
"tabViewPosition="+tabViewPosition); "tabViewPosition=" + tabViewPosition;
} }
} }
...@@ -3788,8 +3786,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { ...@@ -3788,8 +3786,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
} }
} }
private Vector createHTMLVector() { private Vector<View> createHTMLVector() {
Vector htmlViews = new Vector(); Vector<View> htmlViews = new Vector<View>();
int count = tabPane.getTabCount(); int count = tabPane.getTabCount();
if (count>0) { if (count>0) {
for (int i=0 ; i<count; i++) { for (int i=0 ; i<count; i++) {
......
...@@ -526,16 +526,16 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -526,16 +526,16 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
EditorKit editorKit = getEditorKit(editor); EditorKit editorKit = getEditorKit(editor);
if ( editorKit != null if ( editorKit != null
&& editorKit instanceof DefaultEditorKit) { && editorKit instanceof DefaultEditorKit) {
Set storedForwardTraversalKeys = editor. Set<AWTKeyStroke> storedForwardTraversalKeys = editor.
getFocusTraversalKeys(KeyboardFocusManager. getFocusTraversalKeys(KeyboardFocusManager.
FORWARD_TRAVERSAL_KEYS); FORWARD_TRAVERSAL_KEYS);
Set storedBackwardTraversalKeys = editor. Set<AWTKeyStroke> storedBackwardTraversalKeys = editor.
getFocusTraversalKeys(KeyboardFocusManager. getFocusTraversalKeys(KeyboardFocusManager.
BACKWARD_TRAVERSAL_KEYS); BACKWARD_TRAVERSAL_KEYS);
Set forwardTraversalKeys = Set<AWTKeyStroke> forwardTraversalKeys =
new HashSet(storedForwardTraversalKeys); new HashSet<AWTKeyStroke>(storedForwardTraversalKeys);
Set backwardTraversalKeys = Set<AWTKeyStroke> backwardTraversalKeys =
new HashSet(storedBackwardTraversalKeys); new HashSet<AWTKeyStroke>(storedBackwardTraversalKeys);
if (editor.isEditable()) { if (editor.isEditable()) {
forwardTraversalKeys. forwardTraversalKeys.
remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
...@@ -1888,7 +1888,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -1888,7 +1888,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
* *
* @param e The change notification from the currently associated * @param e The change notification from the currently associated
* document. * document.
* @see DocumentListener#changeUpdate * @see DocumentListener#changedUpdate(DocumentEvent)
*/ */
public final void changedUpdate(DocumentEvent e) { public final void changedUpdate(DocumentEvent e) {
Rectangle alloc = (painted) ? getVisibleEditorRect() : null; Rectangle alloc = (painted) ? getVisibleEditorRect() : null;
...@@ -1964,9 +1964,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -1964,9 +1964,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
} }
try { try {
rootView.setSize(alloc.width, alloc.height); rootView.setSize(alloc.width, alloc.height);
Enumeration components = constraints.keys(); Enumeration<Component> components = constraints.keys();
while (components.hasMoreElements()) { while (components.hasMoreElements()) {
Component comp = (Component) components.nextElement(); Component comp = components.nextElement();
View v = (View) constraints.get(comp); View v = (View) constraints.get(comp);
Shape ca = calculateViewPosition(alloc, v); Shape ca = calculateViewPosition(alloc, v);
if (ca != null) { if (ca != null) {
...@@ -2009,7 +2009,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -2009,7 +2009,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
public void addLayoutComponent(Component comp, Object constraint) { public void addLayoutComponent(Component comp, Object constraint) {
if (constraint instanceof View) { if (constraint instanceof View) {
if (constraints == null) { if (constraints == null) {
constraints = new Hashtable(7); constraints = new Hashtable<Component, Object>(7);
} }
constraints.put(comp, constraint); constraints.put(comp, constraint);
} }
...@@ -2060,7 +2060,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -2060,7 +2060,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
* These are View objects for those components that are represented * These are View objects for those components that are represented
* by a View in the View tree. * by a View in the View tree.
*/ */
private Hashtable constraints; private Hashtable<Component, Object> constraints;
private boolean i18nView = false; private boolean i18nView = false;
} }
...@@ -2457,8 +2457,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -2457,8 +2457,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
JTextComponent c = (JTextComponent)comp; JTextComponent c = (JTextComponent)comp;
int pos = modeBetween int pos = modeBetween
? ((JTextComponent.DropLocation)c.getDropLocation()).getIndex() ? c.getDropLocation().getIndex() : c.getCaretPosition();
: c.getCaretPosition();
// if we are importing to the same component that we exported from // if we are importing to the same component that we exported from
// then don't actually do anything if the drop location is inside // then don't actually do anything if the drop location is inside
......
...@@ -125,31 +125,31 @@ public class BasicToggleButtonUI extends BasicButtonUI { ...@@ -125,31 +125,31 @@ public class BasicToggleButtonUI extends BasicButtonUI {
if(!model.isEnabled()) { if(!model.isEnabled()) {
if(model.isSelected()) { if(model.isSelected()) {
icon = (Icon) b.getDisabledSelectedIcon(); icon = b.getDisabledSelectedIcon();
} else { } else {
icon = (Icon) b.getDisabledIcon(); icon = b.getDisabledIcon();
} }
} else if(model.isPressed() && model.isArmed()) { } else if(model.isPressed() && model.isArmed()) {
icon = (Icon) b.getPressedIcon(); icon = b.getPressedIcon();
if(icon == null) { if(icon == null) {
// Use selected icon // Use selected icon
icon = (Icon) b.getSelectedIcon(); icon = b.getSelectedIcon();
} }
} else if(model.isSelected()) { } else if(model.isSelected()) {
if(b.isRolloverEnabled() && model.isRollover()) { if(b.isRolloverEnabled() && model.isRollover()) {
icon = (Icon) b.getRolloverSelectedIcon(); icon = b.getRolloverSelectedIcon();
if (icon == null) { if (icon == null) {
icon = (Icon) b.getSelectedIcon(); icon = b.getSelectedIcon();
} }
} else { } else {
icon = (Icon) b.getSelectedIcon(); icon = b.getSelectedIcon();
} }
} else if(b.isRolloverEnabled() && model.isRollover()) { } else if(b.isRolloverEnabled() && model.isRollover()) {
icon = (Icon) b.getRolloverIcon(); icon = b.getRolloverIcon();
} }
if(icon == null) { if(icon == null) {
icon = (Icon) b.getIcon(); icon = b.getIcon();
} }
icon.paintIcon(b, g, iconRect.x, iconRect.y); icon.paintIcon(b, g, iconRect.x, iconRect.y);
......
...@@ -83,8 +83,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -83,8 +83,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
private static Border nonRolloverToggleBorder; private static Border nonRolloverToggleBorder;
private boolean rolloverBorders = false; private boolean rolloverBorders = false;
private HashMap borderTable = new HashMap(); private HashMap<AbstractButton, Border> borderTable = new HashMap<AbstractButton, Border>();
private Hashtable rolloverTable = new Hashtable(); private Hashtable<AbstractButton, Boolean> rolloverTable = new Hashtable<AbstractButton, Boolean>();
/** /**
...@@ -171,7 +171,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -171,7 +171,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
uninstallKeyboardActions(); uninstallKeyboardActions();
// Clear instance vars // Clear instance vars
if (isFloating() == true) if (isFloating())
setFloating(false, null); setFloating(false, null);
floatingToolBar = null; floatingToolBar = null;
...@@ -273,9 +273,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -273,9 +273,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
// Put focus listener on all components in toolbar // Put focus listener on all components in toolbar
Component[] components = toolBar.getComponents(); Component[] components = toolBar.getComponents();
for ( int i = 0; i < components.length; ++i ) for (Component component : components) {
{ component.addFocusListener(toolBarFocusListener);
components[ i ].addFocusListener( toolBarFocusListener );
} }
} }
} }
...@@ -307,9 +306,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -307,9 +306,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
// Remove focus listener from all components in toolbar // Remove focus listener from all components in toolbar
Component[] components = toolBar.getComponents(); Component[] components = toolBar.getComponents();
for ( int i = 0; i < components.length; ++i ) for (Component component : components) {
{ component.removeFocusListener(toolBarFocusListener);
components[ i ].removeFocusListener( toolBarFocusListener );
} }
toolBarFocusListener = null; toolBarFocusListener = null;
...@@ -616,10 +614,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -616,10 +614,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
// Put rollover borders on buttons // Put rollover borders on buttons
Component[] components = c.getComponents(); Component[] components = c.getComponents();
for ( int i = 0; i < components.length; ++i ) { for (Component component : components) {
if ( components[ i ] instanceof JComponent ) { if (component instanceof JComponent) {
( (JComponent)components[ i ] ).updateUI(); ((JComponent) component).updateUI();
setBorderToRollover( components[ i ] ); setBorderToRollover(component);
} }
} }
} }
...@@ -640,10 +638,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -640,10 +638,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
// Put non-rollover borders on buttons. These borders reduce the margin. // Put non-rollover borders on buttons. These borders reduce the margin.
Component[] components = c.getComponents(); Component[] components = c.getComponents();
for ( int i = 0; i < components.length; ++i ) { for (Component component : components) {
if ( components[ i ] instanceof JComponent ) { if (component instanceof JComponent) {
( (JComponent)components[ i ] ).updateUI(); ((JComponent) component).updateUI();
setBorderToNonRollover( components[ i ] ); setBorderToNonRollover(component);
} }
} }
} }
...@@ -664,8 +662,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -664,8 +662,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
// Put back the normal borders on buttons // Put back the normal borders on buttons
Component[] components = c.getComponents(); Component[] components = c.getComponents();
for ( int i = 0; i < components.length; ++i ) { for (Component component : components) {
setBorderToNormal( components[ i ] ); setBorderToNormal(component);
} }
} }
...@@ -681,7 +679,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -681,7 +679,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
if (c instanceof AbstractButton) { if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c; AbstractButton b = (AbstractButton)c;
Border border = (Border)borderTable.get(b); Border border = borderTable.get(b);
if (border == null || border instanceof UIResource) { if (border == null || border instanceof UIResource) {
borderTable.put(b, b.getBorder()); borderTable.put(b, b.getBorder());
} }
...@@ -721,7 +719,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -721,7 +719,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
if (c instanceof AbstractButton) { if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c; AbstractButton b = (AbstractButton)c;
Border border = (Border)borderTable.get(b); Border border = borderTable.get(b);
if (border == null || border instanceof UIResource) { if (border == null || border instanceof UIResource) {
borderTable.put(b, b.getBorder()); borderTable.put(b, b.getBorder());
} }
...@@ -765,10 +763,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -765,10 +763,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
if (c instanceof AbstractButton) { if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c; AbstractButton b = (AbstractButton)c;
Border border = (Border)borderTable.remove(b); Border border = borderTable.remove(b);
b.setBorder(border); b.setBorder(border);
Boolean value = (Boolean)rolloverTable.remove(b); Boolean value = rolloverTable.remove(b);
if (value != null) { if (value != null) {
b.setRolloverEnabled(value.booleanValue()); b.setRolloverEnabled(value.booleanValue());
} }
...@@ -785,7 +783,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -785,7 +783,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
} }
public void setFloating(boolean b, Point p) { public void setFloating(boolean b, Point p) {
if (toolBar.isFloatable() == true) { if (toolBar.isFloatable()) {
boolean visible = false; boolean visible = false;
Window ancestor = SwingUtilities.getWindowAncestor(toolBar); Window ancestor = SwingUtilities.getWindowAncestor(toolBar);
if (ancestor != null) { if (ancestor != null) {
...@@ -953,7 +951,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -953,7 +951,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
protected void dragTo(Point position, Point origin) protected void dragTo(Point position, Point origin)
{ {
if (toolBar.isFloatable() == true) if (toolBar.isFloatable())
{ {
try try
{ {
...@@ -1003,7 +1001,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -1003,7 +1001,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
protected void floatAt(Point position, Point origin) protected void floatAt(Point position, Point origin)
{ {
if(toolBar.isFloatable() == true) if(toolBar.isFloatable())
{ {
try try
{ {
...@@ -1174,7 +1172,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -1174,7 +1172,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
if (!tb.isEnabled()) { if (!tb.isEnabled()) {
return; return;
} }
if (isDragging == true) { if (isDragging) {
Point position = evt.getPoint(); Point position = evt.getPoint();
if (origin == null) if (origin == null)
origin = evt.getComponent().getLocationOnScreen(); origin = evt.getComponent().getLocationOnScreen();
...@@ -1242,7 +1240,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -1242,7 +1240,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
protected class FrameListener extends WindowAdapter { protected class FrameListener extends WindowAdapter {
public void windowClosing(WindowEvent w) { public void windowClosing(WindowEvent w) {
if (toolBar.isFloatable() == true) { if (toolBar.isFloatable()) {
if (dragWindow != null) if (dragWindow != null)
dragWindow.setVisible(false); dragWindow.setVisible(false);
floating = false; floating = false;
......
...@@ -1263,7 +1263,7 @@ public class BasicTreeUI extends TreeUI ...@@ -1263,7 +1263,7 @@ public class BasicTreeUI extends TreeUI
} }
private Rectangle getDropLineRect(JTree.DropLocation loc) { private Rectangle getDropLineRect(JTree.DropLocation loc) {
Rectangle rect = null; Rectangle rect;
TreePath path = loc.getPath(); TreePath path = loc.getPath();
int index = loc.getChildIndex(); int index = loc.getChildIndex();
boolean ltr = leftToRight; boolean ltr = leftToRight;
...@@ -2138,7 +2138,7 @@ public class BasicTreeUI extends TreeUI ...@@ -2138,7 +2138,7 @@ public class BasicTreeUI extends TreeUI
compositeRequestFocus(editingComponent); compositeRequestFocus(editingComponent);
boolean selectAll = true; boolean selectAll = true;
if(event != null && event instanceof MouseEvent) { if(event != null) {
/* Find the component that will get forwarded all the /* Find the component that will get forwarded all the
mouse events until mouseReleased. */ mouse events until mouseReleased. */
Point componentPoint = SwingUtilities.convertPoint Point componentPoint = SwingUtilities.convertPoint
...@@ -3125,7 +3125,7 @@ public class BasicTreeUI extends TreeUI ...@@ -3125,7 +3125,7 @@ public class BasicTreeUI extends TreeUI
private static final TransferHandler defaultTransferHandler = new TreeTransferHandler(); private static final TransferHandler defaultTransferHandler = new TreeTransferHandler();
static class TreeTransferHandler extends TransferHandler implements UIResource, Comparator { static class TreeTransferHandler extends TransferHandler implements UIResource, Comparator<TreePath> {
private JTree tree; private JTree tree;
...@@ -3156,9 +3156,7 @@ public class BasicTreeUI extends TreeUI ...@@ -3156,9 +3156,7 @@ public class BasicTreeUI extends TreeUI
TreePath lastPath = null; TreePath lastPath = null;
TreePath[] displayPaths = getDisplayOrderPaths(paths); TreePath[] displayPaths = getDisplayOrderPaths(paths);
for (int i = 0; i < displayPaths.length; i++) { for (TreePath path : displayPaths) {
TreePath path = displayPaths[i];
Object node = path.getLastPathComponent(); Object node = path.getLastPathComponent();
boolean leaf = model.isLeaf(node); boolean leaf = model.isLeaf(node);
String label = getDisplayString(path, true, leaf); String label = getDisplayString(path, true, leaf);
...@@ -3179,9 +3177,9 @@ public class BasicTreeUI extends TreeUI ...@@ -3179,9 +3177,9 @@ public class BasicTreeUI extends TreeUI
return null; return null;
} }
public int compare(Object o1, Object o2) { public int compare(TreePath o1, TreePath o2) {
int row1 = tree.getRowForPath((TreePath)o1); int row1 = tree.getRowForPath(o1);
int row2 = tree.getRowForPath((TreePath)o2); int row2 = tree.getRowForPath(o2);
return row1 - row2; return row1 - row2;
} }
...@@ -3200,15 +3198,15 @@ public class BasicTreeUI extends TreeUI ...@@ -3200,15 +3198,15 @@ public class BasicTreeUI extends TreeUI
*/ */
TreePath[] getDisplayOrderPaths(TreePath[] paths) { TreePath[] getDisplayOrderPaths(TreePath[] paths) {
// sort the paths to display order rather than selection order // sort the paths to display order rather than selection order
ArrayList selOrder = new ArrayList(); ArrayList<TreePath> selOrder = new ArrayList<TreePath>();
for (int i = 0; i < paths.length; i++) { for (TreePath path : paths) {
selOrder.add(paths[i]); selOrder.add(path);
} }
Collections.sort(selOrder, this); Collections.sort(selOrder, this);
int n = selOrder.size(); int n = selOrder.size();
TreePath[] displayPaths = new TreePath[n]; TreePath[] displayPaths = new TreePath[n];
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
displayPaths[i] = (TreePath) selOrder.get(i); displayPaths[i] = selOrder.get(i);
} }
return displayPaths; return displayPaths;
} }
...@@ -3321,10 +3319,7 @@ public class BasicTreeUI extends TreeUI ...@@ -3321,10 +3319,7 @@ public class BasicTreeUI extends TreeUI
InputMap inputMap = tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); InputMap inputMap = tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
KeyStroke key = KeyStroke.getKeyStrokeForEvent(event); KeyStroke key = KeyStroke.getKeyStrokeForEvent(event);
if (inputMap != null && inputMap.get(key) != null) { return inputMap != null && inputMap.get(key) != null;
return true;
}
return false;
} }
......
...@@ -73,8 +73,7 @@ class DragRecognitionSupport { ...@@ -73,8 +73,7 @@ class DragRecognitionSupport {
* Returns whether or not the event is potentially part of a drag sequence. * Returns whether or not the event is potentially part of a drag sequence.
*/ */
public static boolean mousePressed(MouseEvent me) { public static boolean mousePressed(MouseEvent me) {
return ((DragRecognitionSupport)getDragRecognitionSupport()). return getDragRecognitionSupport().mousePressedImpl(me);
mousePressedImpl(me);
} }
/** /**
...@@ -82,16 +81,14 @@ class DragRecognitionSupport { ...@@ -82,16 +81,14 @@ class DragRecognitionSupport {
* that started the recognition. Otherwise, return null. * that started the recognition. Otherwise, return null.
*/ */
public static MouseEvent mouseReleased(MouseEvent me) { public static MouseEvent mouseReleased(MouseEvent me) {
return ((DragRecognitionSupport)getDragRecognitionSupport()). return getDragRecognitionSupport().mouseReleasedImpl(me);
mouseReleasedImpl(me);
} }
/** /**
* Returns whether or not a drag gesture recognition is ongoing. * Returns whether or not a drag gesture recognition is ongoing.
*/ */
public static boolean mouseDragged(MouseEvent me, BeforeDrag bd) { public static boolean mouseDragged(MouseEvent me, BeforeDrag bd) {
return ((DragRecognitionSupport)getDragRecognitionSupport()). return getDragRecognitionSupport().mouseDraggedImpl(me, bd);
mouseDraggedImpl(me, bd);
} }
private void clearState() { private void clearState() {
......
...@@ -142,7 +142,7 @@ class LazyActionMap extends ActionMapUIResource { ...@@ -142,7 +142,7 @@ class LazyActionMap extends ActionMapUIResource {
Object loader = _loader; Object loader = _loader;
_loader = null; _loader = null;
Class klass = (Class)loader; Class<?> klass = (Class<?>)loader;
try { try {
Method method = klass.getDeclaredMethod("loadActionMap", Method method = klass.getDeclaredMethod("loadActionMap",
new Class[] { LazyActionMap.class }); new Class[] { LazyActionMap.class });
......
...@@ -387,9 +387,9 @@ public class DefaultMetalTheme extends MetalTheme { ...@@ -387,9 +387,9 @@ public class DefaultMetalTheme extends MetalTheme {
* that it is wrapped inside a <code>doPrivileged</code> call. * that it is wrapped inside a <code>doPrivileged</code> call.
*/ */
protected Font getPrivilegedFont(final int key) { protected Font getPrivilegedFont(final int key) {
return (Font)java.security.AccessController.doPrivileged( return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Font>() {
public Object run() { public Font run() {
return Font.getFont(getDefaultPropertyName(key)); return Font.getFont(getDefaultPropertyName(key));
} }
} }
......
...@@ -49,7 +49,7 @@ class MetalBumps implements Icon { ...@@ -49,7 +49,7 @@ class MetalBumps implements Icon {
protected Color shadowColor; protected Color shadowColor;
protected Color backColor; protected Color backColor;
protected static Vector buffers = new Vector(); protected static Vector<BumpBuffer> buffers = new Vector<BumpBuffer>();
protected BumpBuffer buffer; protected BumpBuffer buffer;
public MetalBumps( Dimension bumpArea ) { public MetalBumps( Dimension bumpArea ) {
...@@ -81,10 +81,7 @@ class MetalBumps implements Icon { ...@@ -81,10 +81,7 @@ class MetalBumps implements Icon {
} }
BumpBuffer result = null; BumpBuffer result = null;
Enumeration elements = buffers.elements(); for (BumpBuffer aBuffer : buffers) {
while ( elements.hasMoreElements() ) {
BumpBuffer aBuffer = (BumpBuffer)elements.nextElement();
if ( aBuffer.hasSameConfiguration(gc, aTopColor, aShadowColor, if ( aBuffer.hasSameConfiguration(gc, aTopColor, aShadowColor,
aBackColor)) { aBackColor)) {
result = aBuffer; result = aBuffer;
...@@ -120,8 +117,7 @@ class MetalBumps implements Icon { ...@@ -120,8 +117,7 @@ class MetalBumps implements Icon {
public void paintIcon( Component c, Graphics g, int x, int y ) { public void paintIcon( Component c, Graphics g, int x, int y ) {
GraphicsConfiguration gc = (g instanceof Graphics2D) ? GraphicsConfiguration gc = (g instanceof Graphics2D) ?
(GraphicsConfiguration)((Graphics2D)g). ((Graphics2D) g).getDeviceConfiguration() : null;
getDeviceConfiguration() : null;
buffer = getBuffer(gc, topColor, shadowColor, backColor); buffer = getBuffer(gc, topColor, shadowColor, backColor);
......
...@@ -782,7 +782,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI { ...@@ -782,7 +782,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
} else if (s.equals("componentOrientation")) { } else if (s.equals("componentOrientation")) {
ComponentOrientation o = (ComponentOrientation)e.getNewValue(); ComponentOrientation o = (ComponentOrientation)e.getNewValue();
JFileChooser cc = (JFileChooser)e.getSource(); JFileChooser cc = (JFileChooser)e.getSource();
if (o != (ComponentOrientation)e.getOldValue()) { if (o != e.getOldValue()) {
cc.applyComponentOrientation(o); cc.applyComponentOrientation(o);
} }
} else if (s == "FileChooser.useShellFolder") { } else if (s == "FileChooser.useShellFolder") {
...@@ -927,7 +927,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI { ...@@ -927,7 +927,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
* Data model for a type-face selection combo-box. * Data model for a type-face selection combo-box.
*/ */
protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel { protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
Vector directories = new Vector(); Vector<File> directories = new Vector<File>();
int[] depths = null; int[] depths = null;
File selectedDirectory = null; File selectedDirectory = null;
JFileChooser chooser = getFileChooser(); JFileChooser chooser = getFileChooser();
...@@ -966,7 +966,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI { ...@@ -966,7 +966,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
// Get the canonical (full) path. This has the side // Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path, // benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar // for example /foo/bar/ becomes /foo/bar
File canonical = null; File canonical;
try { try {
canonical = ShellFolder.getNormalizedFile(directory); canonical = ShellFolder.getNormalizedFile(directory);
} catch (IOException e) { } catch (IOException e) {
...@@ -979,7 +979,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI { ...@@ -979,7 +979,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical) File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical; : canonical;
File f = sf; File f = sf;
Vector path = new Vector(10); Vector<File> path = new Vector<File>(10);
do { do {
path.addElement(f); path.addElement(f);
} while ((f = f.getParentFile()) != null); } while ((f = f.getParentFile()) != null);
...@@ -987,7 +987,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI { ...@@ -987,7 +987,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
int pathCount = path.size(); int pathCount = path.size();
// Insert chain at appropriate place in vector // Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) { for (int i = 0; i < pathCount; i++) {
f = (File)path.get(i); f = path.get(i);
if (directories.contains(f)) { if (directories.contains(f)) {
int topIndex = directories.indexOf(f); int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) { for (int j = i-1; j >= 0; j--) {
...@@ -1006,12 +1006,12 @@ public class MetalFileChooserUI extends BasicFileChooserUI { ...@@ -1006,12 +1006,12 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
private void calculateDepths() { private void calculateDepths() {
depths = new int[directories.size()]; depths = new int[directories.size()];
for (int i = 0; i < depths.length; i++) { for (int i = 0; i < depths.length; i++) {
File dir = (File)directories.get(i); File dir = directories.get(i);
File parent = dir.getParentFile(); File parent = dir.getParentFile();
depths[i] = 0; depths[i] = 0;
if (parent != null) { if (parent != null) {
for (int j = i-1; j >= 0; j--) { for (int j = i-1; j >= 0; j--) {
if (parent.equals((File)directories.get(j))) { if (parent.equals(directories.get(j))) {
depths[i] = depths[j] + 1; depths[i] = depths[j] + 1;
break; break;
} }
...@@ -1110,8 +1110,8 @@ public class MetalFileChooserUI extends BasicFileChooserUI { ...@@ -1110,8 +1110,8 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
FileFilter currentFilter = getFileChooser().getFileFilter(); FileFilter currentFilter = getFileChooser().getFileFilter();
boolean found = false; boolean found = false;
if(currentFilter != null) { if(currentFilter != null) {
for(int i=0; i < filters.length; i++) { for (FileFilter filter : filters) {
if(filters[i] == currentFilter) { if (filter == currentFilter) {
found = true; found = true;
} }
} }
......
...@@ -598,7 +598,7 @@ public class MetalIconFactory implements Serializable { ...@@ -598,7 +598,7 @@ public class MetalIconFactory implements Serializable {
} }
// Some calculations that are needed more than once later on. // Some calculations that are needed more than once later on.
int oneHalf = (int)(iconSize / 2); // 16 -> 8 int oneHalf = iconSize / 2; // 16 -> 8
g.translate(x, y); g.translate(x, y);
...@@ -1502,7 +1502,7 @@ public class MetalIconFactory implements Serializable { ...@@ -1502,7 +1502,7 @@ public class MetalIconFactory implements Serializable {
// PENDING: Replace this class with CachedPainter. // PENDING: Replace this class with CachedPainter.
Vector images = new Vector(1, 1); Vector<ImageGcPair> images = new Vector<ImageGcPair>(1, 1);
ImageGcPair currentImageGcPair; ImageGcPair currentImageGcPair;
class ImageGcPair { class ImageGcPair {
...@@ -1514,12 +1514,8 @@ public class MetalIconFactory implements Serializable { ...@@ -1514,12 +1514,8 @@ public class MetalIconFactory implements Serializable {
} }
boolean hasSameConfiguration(GraphicsConfiguration newGC) { boolean hasSameConfiguration(GraphicsConfiguration newGC) {
if (((newGC != null) && (newGC.equals(gc))) || return ((newGC != null) && (newGC.equals(gc))) ||
((newGC == null) && (gc == null))) ((newGC == null) && (gc == null));
{
return true;
}
return false;
} }
} }
...@@ -1528,9 +1524,7 @@ public class MetalIconFactory implements Serializable { ...@@ -1528,9 +1524,7 @@ public class MetalIconFactory implements Serializable {
if ((currentImageGcPair == null) || if ((currentImageGcPair == null) ||
!(currentImageGcPair.hasSameConfiguration(newGC))) !(currentImageGcPair.hasSameConfiguration(newGC)))
{ {
Enumeration elements = images.elements(); for (ImageGcPair imgGcPair : images) {
while (elements.hasMoreElements()) {
ImageGcPair imgGcPair = (ImageGcPair)elements.nextElement();
if (imgGcPair.hasSameConfiguration(newGC)) { if (imgGcPair.hasSameConfiguration(newGC)) {
currentImageGcPair = imgGcPair; currentImageGcPair = imgGcPair;
return imgGcPair.image; return imgGcPair.image;
......
...@@ -191,7 +191,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane { ...@@ -191,7 +191,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane {
extends BasicInternalFrameTitlePane.PropertyChangeHandler extends BasicInternalFrameTitlePane.PropertyChangeHandler
{ {
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
String prop = (String)evt.getPropertyName(); String prop = evt.getPropertyName();
if( prop.equals(JInternalFrame.IS_SELECTED_PROPERTY) ) { if( prop.equals(JInternalFrame.IS_SELECTED_PROPERTY) ) {
Boolean b = (Boolean)evt.getNewValue(); Boolean b = (Boolean)evt.getNewValue();
iconButton.putClientProperty("paintActive", b); iconButton.putClientProperty("paintActive", b);
...@@ -242,7 +242,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane { ...@@ -242,7 +242,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane {
} }
// Compute height. // Compute height.
int height = 0; int height;
if (isPalette) { if (isPalette) {
height = paletteTitleHeight; height = paletteTitleHeight;
} else { } else {
...@@ -410,7 +410,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane { ...@@ -410,7 +410,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane {
g.drawLine ( width - 1, 0 , width -1, 0); g.drawLine ( width - 1, 0 , width -1, 0);
int titleLength = 0; int titleLength;
int xOffset = leftToRight ? 5 : width - 5; int xOffset = leftToRight ? 5 : width - 5;
String frameTitle = frame.getTitle(); String frameTitle = frame.getTitle();
......
...@@ -2208,9 +2208,9 @@ public class MetalLookAndFeel extends BasicLookAndFeel ...@@ -2208,9 +2208,9 @@ public class MetalLookAndFeel extends BasicLookAndFeel
if (methodName == null) { if (methodName == null) {
return c.newInstance(); return c.newInstance();
} }
Method method = (Method)AccessController.doPrivileged( Method method = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Method>() {
public Object run() { public Method run() {
Method[] methods = c.getDeclaredMethods(); Method[] methods = c.getDeclaredMethods();
for (int counter = methods.length - 1; counter >= 0; for (int counter = methods.length - 1; counter >= 0;
counter--) { counter--) {
...@@ -2273,7 +2273,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel ...@@ -2273,7 +2273,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
} }
} }
static ReferenceQueue queue = new ReferenceQueue(); static ReferenceQueue<LookAndFeel> queue = new ReferenceQueue<LookAndFeel>();
static void flushUnreferenced() { static void flushUnreferenced() {
AATextListener aatl; AATextListener aatl;
...@@ -2283,7 +2283,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel ...@@ -2283,7 +2283,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
} }
static class AATextListener static class AATextListener
extends WeakReference implements PropertyChangeListener { extends WeakReference<LookAndFeel> implements PropertyChangeListener {
private String key = SunToolkit.DESKTOPFONTHINTS; private String key = SunToolkit.DESKTOPFONTHINTS;
...@@ -2294,7 +2294,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel ...@@ -2294,7 +2294,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
} }
public void propertyChange(PropertyChangeEvent pce) { public void propertyChange(PropertyChangeEvent pce) {
LookAndFeel laf = (LookAndFeel)get(); LookAndFeel laf = get();
if (laf == null || laf != UIManager.getLookAndFeel()) { if (laf == null || laf != UIManager.getLookAndFeel()) {
dispose(); dispose();
return; return;
...@@ -2318,8 +2318,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel ...@@ -2318,8 +2318,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
private static void updateWindowUI(Window window) { private static void updateWindowUI(Window window) {
SwingUtilities.updateComponentTreeUI(window); SwingUtilities.updateComponentTreeUI(window);
Window ownedWins[] = window.getOwnedWindows(); Window ownedWins[] = window.getOwnedWindows();
for (int i=0; i < ownedWins.length; i++) { for (Window w : ownedWins) {
updateWindowUI(ownedWins[i]); updateWindowUI(w);
} }
} }
...@@ -2328,8 +2328,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel ...@@ -2328,8 +2328,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
*/ */
private static void updateAllUIs() { private static void updateAllUIs() {
Frame appFrames[] = Frame.getFrames(); Frame appFrames[] = Frame.getFrames();
for (int j=0; j < appFrames.length; j++) { for (Frame frame : appFrames) {
updateWindowUI(appFrames[j]); updateWindowUI(frame);
} }
} }
......
...@@ -164,15 +164,15 @@ public class MetalRadioButtonUI extends BasicRadioButtonUI { ...@@ -164,15 +164,15 @@ public class MetalRadioButtonUI extends BasicRadioButtonUI {
} }
} else if(model.isSelected()) { } else if(model.isSelected()) {
if(b.isRolloverEnabled() && model.isRollover()) { if(b.isRolloverEnabled() && model.isRollover()) {
altIcon = (Icon) b.getRolloverSelectedIcon(); altIcon = b.getRolloverSelectedIcon();
if (altIcon == null) { if (altIcon == null) {
altIcon = (Icon) b.getSelectedIcon(); altIcon = b.getSelectedIcon();
} }
} else { } else {
altIcon = (Icon) b.getSelectedIcon(); altIcon = b.getSelectedIcon();
} }
} else if(b.isRolloverEnabled() && model.isRollover()) { } else if(b.isRolloverEnabled() && model.isRollover()) {
altIcon = (Icon) b.getRolloverIcon(); altIcon = b.getRolloverIcon();
} }
if(altIcon == null) { if(altIcon == null) {
......
...@@ -61,7 +61,7 @@ public class MetalToolBarUI extends BasicToolBarUI ...@@ -61,7 +61,7 @@ public class MetalToolBarUI extends BasicToolBarUI
* instances of JToolBars and JMenuBars and is used to find * instances of JToolBars and JMenuBars and is used to find
* JToolBars/JMenuBars that border each other. * JToolBars/JMenuBars that border each other.
*/ */
private static java.util.List components = new ArrayList(); private static List<WeakReference<JComponent>> components = new ArrayList<WeakReference<JComponent>>();
/** /**
* This protected field is implemenation specific. Do not access directly * This protected field is implemenation specific. Do not access directly
...@@ -95,7 +95,7 @@ public class MetalToolBarUI extends BasicToolBarUI ...@@ -95,7 +95,7 @@ public class MetalToolBarUI extends BasicToolBarUI
// typed to throw an NPE. // typed to throw an NPE.
throw new NullPointerException("JComponent must be non-null"); throw new NullPointerException("JComponent must be non-null");
} }
components.add(new WeakReference(c)); components.add(new WeakReference<JComponent>(c));
} }
/** /**
...@@ -105,8 +105,7 @@ public class MetalToolBarUI extends BasicToolBarUI ...@@ -105,8 +105,7 @@ public class MetalToolBarUI extends BasicToolBarUI
for (int counter = components.size() - 1; counter >= 0; counter--) { for (int counter = components.size() - 1; counter >= 0; counter--) {
// Search for the component, removing any flushed references // Search for the component, removing any flushed references
// along the way. // along the way.
WeakReference ref = (WeakReference)components.get(counter); JComponent target = components.get(counter).get();
Object target = ((WeakReference)components.get(counter)).get();
if (target == c || target == null) { if (target == c || target == null) {
components.remove(counter); components.remove(counter);
......
...@@ -63,7 +63,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory { ...@@ -63,7 +63,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory {
/** /**
* Maps from a List (BakedArrayList to be precise) to the merged style. * Maps from a List (BakedArrayList to be precise) to the merged style.
*/ */
private Map _resolvedStyles; private Map<BakedArrayList, SynthStyle> _resolvedStyles;
/** /**
* Used if there are no styles matching a widget. * Used if there are no styles matching a widget.
...@@ -74,7 +74,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory { ...@@ -74,7 +74,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory {
DefaultSynthStyleFactory() { DefaultSynthStyleFactory() {
_tmpList = new BakedArrayList(5); _tmpList = new BakedArrayList(5);
_styles = new ArrayList<StyleAssociation>(); _styles = new ArrayList<StyleAssociation>();
_resolvedStyles = new HashMap(); _resolvedStyles = new HashMap<BakedArrayList, SynthStyle>();
} }
public synchronized void addStyle(DefaultSynthStyle style, public synchronized void addStyle(DefaultSynthStyle style,
...@@ -138,7 +138,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory { ...@@ -138,7 +138,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory {
* Fetches any styles that match the passed into arguments into * Fetches any styles that match the passed into arguments into
* <code>matches</code>. * <code>matches</code>.
*/ */
private void getMatchingStyles(java.util.List matches, JComponent c, private void getMatchingStyles(List matches, JComponent c,
Region id) { Region id) {
String idName = id.getLowerCaseName(); String idName = id.getLowerCaseName();
String cName = c.getName(); String cName = c.getName();
...@@ -166,7 +166,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory { ...@@ -166,7 +166,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory {
/** /**
* Caches the specified style. * Caches the specified style.
*/ */
private void cacheStyle(java.util.List styles, SynthStyle style) { private void cacheStyle(List styles, SynthStyle style) {
BakedArrayList cachedStyles = new BakedArrayList(styles); BakedArrayList cachedStyles = new BakedArrayList(styles);
_resolvedStyles.put(cachedStyles, style); _resolvedStyles.put(cachedStyles, style);
...@@ -175,11 +175,11 @@ class DefaultSynthStyleFactory extends SynthStyleFactory { ...@@ -175,11 +175,11 @@ class DefaultSynthStyleFactory extends SynthStyleFactory {
/** /**
* Returns the cached style from the passed in arguments. * Returns the cached style from the passed in arguments.
*/ */
private SynthStyle getCachedStyle(java.util.List styles) { private SynthStyle getCachedStyle(List styles) {
if (styles.size() == 0) { if (styles.size() == 0) {
return null; return null;
} }
return (SynthStyle)_resolvedStyles.get(styles); return _resolvedStyles.get(styles);
} }
/** /**
...@@ -187,7 +187,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory { ...@@ -187,7 +187,7 @@ class DefaultSynthStyleFactory extends SynthStyleFactory {
* is reverse sorted, that is the most recently added style found to * is reverse sorted, that is the most recently added style found to
* match will be first. * match will be first.
*/ */
private SynthStyle mergeStyles(java.util.List styles) { private SynthStyle mergeStyles(List styles) {
int size = styles.size(); int size = styles.size();
if (size == 0) { if (size == 0) {
......
...@@ -66,7 +66,7 @@ class ImagePainter extends SynthPainter { ...@@ -66,7 +66,7 @@ class ImagePainter extends SynthPainter {
Paint9Painter painter; Paint9Painter painter;
if (cacheRef == null || (painter = cacheRef.get()) == null) { if (cacheRef == null || (painter = cacheRef.get()) == null) {
painter = new Paint9Painter(30); painter = new Paint9Painter(30);
cacheRef = new WeakReference(painter); cacheRef = new WeakReference<Paint9Painter>(painter);
AppContext.getAppContext().put(CACHE_KEY, cacheRef); AppContext.getAppContext().put(CACHE_KEY, cacheRef);
} }
return painter; return painter;
......
...@@ -67,8 +67,8 @@ import java.util.*; ...@@ -67,8 +67,8 @@ import java.util.*;
* @author Scott Violet * @author Scott Violet
*/ */
public class Region { public class Region {
private static final Map uiToRegionMap = new HashMap(); private static final Map<String, Region> uiToRegionMap = new HashMap<String, Region>();
private static final Map lowerCaseNameMap = new HashMap(); private static final Map<Region, String> lowerCaseNameMap = new HashMap<Region, String>();
/** /**
* ArrowButton's are special types of buttons that also render a * ArrowButton's are special types of buttons that also render a
...@@ -451,15 +451,11 @@ public class Region { ...@@ -451,15 +451,11 @@ public class Region {
static Region getRegion(JComponent c) { static Region getRegion(JComponent c) {
return (Region)uiToRegionMap.get(c.getUIClassID()); return uiToRegionMap.get(c.getUIClassID());
} }
static void registerUIs(UIDefaults table) { static void registerUIs(UIDefaults table) {
Iterator uis = uiToRegionMap.keySet().iterator(); for (String key : uiToRegionMap.keySet()) {
while (uis.hasNext()) {
Object key = uis.next();
table.put(key, "javax.swing.plaf.synth.SynthLookAndFeel"); table.put(key, "javax.swing.plaf.synth.SynthLookAndFeel");
} }
} }
...@@ -521,7 +517,7 @@ public class Region { ...@@ -521,7 +517,7 @@ public class Region {
*/ */
String getLowerCaseName() { String getLowerCaseName() {
synchronized(lowerCaseNameMap) { synchronized(lowerCaseNameMap) {
String lowerCaseName = (String)lowerCaseNameMap.get(this); String lowerCaseName = lowerCaseNameMap.get(this);
if (lowerCaseName == null) { if (lowerCaseName == null) {
lowerCaseName = getName().toLowerCase(); lowerCaseName = getName().toLowerCase();
lowerCaseNameMap.put(this, lowerCaseName); lowerCaseNameMap.put(this, lowerCaseName);
......
...@@ -336,7 +336,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -336,7 +336,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
return oldValue; return oldValue;
} else { } else {
// Must take the value from the editor and get the value and cast it to the new type. // Must take the value from the editor and get the value and cast it to the new type.
Class cls = oldValue.getClass(); Class<?> cls = oldValue.getClass();
try { try {
Method method = cls.getMethod("valueOf", new Class[]{String.class}); Method method = cls.getMethod("valueOf", new Class[]{String.class});
newValue = method.invoke(oldValue, new Object[] { editor.getText()}); newValue = method.invoke(oldValue, new Object[] { editor.getText()});
......
...@@ -39,7 +39,7 @@ import java.util.*; ...@@ -39,7 +39,7 @@ import java.util.*;
* @author Scott Violet * @author Scott Violet
*/ */
public class SynthContext { public class SynthContext {
private static final Map contextMap; private static final Map<Class, List<SynthContext>> contextMap;
private JComponent component; private JComponent component;
private Region region; private Region region;
...@@ -48,7 +48,7 @@ public class SynthContext { ...@@ -48,7 +48,7 @@ public class SynthContext {
static { static {
contextMap = new HashMap(); contextMap = new HashMap<Class, List<SynthContext>>();
} }
...@@ -58,13 +58,13 @@ public class SynthContext { ...@@ -58,13 +58,13 @@ public class SynthContext {
SynthContext context = null; SynthContext context = null;
synchronized(contextMap) { synchronized(contextMap) {
java.util.List instances = (java.util.List)contextMap.get(type); List<SynthContext> instances = contextMap.get(type);
if (instances != null) { if (instances != null) {
int size = instances.size(); int size = instances.size();
if (size > 0) { if (size > 0) {
context = (SynthContext)instances.remove(size - 1); context = instances.remove(size - 1);
} }
} }
} }
...@@ -81,11 +81,10 @@ public class SynthContext { ...@@ -81,11 +81,10 @@ public class SynthContext {
static void releaseContext(SynthContext context) { static void releaseContext(SynthContext context) {
synchronized(contextMap) { synchronized(contextMap) {
java.util.List instances = (java.util.List)contextMap.get( List<SynthContext> instances = contextMap.get(context.getClass());
context.getClass());
if (instances == null) { if (instances == null) {
instances = new ArrayList(5); instances = new ArrayList<SynthContext>(5);
contextMap.put(context.getClass(), instances); contextMap.put(context.getClass(), instances);
} }
instances.add(context); instances.add(context);
......
...@@ -45,8 +45,8 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { ...@@ -45,8 +45,8 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
* I would prefer to use UIResource instad of this. * I would prefer to use UIResource instad of this.
* Unfortunately Boolean is a final class * Unfortunately Boolean is a final class
*/ */
private Boolean localTrue = new Boolean(true); private Boolean localTrue = Boolean.TRUE;
private Boolean localFalse = new Boolean(false); private Boolean localFalse = Boolean.FALSE;
/** /**
* Creates a UI for the JTextPane. * Creates a UI for the JTextPane.
...@@ -69,7 +69,7 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { ...@@ -69,7 +69,7 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
localTrue); localTrue);
} }
updateStyle((JTextComponent)getComponent()); updateStyle(getComponent());
} }
protected void uninstallDefaults() { protected void uninstallDefaults() {
......
...@@ -416,7 +416,7 @@ public class SynthGraphicsUtils { ...@@ -416,7 +416,7 @@ public class SynthGraphicsUtils {
* the SynthIcon with a given SynthContext. * the SynthIcon with a given SynthContext.
*/ */
private static class SynthIconWrapper implements Icon { private static class SynthIconWrapper implements Icon {
private static final java.util.List CACHE = new java.util.ArrayList(1); private static final java.util.List<SynthIconWrapper> CACHE = new java.util.ArrayList<SynthIconWrapper>(1);
private SynthIcon synthIcon; private SynthIcon synthIcon;
private SynthContext context; private SynthContext context;
...@@ -425,8 +425,7 @@ public class SynthGraphicsUtils { ...@@ -425,8 +425,7 @@ public class SynthGraphicsUtils {
synchronized(CACHE) { synchronized(CACHE) {
int size = CACHE.size(); int size = CACHE.size();
if (size > 0) { if (size > 0) {
SynthIconWrapper wrapper = (SynthIconWrapper)CACHE.remove( SynthIconWrapper wrapper = CACHE.remove(size - 1);
size - 1);
wrapper.reset(icon, context); wrapper.reset(icon, context);
return wrapper; return wrapper;
} }
......
...@@ -197,18 +197,18 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane ...@@ -197,18 +197,18 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
protected void addSystemMenuItems(JPopupMenu menu) { protected void addSystemMenuItems(JPopupMenu menu) {
// PENDING: this should all be localizable! // PENDING: this should all be localizable!
JMenuItem mi = (JMenuItem)menu.add(restoreAction); JMenuItem mi = menu.add(restoreAction);
mi.setMnemonic('R'); mi.setMnemonic('R');
mi = (JMenuItem)menu.add(moveAction); mi = menu.add(moveAction);
mi.setMnemonic('M'); mi.setMnemonic('M');
mi = (JMenuItem)menu.add(sizeAction); mi = menu.add(sizeAction);
mi.setMnemonic('S'); mi.setMnemonic('S');
mi = (JMenuItem)menu.add(iconifyAction); mi = menu.add(iconifyAction);
mi.setMnemonic('n'); mi.setMnemonic('n');
mi = (JMenuItem)menu.add(maximizeAction); mi = menu.add(maximizeAction);
mi.setMnemonic('x'); mi.setMnemonic('x');
menu.add(new JSeparator()); menu.add(new JSeparator());
mi = (JMenuItem)menu.add(closeAction); mi = menu.add(closeAction);
mi.setMnemonic('C'); mi.setMnemonic('C');
} }
......
...@@ -107,7 +107,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -107,7 +107,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
* Map of defaults table entries. This is populated via the load * Map of defaults table entries. This is populated via the load
* method. * method.
*/ */
private Map defaultsMap; private Map<String, Object> defaultsMap;
private Handler _handler; private Handler _handler;
...@@ -308,8 +308,8 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -308,8 +308,8 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
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) {
updateStyles(children[i]); updateStyles(child);
} }
} }
} }
...@@ -581,7 +581,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -581,7 +581,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
} }
if (defaultsMap == null) { if (defaultsMap == null) {
defaultsMap = new HashMap(); defaultsMap = new HashMap<String, Object>();
} }
new SynthParser().parse(input, (DefaultSynthStyleFactory) factory, new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,
...@@ -611,7 +611,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -611,7 +611,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
} }
if (defaultsMap == null) { if (defaultsMap == null) {
defaultsMap = new HashMap(); defaultsMap = new HashMap<String, Object>();
} }
InputStream input = url.openStream(); InputStream input = url.openStream();
...@@ -771,7 +771,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -771,7 +771,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
*/ */
private static Object getAATextInfo() { private static Object getAATextInfo() {
String language = Locale.getDefault().getLanguage(); String language = Locale.getDefault().getLanguage();
String desktop = (String) String desktop =
AccessController.doPrivileged(new GetPropertyAction("sun.desktop")); AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
boolean isCjkLocale = (Locale.CHINESE.getLanguage().equals(language) || boolean isCjkLocale = (Locale.CHINESE.getLanguage().equals(language) ||
...@@ -786,7 +786,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -786,7 +786,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
return aaTextInfo; return aaTextInfo;
} }
private static ReferenceQueue queue = new ReferenceQueue(); private static ReferenceQueue<LookAndFeel> queue = new ReferenceQueue<LookAndFeel>();
private static void flushUnreferenced() { private static void flushUnreferenced() {
AATextListener aatl; AATextListener aatl;
...@@ -796,7 +796,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -796,7 +796,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
} }
private static class AATextListener private static class AATextListener
extends WeakReference implements PropertyChangeListener { extends WeakReference<LookAndFeel> implements PropertyChangeListener {
private String key = SunToolkit.DESKTOPFONTHINTS; private String key = SunToolkit.DESKTOPFONTHINTS;
AATextListener(LookAndFeel laf) { AATextListener(LookAndFeel laf) {
...@@ -812,7 +812,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -812,7 +812,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
return; return;
} }
LookAndFeel laf = (LookAndFeel) get(); LookAndFeel laf = get();
if (laf == null || laf != UIManager.getLookAndFeel()) { if (laf == null || laf != UIManager.getLookAndFeel()) {
dispose(); dispose();
return; return;
...@@ -835,8 +835,8 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -835,8 +835,8 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
private static void updateWindowUI(Window window) { private static void updateWindowUI(Window window) {
updateStyles(window); updateStyles(window);
Window ownedWins[] = window.getOwnedWindows(); Window ownedWins[] = window.getOwnedWindows();
for (int i = 0; i < ownedWins.length; i++) { for (Window w : ownedWins) {
updateWindowUI(ownedWins[i]); updateWindowUI(w);
} }
} }
...@@ -845,8 +845,8 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -845,8 +845,8 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
*/ */
private static void updateAllUIs() { private static void updateAllUIs() {
Frame appFrames[] = Frame.getFrames(); Frame appFrames[] = Frame.getFrames();
for (int i = 0; i < appFrames.length; i++) { for (Frame frame : appFrames) {
updateWindowUI(appFrames[i]); updateWindowUI(frame);
} }
} }
...@@ -909,7 +909,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -909,7 +909,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
// register it on the new one. // register it on the new one.
KeyboardFocusManager manager = KeyboardFocusManager manager =
(KeyboardFocusManager)evt.getSource(); (KeyboardFocusManager)evt.getSource();
if (((Boolean)newValue).equals(Boolean.FALSE)) { if (newValue.equals(Boolean.FALSE)) {
manager.removePropertyChangeListener(_handler); manager.removePropertyChangeListener(_handler);
} }
else { else {
......
...@@ -106,7 +106,7 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -106,7 +106,7 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
Icon checkIcon, Icon arrowIcon, int defaultTextIconGap, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap,
String acceleratorDelimiter) { String acceleratorDelimiter) {
JMenuItem b = (JMenuItem) c; JMenuItem b = (JMenuItem) c;
Icon icon = (Icon) b.getIcon(); Icon icon = b.getIcon();
String text = b.getText(); String text = b.getText();
KeyStroke accelerator = b.getAccelerator(); KeyStroke accelerator = b.getAccelerator();
String acceleratorText = ""; String acceleratorText = "";
...@@ -306,15 +306,15 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -306,15 +306,15 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
if(b.getIcon() != null) { if(b.getIcon() != null) {
Icon icon; Icon icon;
if(!model.isEnabled()) { if(!model.isEnabled()) {
icon = (Icon) b.getDisabledIcon(); icon = b.getDisabledIcon();
} else if(model.isPressed() && model.isArmed()) { } else if(model.isPressed() && model.isArmed()) {
icon = (Icon) b.getPressedIcon(); icon = b.getPressedIcon();
if(icon == null) { if(icon == null) {
// Use default icon // Use default icon
icon = (Icon) b.getIcon(); icon = b.getIcon();
} }
} else { } else {
icon = (Icon) b.getIcon(); icon = b.getIcon();
} }
if (icon!=null) { if (icon!=null) {
......
...@@ -40,6 +40,7 @@ import java.net.URLClassLoader; ...@@ -40,6 +40,7 @@ import java.net.URLClassLoader;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer; import java.util.StringTokenizer;
...@@ -136,7 +137,7 @@ class SynthParser extends HandlerBase { ...@@ -136,7 +137,7 @@ class SynthParser extends HandlerBase {
* Array of state infos for the current style. These are pushed to the * Array of state infos for the current style. These are pushed to the
* style when </style> is received. * style when </style> is received.
*/ */
private java.util.List _stateInfos; private List<ParsedSynthStyle.StateInfo> _stateInfos;
/** /**
* Current style. * Current style.
...@@ -151,7 +152,7 @@ class SynthParser extends HandlerBase { ...@@ -151,7 +152,7 @@ class SynthParser extends HandlerBase {
/** /**
* Bindings for the current InputMap * Bindings for the current InputMap
*/ */
private java.util.List _inputMapBindings; private List<String> _inputMapBindings;
/** /**
* ID for the input map. This is cached as * ID for the input map. This is cached as
...@@ -177,30 +178,30 @@ class SynthParser extends HandlerBase { ...@@ -177,30 +178,30 @@ class SynthParser extends HandlerBase {
/** /**
* List of ColorTypes. This is populated in startColorType. * List of ColorTypes. This is populated in startColorType.
*/ */
private java.util.List _colorTypes; private List<ColorType> _colorTypes;
/** /**
* defaultsPropertys are placed here. * defaultsPropertys are placed here.
*/ */
private Map _defaultsMap; private Map<String, Object> _defaultsMap;
/** /**
* List of SynthStyle.Painters that will be applied to the current style. * List of SynthStyle.Painters that will be applied to the current style.
*/ */
private java.util.List _stylePainters; private List<ParsedSynthStyle.PainterInfo> _stylePainters;
/** /**
* List of SynthStyle.Painters that will be applied to the current state. * List of SynthStyle.Painters that will be applied to the current state.
*/ */
private java.util.List _statePainters; private List<ParsedSynthStyle.PainterInfo> _statePainters;
SynthParser() { SynthParser() {
_mapping = new HashMap<String,Object>(); _mapping = new HashMap<String,Object>();
_stateInfos = new ArrayList(); _stateInfos = new ArrayList<ParsedSynthStyle.StateInfo>();
_colorTypes = new ArrayList(); _colorTypes = new ArrayList<ColorType>();
_inputMapBindings = new ArrayList(); _inputMapBindings = new ArrayList<String>();
_stylePainters = new ArrayList(); _stylePainters = new ArrayList<ParsedSynthStyle.PainterInfo>();
_statePainters = new ArrayList(); _statePainters = new ArrayList<ParsedSynthStyle.PainterInfo>();
} }
/** /**
...@@ -219,7 +220,7 @@ class SynthParser extends HandlerBase { ...@@ -219,7 +220,7 @@ class SynthParser extends HandlerBase {
public void parse(InputStream inputStream, public void parse(InputStream inputStream,
DefaultSynthStyleFactory factory, DefaultSynthStyleFactory factory,
URL urlResourceBase, Class<?> classResourceBase, URL urlResourceBase, Class<?> classResourceBase,
Map defaultsMap) Map<String, Object> defaultsMap)
throws ParseException, IllegalArgumentException { throws ParseException, IllegalArgumentException {
if (inputStream == null || factory == null || if (inputStream == null || factory == null ||
(urlResourceBase == null && classResourceBase == null)) { (urlResourceBase == null && classResourceBase == null)) {
...@@ -333,7 +334,7 @@ class SynthParser extends HandlerBase { ...@@ -333,7 +334,7 @@ class SynthParser extends HandlerBase {
* type type, this will throw an exception. * type type, this will throw an exception.
*/ */
private Object lookup(String key, Class type) throws SAXException { private Object lookup(String key, Class type) throws SAXException {
Object value = null; Object value;
if (_handler != null) { if (_handler != null) {
if ((value = _handler.lookup(key)) != null) { if ((value = _handler.lookup(key)) != null) {
return checkCast(value, type); return checkCast(value, type);
...@@ -423,15 +424,12 @@ class SynthParser extends HandlerBase { ...@@ -423,15 +424,12 @@ class SynthParser extends HandlerBase {
private void endStyle() throws SAXException { private void endStyle() throws SAXException {
int size = _stylePainters.size(); int size = _stylePainters.size();
if (size > 0) { if (size > 0) {
_style.setPainters((ParsedSynthStyle.PainterInfo[]) _style.setPainters(_stylePainters.toArray(new ParsedSynthStyle.PainterInfo[size]));
_stylePainters.toArray(new ParsedSynthStyle.
PainterInfo[size]));
_stylePainters.clear(); _stylePainters.clear();
} }
size = _stateInfos.size(); size = _stateInfos.size();
if (size > 0) { if (size > 0) {
_style.setStateInfo((ParsedSynthStyle.StateInfo[])_stateInfos. _style.setStateInfo(_stateInfos.toArray(new ParsedSynthStyle.StateInfo[size]));
toArray(new ParsedSynthStyle.StateInfo[size]));
_stateInfos.clear(); _stateInfos.clear();
} }
_style = null; _style = null;
...@@ -501,9 +499,7 @@ class SynthParser extends HandlerBase { ...@@ -501,9 +499,7 @@ class SynthParser extends HandlerBase {
private void endState() throws SAXException { private void endState() throws SAXException {
int size = _statePainters.size(); int size = _statePainters.size();
if (size > 0) { if (size > 0) {
_stateInfo.setPainters((ParsedSynthStyle.PainterInfo[]) _stateInfo.setPainters(_statePainters.toArray(new ParsedSynthStyle.PainterInfo[size]));
_statePainters.toArray(new ParsedSynthStyle.
PainterInfo[size]));
_statePainters.clear(); _statePainters.clear();
} }
_stateInfo = null; _stateInfo = null;
...@@ -684,8 +680,7 @@ class SynthParser extends HandlerBase { ...@@ -684,8 +680,7 @@ class SynthParser extends HandlerBase {
int max = 0; int max = 0;
for (int counter = _colorTypes.size() - 1; counter >= 0; for (int counter = _colorTypes.size() - 1; counter >= 0;
counter--) { counter--) {
max = Math.max(max, ((ColorType)_colorTypes.get(counter)). max = Math.max(max, _colorTypes.get(counter).getID());
getID());
} }
if (colors == null || colors.length <= max) { if (colors == null || colors.length <= max) {
Color[] newColors = new Color[max + 1]; Color[] newColors = new Color[max + 1];
...@@ -696,7 +691,7 @@ class SynthParser extends HandlerBase { ...@@ -696,7 +691,7 @@ class SynthParser extends HandlerBase {
} }
for (int counter = _colorTypes.size() - 1; counter >= 0; for (int counter = _colorTypes.size() - 1; counter >= 0;
counter--) { counter--) {
colors[((ColorType)_colorTypes.get(counter)).getID()] = color; colors[_colorTypes.get(counter).getID()] = color;
} }
_stateInfo.setColors(colors); _stateInfo.setColors(colors);
} }
...@@ -705,7 +700,7 @@ class SynthParser extends HandlerBase { ...@@ -705,7 +700,7 @@ class SynthParser extends HandlerBase {
private void startProperty(AttributeList attributes, private void startProperty(AttributeList attributes,
Object property) throws SAXException { Object property) throws SAXException {
Object value = null; Object value = null;
Object key = null; String key = null;
// Type of the value: 0=idref, 1=boolean, 2=dimension, 3=insets, // Type of the value: 0=idref, 1=boolean, 2=dimension, 3=insets,
// 4=integer,5=string // 4=integer,5=string
int iType = 0; int iType = 0;
...@@ -1027,7 +1022,7 @@ class SynthParser extends HandlerBase { ...@@ -1027,7 +1022,7 @@ class SynthParser extends HandlerBase {
} }
} }
private void addPainterOrMerge(java.util.List painters, String method, private void addPainterOrMerge(List<ParsedSynthStyle.PainterInfo> painters, String method,
SynthPainter painter, int direction) { SynthPainter painter, int direction) {
ParsedSynthStyle.PainterInfo painterInfo; ParsedSynthStyle.PainterInfo painterInfo;
painterInfo = new ParsedSynthStyle.PainterInfo(method, painterInfo = new ParsedSynthStyle.PainterInfo(method,
......
...@@ -48,13 +48,13 @@ class SynthSplitPaneUI extends BasicSplitPaneUI implements ...@@ -48,13 +48,13 @@ class SynthSplitPaneUI extends BasicSplitPaneUI implements
* Keys to use for forward focus traversal when the JComponent is * Keys to use for forward focus traversal when the JComponent is
* managing focus. * managing focus.
*/ */
private static Set managingFocusForwardTraversalKeys; private static Set<KeyStroke> managingFocusForwardTraversalKeys;
/** /**
* Keys to use for backward focus traversal when the JComponent is * Keys to use for backward focus traversal when the JComponent is
* managing focus. * managing focus.
*/ */
private static Set managingFocusBackwardTraversalKeys; private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
/** /**
* Style for the JSplitPane. * Style for the JSplitPane.
...@@ -96,7 +96,7 @@ class SynthSplitPaneUI extends BasicSplitPaneUI implements ...@@ -96,7 +96,7 @@ class SynthSplitPaneUI extends BasicSplitPaneUI implements
// focus forward traversal key // focus forward traversal key
if (managingFocusForwardTraversalKeys==null) { if (managingFocusForwardTraversalKeys==null) {
managingFocusForwardTraversalKeys = new HashSet(); managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusForwardTraversalKeys.add( managingFocusForwardTraversalKeys.add(
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
} }
...@@ -104,7 +104,7 @@ class SynthSplitPaneUI extends BasicSplitPaneUI implements ...@@ -104,7 +104,7 @@ class SynthSplitPaneUI extends BasicSplitPaneUI implements
managingFocusForwardTraversalKeys); managingFocusForwardTraversalKeys);
// focus backward traversal key // focus backward traversal key
if (managingFocusBackwardTraversalKeys==null) { if (managingFocusBackwardTraversalKeys==null) {
managingFocusBackwardTraversalKeys = new HashSet(); managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusBackwardTraversalKeys.add( managingFocusBackwardTraversalKeys.add(
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK)); KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
} }
......
...@@ -53,7 +53,7 @@ public abstract class SynthStyle { ...@@ -53,7 +53,7 @@ public abstract class SynthStyle {
/** /**
* Contains the default values for certain properties. * Contains the default values for certain properties.
*/ */
private static Map DEFAULT_VALUES; private static Map<Object, Object> DEFAULT_VALUES;
/** /**
* Shared SynthGraphics. * Shared SynthGraphics.
...@@ -715,7 +715,7 @@ public abstract class SynthStyle { ...@@ -715,7 +715,7 @@ public abstract class SynthStyle {
private static Object getDefaultValue(Object key) { private static Object getDefaultValue(Object key) {
synchronized(SynthStyle.class) { synchronized(SynthStyle.class) {
if (DEFAULT_VALUES == null) { if (DEFAULT_VALUES == null) {
DEFAULT_VALUES = new HashMap(); DEFAULT_VALUES = new HashMap<Object, Object>();
populateDefaultValues(); populateDefaultValues();
} }
Object value = DEFAULT_VALUES.get(key); Object value = DEFAULT_VALUES.get(key);
......
...@@ -66,7 +66,7 @@ class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI { ...@@ -66,7 +66,7 @@ class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI {
protected void installDefaults() { protected void installDefaults() {
// Installs the text cursor on the component // Installs the text cursor on the component
super.installDefaults(); super.installDefaults();
updateStyle((JTextComponent)getComponent()); updateStyle(getComponent());
} }
protected void uninstallDefaults() { protected void uninstallDefaults() {
......
...@@ -232,7 +232,7 @@ class SynthTextFieldUI ...@@ -232,7 +232,7 @@ class SynthTextFieldUI
protected void installDefaults() { protected void installDefaults() {
// Installs the text cursor on the component // Installs the text cursor on the component
super.installDefaults(); super.installDefaults();
updateStyle((JTextComponent)getComponent()); updateStyle(getComponent());
getComponent().addFocusListener(this); getComponent().addFocusListener(this);
} }
......
...@@ -390,7 +390,7 @@ class SynthTreeUI extends BasicTreeUI implements PropertyChangeListener, ...@@ -390,7 +390,7 @@ class SynthTreeUI extends BasicTreeUI implements PropertyChangeListener,
} }
private Rectangle getDropLineRect(JTree.DropLocation loc) { private Rectangle getDropLineRect(JTree.DropLocation loc) {
Rectangle rect = null; Rectangle rect;
TreePath path = loc.getPath(); TreePath path = loc.getPath();
int index = loc.getChildIndex(); int index = loc.getChildIndex();
boolean ltr = tree.getComponentOrientation().isLeftToRight(); boolean ltr = tree.getComponentOrientation().isLeftToRight();
...@@ -523,7 +523,7 @@ class SynthTreeUI extends BasicTreeUI implements PropertyChangeListener, ...@@ -523,7 +523,7 @@ class SynthTreeUI extends BasicTreeUI implements PropertyChangeListener,
// Don't paint the renderer if editing this row. // Don't paint the renderer if editing this row.
boolean selected = tree.isRowSelected(row); boolean selected = tree.isRowSelected(row);
JTree.DropLocation dropLocation = (JTree.DropLocation)tree.getDropLocation(); JTree.DropLocation dropLocation = tree.getDropLocation();
boolean isDrop = dropLocation != null boolean isDrop = dropLocation != null
&& dropLocation.getChildIndex() == -1 && dropLocation.getChildIndex() == -1
&& path == dropLocation.getPath(); && path == dropLocation.getPath();
......
...@@ -44,7 +44,7 @@ import javax.swing.plaf.*; ...@@ -44,7 +44,7 @@ import javax.swing.plaf.*;
* @author Scott Violet * @author Scott Violet
*/ */
public class DefaultSynthStyle extends SynthStyle implements Cloneable { public class DefaultSynthStyle extends SynthStyle implements Cloneable {
private static final Object PENDING = new String("Pending"); private static final String PENDING = "Pending";
/** /**
* Should the component be opaque? * Should the component be opaque?
...@@ -690,8 +690,8 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { ...@@ -690,8 +690,8 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
StateInfo[] states = getStateInfo(); StateInfo[] states = getStateInfo();
if (states != null) { if (states != null) {
buf.append("states["); buf.append("states[");
for (int i = 0; i < states.length; i++) { for (StateInfo state : states) {
buf.append(states[i].toString()).append(','); buf.append(state.toString()).append(',');
} }
buf.append(']').append(','); buf.append(']').append(',');
} }
...@@ -888,7 +888,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { ...@@ -888,7 +888,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
* Returns the number of states that are similar between the * Returns the number of states that are similar between the
* ComponentState this StateInfo represents and val. * ComponentState this StateInfo represents and val.
*/ */
private final int getMatchCount(int val) { private int getMatchCount(int val) {
// This comes from BigInteger.bitCnt // This comes from BigInteger.bitCnt
val &= state; val &= state;
val -= (0xaaaaaaaa & val) >>> 1; val -= (0xaaaaaaaa & val) >>> 1;
......
...@@ -735,7 +735,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { ...@@ -735,7 +735,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
* Data model for a type-face selection combo-box. * Data model for a type-face selection combo-box.
*/ */
protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel { protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
Vector directories = new Vector(); Vector<File> directories = new Vector<File>();
int[] depths = null; int[] depths = null;
File selectedDirectory = null; File selectedDirectory = null;
JFileChooser chooser = getFileChooser(); JFileChooser chooser = getFileChooser();
...@@ -778,7 +778,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { ...@@ -778,7 +778,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
// Get the canonical (full) path. This has the side // Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path, // benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar // for example /foo/bar/ becomes /foo/bar
File canonical = null; File canonical;
try { try {
canonical = directory.getCanonicalFile(); canonical = directory.getCanonicalFile();
} catch (IOException e) { } catch (IOException e) {
...@@ -791,7 +791,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { ...@@ -791,7 +791,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical) File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical; : canonical;
File f = sf; File f = sf;
Vector path = new Vector(10); Vector<File> path = new Vector<File>(10);
do { do {
path.addElement(f); path.addElement(f);
} while ((f = f.getParentFile()) != null); } while ((f = f.getParentFile()) != null);
...@@ -799,7 +799,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { ...@@ -799,7 +799,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
int pathCount = path.size(); int pathCount = path.size();
// Insert chain at appropriate place in vector // Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) { for (int i = 0; i < pathCount; i++) {
f = (File)path.get(i); f = path.get(i);
if (directories.contains(f)) { if (directories.contains(f)) {
int topIndex = directories.indexOf(f); int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) { for (int j = i-1; j >= 0; j--) {
...@@ -818,12 +818,12 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { ...@@ -818,12 +818,12 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
private void calculateDepths() { private void calculateDepths() {
depths = new int[directories.size()]; depths = new int[directories.size()];
for (int i = 0; i < depths.length; i++) { for (int i = 0; i < depths.length; i++) {
File dir = (File)directories.get(i); File dir = directories.get(i);
File parent = dir.getParentFile(); File parent = dir.getParentFile();
depths[i] = 0; depths[i] = 0;
if (parent != null) { if (parent != null) {
for (int j = i-1; j >= 0; j--) { for (int j = i-1; j >= 0; j--) {
if (parent.equals((File)directories.get(j))) { if (parent.equals(directories.get(j))) {
depths[i] = depths[j] + 1; depths[i] = depths[j] + 1;
break; break;
} }
...@@ -940,8 +940,8 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { ...@@ -940,8 +940,8 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
FileFilter currentFilter = getFileChooser().getFileFilter(); FileFilter currentFilter = getFileChooser().getFileFilter();
boolean found = false; boolean found = false;
if(currentFilter != null) { if(currentFilter != null) {
for(int i=0; i < filters.length; i++) { for (FileFilter filter : filters) {
if(filters[i] == currentFilter) { if (filter == currentFilter) {
found = true; found = true;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册