From 9a3e5a9d132735f818c379ba72c554362650690d Mon Sep 17 00:00:00 2001 From: lclc98 Date: Sun, 3 Jul 2016 00:05:04 +1000 Subject: Started Gui Refactor --- src/main/java/cuchaz/enigma/gui/CrashDialog.java | 86 ------------------------ 1 file changed, 86 deletions(-) delete mode 100644 src/main/java/cuchaz/enigma/gui/CrashDialog.java (limited to 'src/main/java/cuchaz/enigma/gui/CrashDialog.java') diff --git a/src/main/java/cuchaz/enigma/gui/CrashDialog.java b/src/main/java/cuchaz/enigma/gui/CrashDialog.java deleted file mode 100644 index 3806f54..0000000 --- a/src/main/java/cuchaz/enigma/gui/CrashDialog.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - *
- * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ -package cuchaz.enigma.gui; - -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.FlowLayout; -import java.io.PrintWriter; -import java.io.StringWriter; - -import javax.swing.*; - -import cuchaz.enigma.Constants; - -public class CrashDialog { - - private static CrashDialog m_instance = null; - - private JFrame m_frame; - private JTextArea m_text; - - private CrashDialog(JFrame parent) { - // init frame - m_frame = new JFrame(Constants.NAME + " - Crash Report"); - final Container pane = m_frame.getContentPane(); - pane.setLayout(new BorderLayout()); - - JLabel label = new JLabel(Constants.NAME + " has crashed! =("); - label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - pane.add(label, BorderLayout.NORTH); - - // report panel - m_text = new JTextArea(); - m_text.setTabSize(2); - pane.add(new JScrollPane(m_text), BorderLayout.CENTER); - - // buttons panel - JPanel buttonsPanel = new JPanel(); - FlowLayout buttonsLayout = new FlowLayout(); - buttonsLayout.setAlignment(FlowLayout.RIGHT); - buttonsPanel.setLayout(buttonsLayout); - buttonsPanel.add(GuiTricks.unboldLabel(new JLabel("If you choose exit, you will lose any unsaved work."))); - JButton ignoreButton = new JButton("Ignore"); - ignoreButton.addActionListener(event -> { - // close (hide) the dialog - m_frame.setVisible(false); - }); - buttonsPanel.add(ignoreButton); - JButton exitButton = new JButton("Exit"); - exitButton.addActionListener(event -> { - // exit enigma - System.exit(1); - }); - buttonsPanel.add(exitButton); - 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); - } - - public static void init(JFrame parent) { - m_instance = new CrashDialog(parent); - } - - public static void show(Throwable ex) { - // get the error report - StringWriter buf = new StringWriter(); - ex.printStackTrace(new PrintWriter(buf)); - String report = buf.toString(); - - // show it! - m_instance.m_text.setText(report); - m_instance.m_frame.doLayout(); - m_instance.m_frame.setVisible(true); - } -} -- cgit v1.2.3