From b5eb509759bd3e539d80353f332549f94021c105 Mon Sep 17 00:00:00 2001 From: samschreiber Date: Thu, 24 Oct 2013 00:02:38 -0700 Subject: [PATCH] Switch to using Java 7, and clean up the compiler warnings around JComboBox that result from the switch. --- .settings/org.eclipse.jdt.core.prefs | 7 +++---- src/org/ggp/base/apps/kiosk/Kiosk.java | 8 ++++---- src/org/ggp/base/apps/player/Player.java | 4 ++-- src/org/ggp/base/apps/server/Server.java | 8 ++++---- src/org/ggp/base/util/ui/GameSelector.java | 12 ++++++------ src/org/ggp/base/util/ui/PlayerSelector.java | 16 ++++++++-------- 6 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index c5ac048ca..7341ab168 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,11 @@ -#Tue Apr 13 23:54:04 PDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/src/org/ggp/base/apps/kiosk/Kiosk.java b/src/org/ggp/base/apps/kiosk/Kiosk.java index 7351db70f..c700d8227 100644 --- a/src/org/ggp/base/apps/kiosk/Kiosk.java +++ b/src/org/ggp/base/apps/kiosk/Kiosk.java @@ -84,14 +84,14 @@ public void run() { private final JTextField startClockTextField; private final JButton runButton; - private final JList selectedGame; + private final JList selectedGame; private final JCheckBox flipRoles; private final PublishButton publishButton; private final JPanel theGUIPanel; - private final JComboBox playerComboBox; + private final JComboBox playerComboBox; private List> gamers = null; private final JTextField computerAddress; @@ -118,13 +118,13 @@ public Kiosk() flipRoles = new JCheckBox("Flip roles?"); - selectedGame = new JList(theAvailableGames.toArray()); + selectedGame = new JList(theAvailableGames.toArray(new AvailableGame[0])); selectedGame.setSelectedIndex(0); selectedGame.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane selectedGamePane = new JScrollPane(selectedGame); computerAddress = new JTextField("player.ggp.org:80"); - playerComboBox = new JComboBox(); + playerComboBox = new JComboBox(); playerComboBox.addItemListener(this); gamers = ProjectSearcher.getAllClassesThatAre(Gamer.class); diff --git a/src/org/ggp/base/apps/player/Player.java b/src/org/ggp/base/apps/player/Player.java index e3138aaa1..8c7e420c8 100644 --- a/src/org/ggp/base/apps/player/Player.java +++ b/src/org/ggp/base/apps/player/Player.java @@ -64,7 +64,7 @@ public void run() private final JTextField portTextField; - private final JComboBox typeComboBox; + private final JComboBox typeComboBox; private Integer defaultPort = 9147; @@ -75,7 +75,7 @@ public Player() super(new GridBagLayout()); portTextField = new JTextField(defaultPort.toString()); - typeComboBox = new JComboBox(); + typeComboBox = new JComboBox(); createButton = new JButton(createButtonMethod()); playersTabbedPane = new JTabbedPane(); diff --git a/src/org/ggp/base/apps/server/Server.java b/src/org/ggp/base/apps/server/Server.java index 0f134c878..a8c55481b 100644 --- a/src/org/ggp/base/apps/server/Server.java +++ b/src/org/ggp/base/apps/server/Server.java @@ -84,7 +84,7 @@ public void run() private final SchedulingPanel schedulingPanel; private final LeaderboardPanel leaderboardPanel; - private final List playerFields; + private final List> playerFields; private final List roleLabels; private final JButton runButton; @@ -100,7 +100,7 @@ public void run() private final GameSelector gameSelector; private final PlayerSelector playerSelector; - private final JList playerSelectorList; + private final JList playerSelectorList; private final Scheduler scheduler; @@ -119,7 +119,7 @@ public Server() playersPanel = new JPanel(new GridBagLayout()); roleLabels = new ArrayList(); - playerFields = new ArrayList(); + playerFields = new ArrayList>(); theGame = null; shouldScramble = new JCheckBox("Scramble GDL?", true); @@ -237,7 +237,7 @@ public void actionPerformed(ActionEvent evt) { int playClock = (Integer)playClockSpinner.getValue(); List thePlayers = new ArrayList(); - for (JComboBox playerField : playerFields) { + for (JComboBox playerField : playerFields) { String name = playerField.getSelectedItem().toString(); thePlayers.add(playerSelector.getPlayerPresence(name)); } diff --git a/src/org/ggp/base/util/ui/GameSelector.java b/src/org/ggp/base/util/ui/GameSelector.java index 55d2a2d5f..285ca407b 100644 --- a/src/org/ggp/base/util/ui/GameSelector.java +++ b/src/org/ggp/base/util/ui/GameSelector.java @@ -26,8 +26,8 @@ * @author Sam Schreiber */ public class GameSelector implements ActionListener { - JComboBox theGameList; - JComboBox theRepositoryList; + JComboBox theGameList; + JComboBox theRepositoryList; GameRepository theSelectedRepository; Map theCachedRepositories; @@ -47,10 +47,10 @@ public String toString() { } public GameSelector() { - theGameList = new JComboBox(); + theGameList = new JComboBox(); theGameList.addActionListener(this); - theRepositoryList = new JComboBox(); + theRepositoryList = new JComboBox(); theRepositoryList.addActionListener(this); theCachedRepositories = new HashMap(); @@ -102,11 +102,11 @@ public void repopulateGameList() { } } - public JComboBox getRepositoryList() { + public JComboBox getRepositoryList() { return theRepositoryList; } - public JComboBox getGameList() { + public JComboBox getGameList() { return theGameList; } diff --git a/src/org/ggp/base/util/ui/PlayerSelector.java b/src/org/ggp/base/util/ui/PlayerSelector.java index 586923649..00a9904f7 100644 --- a/src/org/ggp/base/util/ui/PlayerSelector.java +++ b/src/org/ggp/base/util/ui/PlayerSelector.java @@ -25,7 +25,7 @@ public PlayerSelector() { thePresenceManager = new PlayerPresenceManager(); } - class PlayerPresenceLabel extends JLabel implements ListCellRenderer { + class PlayerPresenceLabel extends JLabel implements ListCellRenderer { private static final long serialVersionUID = 1L; private int maxLabelLength; @@ -37,8 +37,8 @@ public PlayerPresenceLabel(int maxLabelLength) { } public Component getListCellRendererComponent( - JList list, - Object value, + JList list, + String value, int index, boolean isSelected, boolean cellHasFocus) { @@ -90,7 +90,7 @@ public Component getListCellRendererComponent( } } - class PlayerSelectorBox extends JComboBox implements Observer { + class PlayerSelectorBox extends JComboBox implements Observer { private static final long serialVersionUID = 1L; public PlayerSelectorBox() { @@ -122,7 +122,7 @@ public void observe(Event event) { } } - class PlayerSelectorList extends JList implements Observer { + class PlayerSelectorList extends JList implements Observer { private static final long serialVersionUID = 1L; public PlayerSelectorList() { @@ -133,7 +133,7 @@ public PlayerSelectorList() { } private void setAllPlayerItems() { - setListData(thePresenceManager.getSortedPlayerNames().toArray()); + setListData(thePresenceManager.getSortedPlayerNames().toArray(new String[0])); } @Override @@ -164,11 +164,11 @@ public PlayerPresence getPlayerPresence(String name) { return thePresenceManager.getPresence(name); } - public JComboBox getPlayerSelectorBox() { + public JComboBox getPlayerSelectorBox() { return new PlayerSelectorBox(); } - public JList getPlayerSelectorList() { + public JList getPlayerSelectorList() { return new PlayerSelectorList(); } } \ No newline at end of file