From b4aaff683d78ab92b83f3a7257c33b8e27d1affa Mon Sep 17 00:00:00 2001 From: Thog Date: Tue, 7 Mar 2017 21:24:39 +0100 Subject: Drop unix case style and implement hashCode when equals is overrided Also update Guava to version 21 --- .../java/cuchaz/enigma/gui/dialog/CrashDialog.java | 32 +++++++++++----------- .../cuchaz/enigma/gui/dialog/ProgressDialog.java | 16 +++++------ 2 files changed, 23 insertions(+), 25 deletions(-) (limited to 'src/main/java/cuchaz/enigma/gui/dialog') diff --git a/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java b/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java index 8d3df47..5c1d9ff 100644 --- a/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java +++ b/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java @@ -23,15 +23,15 @@ import cuchaz.enigma.utils.Utils; public class CrashDialog { - private static CrashDialog m_instance = null; + private static CrashDialog instance = null; - private JFrame m_frame; - private JTextArea m_text; + private JFrame frame; + private JTextArea text; private CrashDialog(JFrame parent) { // init frame - m_frame = new JFrame(Constants.NAME + " - Crash Report"); - final Container pane = m_frame.getContentPane(); + frame = new JFrame(Constants.NAME + " - Crash Report"); + final Container pane = frame.getContentPane(); pane.setLayout(new BorderLayout()); JLabel label = new JLabel(Constants.NAME + " has crashed! =("); @@ -39,9 +39,9 @@ public class CrashDialog { pane.add(label, BorderLayout.NORTH); // report panel - m_text = new JTextArea(); - m_text.setTabSize(2); - pane.add(new JScrollPane(m_text), BorderLayout.CENTER); + text = new JTextArea(); + text.setTabSize(2); + pane.add(new JScrollPane(text), BorderLayout.CENTER); // buttons panel JPanel buttonsPanel = new JPanel(); @@ -52,7 +52,7 @@ public class CrashDialog { JButton ignoreButton = new JButton("Ignore"); ignoreButton.addActionListener(event -> { // close (hide) the dialog - m_frame.setVisible(false); + frame.setVisible(false); }); buttonsPanel.add(ignoreButton); JButton exitButton = new JButton("Exit"); @@ -64,13 +64,13 @@ public class CrashDialog { pane.add(buttonsPanel, BorderLayout.SOUTH); // show the frame - m_frame.setSize(600, 400); - m_frame.setLocationRelativeTo(parent); - m_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + frame.setSize(600, 400); + frame.setLocationRelativeTo(parent); + frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); } public static void init(JFrame parent) { - m_instance = new CrashDialog(parent); + instance = new CrashDialog(parent); } public static void show(Throwable ex) { @@ -80,8 +80,8 @@ public class CrashDialog { String report = buf.toString(); // show it! - m_instance.m_text.setText(report); - m_instance.m_frame.doLayout(); - m_instance.m_frame.setVisible(true); + instance.text.setText(report); + instance.frame.doLayout(); + instance.frame.setVisible(true); } } diff --git a/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java b/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java index c752c86..8df22a7 100644 --- a/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java +++ b/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java @@ -87,15 +87,13 @@ public class ProgressDialog implements ProgressListener, AutoCloseable { } public static void runInThread(final JFrame parent, final ProgressRunnable runnable) { - new Thread() { - @Override - public void run() { - try (ProgressDialog progress = new ProgressDialog(parent)) { - runnable.run(progress); - } catch (Exception ex) { - throw new Error(ex); - } + new Thread(() -> + { + try (ProgressDialog progress = new ProgressDialog(parent)) { + runnable.run(progress); + } catch (Exception ex) { + throw new Error(ex); } - }.start(); + }).start(); } } -- cgit v1.2.3