提交 62cf36ae 编写于 作者: R rupashka

6776095: Code improvement and warnings removing from swing packages

Reviewed-by: malenkov
Contributed-by: NFlorian Brunner <fbrunnerlist@gmx.ch>
上级 8325c78b
......@@ -263,13 +263,13 @@ class GTKFileChooserUI extends SynthFileChooserUI {
ListSelectionModel sm = directoryList.getSelectionModel();
if (sm instanceof DefaultListSelectionModel) {
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0);
sm.setAnchorSelectionIndex(0);
}
fileList.clearSelection();
sm = fileList.getSelectionModel();
if (sm instanceof DefaultListSelectionModel) {
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0);
sm.setAnchorSelectionIndex(0);
}
File currentDirectory = getFileChooser().getCurrentDirectory();
......@@ -1073,7 +1073,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
* Data model for a type-face selection combo-box.
*/
protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
Vector directories = new Vector();
Vector<File> directories = new Vector<File>();
File selectedDirectory = null;
JFileChooser chooser = getFileChooser();
FileSystemView fsv = chooser.getFileSystemView();
......@@ -1215,7 +1215,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
ListSelectionModel sm = fileList.getSelectionModel();
if (sm instanceof DefaultListSelectionModel) {
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0);
sm.setAnchorSelectionIndex(0);
}
rescanCurrentDirectory(getFileChooser());
return;
......
......@@ -1470,7 +1470,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(gtkAAFontSettingsCond);
}
static ReferenceQueue queue = new ReferenceQueue();
static ReferenceQueue<GTKLookAndFeel> queue = new ReferenceQueue<GTKLookAndFeel>();
private static void flushUnreferenced() {
WeakPCL pcl;
......@@ -1480,12 +1480,12 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
}
}
static class WeakPCL extends WeakReference implements
static class WeakPCL extends WeakReference<GTKLookAndFeel> implements
PropertyChangeListener {
private Toolkit kit;
private String key;
WeakPCL(Object target, Toolkit kit, String key) {
WeakPCL(GTKLookAndFeel target, Toolkit kit, String key) {
super(target, queue);
this.kit = kit;
this.key = key;
......@@ -1494,7 +1494,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
public String getKey() { return key; }
public void propertyChange(final PropertyChangeEvent pce) {
final GTKLookAndFeel lnf = (GTKLookAndFeel)get();
final GTKLookAndFeel lnf = get();
if (lnf == null || UIManager.getLookAndFeel() != lnf) {
// The property was GC'ed, we're no longer interested in
......
......@@ -86,7 +86,7 @@ public class ImageIcon implements Icon, Serializable, Accessible {
static {
component = new Component() {};
AccessController.doPrivileged(new PrivilegedAction() {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try {
// 6482575 - clear the appContext field so as not to leak it
......
......@@ -78,7 +78,7 @@ import javax.swing.text.*;
* @author James Gosling
* @author Lynn Monsanto (accessibility)
*/
public class ProgressMonitor extends Object implements Accessible
public class ProgressMonitor implements Accessible
{
private ProgressMonitor root;
private JDialog dialog;
......@@ -186,7 +186,7 @@ public class ProgressMonitor extends Object implements Accessible
}
if (window instanceof SwingUtilities.SharedOwnerFrame) {
WindowListener ownerShutdownListener =
(WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener();
SwingUtilities.getSharedOwnerFrameShutdownListener();
dialog.addWindowListener(ownerShutdownListener);
}
Container contentPane = dialog.getContentPane();
......@@ -273,7 +273,7 @@ public class ProgressMonitor extends Object implements Accessible
if (dT >= millisToDecideToPopup) {
int predictedCompletionTime;
if (nv > min) {
predictedCompletionTime = (int)((long)dT *
predictedCompletionTime = (int)(dT *
(max - min) /
(nv - min));
}
......@@ -691,10 +691,7 @@ public class ProgressMonitor extends Object implements Accessible
* object does not have an Accessible parent
*/
public Accessible getAccessibleParent() {
if (dialog != null) {
return (Accessible)dialog;
}
return null;
return dialog;
}
/*
......@@ -768,7 +765,7 @@ public class ProgressMonitor extends Object implements Accessible
if (myBar != null) {
Component c = myBar.getParent();
if (c instanceof Accessible) {
return ((Accessible)c).getAccessibleContext();
return c.getAccessibleContext();
}
}
return null;
......
......@@ -282,7 +282,7 @@ public abstract class SwingWorker<T, V> implements RunnableFuture<T> {
* is finished.
*/
DONE
};
}
/**
* Constructs this {@code SwingWorker}.
......@@ -825,7 +825,7 @@ public abstract class SwingWorker<T, V> implements RunnableFuture<T> {
}
private static class DoSubmitAccumulativeRunnable
extends AccumulativeRunnable<Runnable> implements ActionListener {
private final static int DELAY = (int) (1000 / 30);
private final static int DELAY = 1000 / 30;
@Override
protected void run(List<Runnable> args) {
for (Runnable runnable : args) {
......
......@@ -128,8 +128,7 @@ public class DefaultColorSelectionModel implements ColorSelectionModel, Serializ
* @since 1.4
*/
public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners(
ChangeListener.class);
return listenerList.getListeners(ChangeListener.class);
}
/**
......
......@@ -190,7 +190,7 @@ public class DefaultTableColumnModel implements TableColumnModel,
fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex));
return;
}
aColumn = (TableColumn)tableColumns.elementAt(columnIndex);
aColumn = tableColumns.elementAt(columnIndex);
tableColumns.removeElementAt(columnIndex);
boolean selected = selectionModel.isSelectedIndex(columnIndex);
......@@ -291,7 +291,7 @@ public class DefaultTableColumnModel implements TableColumnModel,
* at <code>columnIndex</code>
*/
public TableColumn getColumn(int columnIndex) {
return (TableColumn)tableColumns.elementAt(columnIndex);
return tableColumns.elementAt(columnIndex);
}
/**
......@@ -504,8 +504,7 @@ public class DefaultTableColumnModel implements TableColumnModel,
* @since 1.4
*/
public TableColumnModelListener[] getColumnModelListeners() {
return (TableColumnModelListener[])listenerList.getListeners(
TableColumnModelListener.class);
return listenerList.getListeners(TableColumnModelListener.class);
}
//
......
......@@ -84,7 +84,7 @@ import java.util.*;
*
* @author Rob Davis
*/
public class DefaultMutableTreeNode extends Object implements Cloneable,
public class DefaultMutableTreeNode implements Cloneable,
MutableTreeNode, Serializable
{
private static final long serialVersionUID = -4298474751201349152L;
......@@ -1251,7 +1251,7 @@ public class DefaultMutableTreeNode extends Object implements Cloneable,
* @return a copy of this node
*/
public Object clone() {
DefaultMutableTreeNode newNode = null;
DefaultMutableTreeNode newNode;
try {
newNode = (DefaultMutableTreeNode)super.clone();
......@@ -1297,24 +1297,22 @@ public class DefaultMutableTreeNode extends Object implements Cloneable,
userObject = tValues[1];
}
final class PreorderEnumeration implements Enumeration<TreeNode> {
protected Stack stack;
private final class PreorderEnumeration implements Enumeration<TreeNode> {
private final Stack<Enumeration> stack = new Stack<Enumeration>();
public PreorderEnumeration(TreeNode rootNode) {
super();
Vector v = new Vector(1);
Vector<TreeNode> v = new Vector<TreeNode>(1);
v.addElement(rootNode); // PENDING: don't really need a vector
stack = new Stack();
stack.push(v.elements());
}
public boolean hasMoreElements() {
return (!stack.empty() &&
((Enumeration)stack.peek()).hasMoreElements());
return (!stack.empty() && stack.peek().hasMoreElements());
}
public TreeNode nextElement() {
Enumeration enumer = (Enumeration)stack.peek();
Enumeration enumer = stack.peek();
TreeNode node = (TreeNode)enumer.nextElement();
Enumeration children = node.children();
......@@ -1353,8 +1351,7 @@ public class DefaultMutableTreeNode extends Object implements Cloneable,
if (subtree.hasMoreElements()) {
retval = subtree.nextElement();
} else if (children.hasMoreElements()) {
subtree = new PostorderEnumeration(
(TreeNode)children.nextElement());
subtree = new PostorderEnumeration(children.nextElement());
retval = subtree.nextElement();
} else {
retval = root;
......@@ -1373,7 +1370,7 @@ public class DefaultMutableTreeNode extends Object implements Cloneable,
public BreadthFirstEnumeration(TreeNode rootNode) {
super();
Vector v = new Vector(1);
Vector<TreeNode> v = new Vector<TreeNode>(1);
v.addElement(rootNode); // PENDING: don't really need a vector
queue = new Queue();
queue.enqueue(v.elements());
......
......@@ -59,7 +59,7 @@ public class CompoundEdit extends AbstractUndoableEdit {
super.undo();
int i = edits.size();
while (i-- > 0) {
UndoableEdit e = (UndoableEdit)edits.elementAt(i);
UndoableEdit e = edits.elementAt(i);
e.undo();
}
}
......@@ -85,7 +85,7 @@ public class CompoundEdit extends AbstractUndoableEdit {
protected UndoableEdit lastEdit() {
int count = edits.size();
if (count > 0)
return (UndoableEdit)edits.elementAt(count-1);
return edits.elementAt(count-1);
else
return null;
}
......@@ -98,7 +98,7 @@ public class CompoundEdit extends AbstractUndoableEdit {
int size = edits.size();
for (int i = size-1; i >= 0; i--)
{
UndoableEdit e = (UndoableEdit)edits.elementAt(i);
UndoableEdit e = edits.elementAt(i);
// System.out.println("CompoundEdit(" + i + "): Discarding " +
// e.getUndoPresentationName());
e.die();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册