Skip to content

Commit

Permalink
8043548: Fix raw and unchecked lint warnings in javax.swing.plaf.*
Browse files Browse the repository at this point in the history
8042849: Fix raw and unchecked warnings in com.sun.java.swing

Reviewed-by: pchelko, alexsch
  • Loading branch information
jddarcy committed Jul 3, 2014
1 parent 3bb2f8e commit 52f8e9c
Show file tree
Hide file tree
Showing 91 changed files with 991 additions and 999 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ class GTKFileChooserUI extends SynthFileChooserUI {
private String renameFileErrorTitle = null;
private String renameFileErrorText = null;

private JComboBox filterComboBox;
private JComboBox<FileFilter> filterComboBox;
private FilterComboBoxModel filterComboBoxModel;

// From Motif

private JPanel rightPanel;
private JList directoryList;
private JList fileList;
private JList<File> directoryList;
private JList<File> fileList;

private JLabel pathField;
private JTextField fileNameTextField;
Expand All @@ -116,7 +116,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
private int pathLabelMnemonic = 0;
private int filterLabelMnemonic = 0;

private JComboBox directoryComboBox;
private JComboBox<File> directoryComboBox;
private DirectoryComboBoxModel directoryComboBoxModel;
private Action directoryComboBoxAction = new DirectoryComboBoxAction();
private JPanel bottomButtonPanel;
Expand Down Expand Up @@ -153,7 +153,7 @@ public String getFileName() {
}

int mode = fc.getFileSelectionMode();
JList list = mode == JFileChooser.DIRECTORIES_ONLY ?
JList<File> list = mode == JFileChooser.DIRECTORIES_ONLY ?
directoryList : fileList;
Object[] files = list.getSelectedValues();
int len = files.length;
Expand Down Expand Up @@ -369,8 +369,8 @@ public ListSelectionListener createListSelectionListener(JFileChooser fc) {
}

class DoubleClickListener extends MouseAdapter {
JList list;
public DoubleClickListener(JList list) {
JList<?> list;
public DoubleClickListener(JList<?> list) {
this.list = list;
}

Expand Down Expand Up @@ -413,7 +413,7 @@ public void mouseEntered(MouseEvent evt) {
}
}

protected MouseListener createDoubleClickListener(JFileChooser fc, JList list) {
protected MouseListener createDoubleClickListener(JFileChooser fc, JList<?> list) {
return new DoubleClickListener(list);
}

Expand All @@ -423,7 +423,7 @@ protected class SelectionListener implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
JFileChooser chooser = getFileChooser();
JList list = (JList) e.getSource();
JList<?> list = (JList) e.getSource();

if (chooser.isMultiSelectionEnabled()) {
File[] files = null;
Expand Down Expand Up @@ -554,7 +554,7 @@ public void installComponents(JFileChooser fc) {
0, 0) {
public void layoutContainer(Container target) {
super.layoutContainer(target);
JComboBox comboBox = directoryComboBox;
JComboBox<?> comboBox = directoryComboBox;
if (comboBox.getWidth() > target.getWidth()) {
comboBox.setBounds(0, comboBox.getY(), target.getWidth(),
comboBox.getHeight());
Expand All @@ -565,7 +565,7 @@ public void layoutContainer(Container target) {
comboBoxPanel.setName("GTKFileChooser.directoryComboBoxPanel");
// CurrentDir ComboBox
directoryComboBoxModel = createDirectoryComboBoxModel(fc);
directoryComboBox = new JComboBox(directoryComboBoxModel);
directoryComboBox = new JComboBox<>(directoryComboBoxModel);
directoryComboBox.setName("GTKFileChooser.directoryComboBox");
directoryComboBox.putClientProperty( "JComboBox.lightweightKeyboardNavigation", "Lightweight" );
directoryComboBox.addActionListener(directoryComboBoxAction);
Expand Down Expand Up @@ -710,7 +710,7 @@ public Dimension getMaximumSize() {

filterComboBoxModel = createFilterComboBoxModel();
fc.addPropertyChangeListener(filterComboBoxModel);
filterComboBox = new JComboBox(filterComboBoxModel);
filterComboBox = new JComboBox<>(filterComboBoxModel);
filterComboBox.setRenderer(createFilterComboBoxRenderer());
filterLabel.setLabelFor(filterComboBox);

Expand Down Expand Up @@ -851,7 +851,7 @@ protected void uninstallStrings(JFileChooser fc) {
}

protected JScrollPane createFilesList() {
fileList = new JList();
fileList = new JList<>();
fileList.setName("GTKFileChooser.fileList");
fileList.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, filesLabelText);

Expand All @@ -877,7 +877,7 @@ protected JScrollPane createFilesList() {
}

protected JScrollPane createDirectoryList() {
directoryList = new JList();
directoryList = new JList<>();
directoryList.setName("GTKFileChooser.directoryList");
directoryList.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, foldersLabelText);
align(directoryList);
Expand Down Expand Up @@ -930,7 +930,7 @@ protected void sort(Vector<? extends File> v) {
}

@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class GTKDirectoryListModel extends AbstractListModel implements ListDataListener {
protected class GTKDirectoryListModel extends AbstractListModel<File> implements ListDataListener {
File curDir;
public GTKDirectoryListModel() {
getModel().addListDataListener(this);
Expand All @@ -941,7 +941,8 @@ public int getSize() {
return getModel().getDirectories().size() + 1;
}

public Object getElementAt(int index) {
@Override
public File getElementAt(int index) {
return index > 0 ? getModel().getDirectories().elementAt(index - 1):
curDir;
}
Expand Down Expand Up @@ -974,7 +975,7 @@ private void directoryChanged() {
}

@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class GTKFileListModel extends AbstractListModel implements ListDataListener {
protected class GTKFileListModel extends AbstractListModel<File> implements ListDataListener {
public GTKFileListModel() {
getModel().addListDataListener(this);
}
Expand All @@ -991,7 +992,8 @@ public int indexOf(Object o) {
return getModel().getFiles().indexOf(o);
}

public Object getElementAt(int index) {
@Override
public File getElementAt(int index) {
return getModel().getFiles().elementAt(index);
}

Expand Down Expand Up @@ -1019,7 +1021,7 @@ public void contentsChanged(ListDataEvent e) {

@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class FileCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index,
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {

super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Expand All @@ -1033,7 +1035,7 @@ public Component getListCellRendererComponent(JList list, Object value, int inde

@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class DirectoryCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index,
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {

super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Expand Down Expand Up @@ -1095,7 +1097,7 @@ protected DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc) {
* Data model for a type-face selection combo-box.
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
protected class DirectoryComboBoxModel extends AbstractListModel<File> implements ComboBoxModel<File> {
Vector<File> directories = new Vector<File>();
File selectedDirectory = null;
JFileChooser chooser = getFileChooser();
Expand Down Expand Up @@ -1163,7 +1165,8 @@ public int getSize() {
return directories.size();
}

public Object getElementAt(int index) {
@Override
public File getElementAt(int index) {
return directories.elementAt(index);
}
}
Expand Down Expand Up @@ -1314,7 +1317,7 @@ public String getName() {
return name;
}

public Component getListCellRendererComponent(JList list, Object value,
public Component getListCellRendererComponent(JList<?> list, Object value,
int index, boolean isSelected,
boolean cellHasFocus) {

Expand Down Expand Up @@ -1345,8 +1348,8 @@ protected FilterComboBoxModel createFilterComboBoxModel() {
* Data model for filter combo-box.
*/
@SuppressWarnings("serial") // JDK implementation class
protected class FilterComboBoxModel extends AbstractListModel
implements ComboBoxModel, PropertyChangeListener {
protected class FilterComboBoxModel extends AbstractListModel<FileFilter>
implements ComboBoxModel<FileFilter>, PropertyChangeListener {
protected FileFilter[] filters;

protected FilterComboBoxModel() {
Expand Down Expand Up @@ -1400,7 +1403,8 @@ public int getSize() {
}
}

public Object getElementAt(int index) {
@Override
public FileFilter getElementAt(int index) {
if (index > getSize() - 1) {
// This shouldn't happen. Try to recover gracefully.
return getFileChooser().getFileFilter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -151,7 +151,7 @@ static void resetIcons() {

private static class DelegatingIcon extends SynthIcon implements
UIResource {
private static final Class[] PARAM_TYPES = new Class[] {
private static final Class<?>[] PARAM_TYPES = new Class<?>[] {
SynthContext.class, Graphics.class, int.class,
int.class, int.class, int.class, int.class
};
Expand Down Expand Up @@ -190,7 +190,7 @@ protected Method getMethod() {
return (Method)method;
}

protected Class[] getMethodParamTypes() {
protected Class<?>[] getMethodParamTypes() {
return PARAM_TYPES;
}

Expand Down Expand Up @@ -262,7 +262,7 @@ private void updateSizeIfNecessary(SynthContext context) {
// we create a unique icon per ToolBar and lookup the style for the
// HandleBox.
private static class ToolBarHandleIcon extends DelegatingIcon {
private static final Class[] PARAM_TYPES = new Class[] {
private static final Class<?>[] PARAM_TYPES = new Class<?>[] {
SynthContext.class, Graphics.class, int.class,
int.class, int.class, int.class, int.class, Orientation.class,
};
Expand All @@ -273,7 +273,7 @@ public ToolBarHandleIcon() {
super(TOOL_BAR_HANDLE_ICON);
}

protected Class[] getMethodParamTypes() {
protected Class<?>[] getMethodParamTypes() {
return PARAM_TYPES;
}

Expand Down Expand Up @@ -323,7 +323,7 @@ public int getIconHeight(SynthContext context) {
}

private static class MenuArrowIcon extends DelegatingIcon {
private static final Class[] PARAM_TYPES = new Class[] {
private static final Class<?>[] PARAM_TYPES = new Class<?>[] {
SynthContext.class, Graphics.class, int.class,
int.class, int.class, int.class, int.class, ArrowType.class,
};
Expand All @@ -332,7 +332,7 @@ public MenuArrowIcon() {
super(MENU_ARROW_ICON);
}

protected Class[] getMethodParamTypes() {
protected Class<?>[] getMethodParamTypes() {
return PARAM_TYPES;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1086,13 +1086,13 @@ static class GTKLazyValue implements UIDefaults.LazyValue {

public Object createValue(UIDefaults table) {
try {
Class c = Class.forName(className, true,Thread.currentThread().
getContextClassLoader());
Class<?> c = Class.forName(className, true,Thread.currentThread().
getContextClassLoader());

if (methodName == null) {
return c.newInstance();
}
Method m = c.getMethod(methodName, (Class[])null);
Method m = c.getMethod(methodName, (Class<?>[])null);

return m.invoke(c, (Object[])null);
} catch (ClassNotFoundException cnfe) {
Expand Down
10 changes: 5 additions & 5 deletions jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -764,7 +764,7 @@ public void layoutContainer(Container c) {
} else {
return;
}
Map gm = getFrameGeometry();
Map<String, Object> gm = getFrameGeometry();

int w = titlePane.getWidth();
int h = titlePane.getHeight();
Expand Down Expand Up @@ -828,11 +828,11 @@ public void layoutContainer(Container c) {
}
} // end TitlePaneLayout

protected Map getFrameGeometry() {
protected Map<String, Object> getFrameGeometry() {
return frameGeometry;
}

protected void setFrameGeometry(JComponent titlePane, Map gm) {
protected void setFrameGeometry(JComponent titlePane, Map<String, Object> gm) {
this.frameGeometry = gm;
if (getInt("top_height") == 0 && titlePane != null) {
gm.put("top_height", Integer.valueOf(titlePane.getHeight()));
Expand Down Expand Up @@ -1501,7 +1501,7 @@ private void updateFrameGeometry(SynthContext context) {
"name", getStringAttr(frame, "style")
});
if (frame_style != null) {
Map gm = frameGeometries.get(getStringAttr(frame_style, "geometry"));
Map<String, Object> gm = frameGeometries.get(getStringAttr(frame_style, "geometry"));

setFrameGeometry(titlePane, gm);
}
Expand Down
10 changes: 4 additions & 6 deletions jdk/src/share/classes/com/sun/java/swing/plaf/gtk/XColors.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,7 @@
*/
class XColors {

private static class XColor implements Comparable {
private static class XColor implements Comparable<XColor> {
String name;

int red;
Expand All @@ -52,10 +52,8 @@ Color toColor() {
return new ColorUIResource(red, green, blue);
}

public int compareTo(Object o) {
XColor other = (XColor)o;

return name.compareTo(other.name);
public int compareTo(XColor o) {
return name.compareTo(o.name);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected ComboPopup createPopup() {
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class MotifComboPopup extends BasicComboPopup {

public MotifComboPopup( JComboBox comboBox ) {
public MotifComboPopup( JComboBox<Object> comboBox ) {
super( comboBox );
}

Expand Down Expand Up @@ -177,7 +177,7 @@ public void paint(Graphics g, JComponent c) {
}

public void paintCurrentValue(Graphics g,Rectangle bounds,boolean hasFocus) {
ListCellRenderer renderer = comboBox.getRenderer();
ListCellRenderer<Object> renderer = comboBox.getRenderer();
Component c;
Dimension d;
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
Expand Down
Loading

0 comments on commit 52f8e9c

Please sign in to comment.