diff options
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java b/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java index 7e66ecde..3921b513 100644 --- a/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java +++ b/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java | |||
| @@ -19,6 +19,9 @@ import javax.swing.*; | |||
| 19 | import java.awt.*; | 19 | import java.awt.*; |
| 20 | import java.io.PrintWriter; | 20 | import java.io.PrintWriter; |
| 21 | import java.io.StringWriter; | 21 | import java.io.StringWriter; |
| 22 | import java.io.FileWriter; | ||
| 23 | import java.io.File; | ||
| 24 | import java.io.IOException; | ||
| 22 | 25 | ||
| 23 | public class CrashDialog { | 26 | public class CrashDialog { |
| 24 | 27 | ||
| @@ -44,9 +47,24 @@ public class CrashDialog { | |||
| 44 | 47 | ||
| 45 | // buttons panel | 48 | // buttons panel |
| 46 | JPanel buttonsPanel = new JPanel(); | 49 | JPanel buttonsPanel = new JPanel(); |
| 47 | FlowLayout buttonsLayout = new FlowLayout(); | 50 | buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS)); |
| 48 | buttonsLayout.setAlignment(FlowLayout.RIGHT); | 51 | JButton exportButton = new JButton(I18n.translate("crash.export")); |
| 49 | buttonsPanel.setLayout(buttonsLayout); | 52 | exportButton.addActionListener(event -> { |
| 53 | JFileChooser chooser = new JFileChooser(); | ||
| 54 | chooser.setSelectedFile(new File("enigma_crash.log")); | ||
| 55 | if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { | ||
| 56 | try { | ||
| 57 | File file = chooser.getSelectedFile(); | ||
| 58 | FileWriter writer = new FileWriter(file); | ||
| 59 | writer.write(instance.text.getText()); | ||
| 60 | writer.close(); | ||
| 61 | } catch (IOException ex) { | ||
| 62 | ex.printStackTrace(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | }); | ||
| 66 | buttonsPanel.add(exportButton); | ||
| 67 | buttonsPanel.add(Box.createHorizontalGlue()); | ||
| 50 | buttonsPanel.add(Utils.unboldLabel(new JLabel(I18n.translate("crash.exit.warning")))); | 68 | buttonsPanel.add(Utils.unboldLabel(new JLabel(I18n.translate("crash.exit.warning")))); |
| 51 | JButton ignoreButton = new JButton(I18n.translate("crash.ignore")); | 69 | JButton ignoreButton = new JButton(I18n.translate("crash.ignore")); |
| 52 | ignoreButton.addActionListener(event -> { | 70 | ignoreButton.addActionListener(event -> { |