Java language level migrations

This commit is contained in:
Hamidreza Bayat
2020-03-27 19:20:30 +04:30
parent 16b57176b6
commit c4575a67d9
9 changed files with 14 additions and 24 deletions

View File

@@ -138,7 +138,7 @@ public class AppletGUI extends javax.swing.JApplet implements GUIInterface {
NewGame.setText("New Game");
NewGame.setFocusable(false);
NewGame.addActionListener(evt -> NewGameActionPerformed(evt));
NewGame.addActionListener(this::NewGameActionPerformed);
SettingsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Settings"));
SettingsPanel.setFocusable(false);
@@ -161,15 +161,15 @@ public class AppletGUI extends javax.swing.JApplet implements GUIInterface {
TimeSlider.setPaintTicks(true);
TimeSlider.setValue(5);
TimeSlider.setFocusable(false);
TimeSlider.addChangeListener(evt -> TimeSliderStateChanged(evt));
TimeSlider.addChangeListener(this::TimeSliderStateChanged);
ShowThinking.setText("Show Thinking");
ShowThinking.setFocusable(false);
ShowThinking.addChangeListener(evt -> ShowThinkingStateChanged(evt));
ShowThinking.addChangeListener(this::ShowThinkingStateChanged);
FlipBoard.setText("Flip Board");
FlipBoard.setFocusable(false);
FlipBoard.addChangeListener(evt -> FlipBoardStateChanged(evt));
FlipBoard.addChangeListener(this::FlipBoardStateChanged);
javax.swing.GroupLayout SettingsPanelLayout = new javax.swing.GroupLayout(SettingsPanel);
SettingsPanel.setLayout(SettingsPanelLayout);
@@ -215,13 +215,13 @@ public class AppletGUI extends javax.swing.JApplet implements GUIInterface {
Forward.setDefaultCapable(false);
Forward.setFocusPainted(false);
Forward.setFocusable(false);
Forward.addActionListener(evt -> ForwardActionPerformed(evt));
Forward.addActionListener(this::ForwardActionPerformed);
Backward.setText("<-");
Backward.setDefaultCapable(false);
Backward.setFocusPainted(false);
Backward.setFocusable(false);
Backward.addActionListener(evt -> BackwardActionPerformed(evt));
Backward.addActionListener(this::BackwardActionPerformed);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);

View File

@@ -179,9 +179,7 @@ public class ChessBoardPainter extends JLabel {
try {
Font font = Font.createFont(Font.TRUETYPE_FONT, inStream);
chessFont = font.deriveFont((float)sqSize);
} catch (FontFormatException ex) {
throw new RuntimeException();
} catch (IOException ex) {
} catch (FontFormatException | IOException ex) {
throw new RuntimeException();
}
}

View File

@@ -147,12 +147,9 @@ public class TUIGame extends Game {
return false;
} catch (IOException ex) {
System.out.printf("IO error: %s\n", ex.getMessage());
} catch (ChessParseError cpe) {
} catch (ChessParseError | StringIndexOutOfBoundsException cpe) {
int lineNo = (fr == null) ? -1 : fr.getLineNumber();
System.out.printf("Parse error, line %d: %s\n", lineNo, cpe.getMessage());
} catch (StringIndexOutOfBoundsException e) {
int lineNo = (fr == null) ? -1 : fr.getLineNumber();
System.out.printf("Parse error, line %d: %s\n", lineNo, e.getMessage());
} finally {
if (fr != null) {
try {

View File

@@ -199,9 +199,7 @@ public class UCIProtocol {
}
quit = true;
}
} catch (ChessParseError ignore) {
} catch (ArrayIndexOutOfBoundsException ignore) {
} catch (NumberFormatException ignore) {
} catch (ChessParseError | ArrayIndexOutOfBoundsException | NumberFormatException ignore) {
}
}