From 959cb5fd4f9586ec3bd265b452fe25fe1db82e3f Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 13 Jan 2015 23:25:04 -0500 Subject: source format change don't hate me too much if you were planning a big merge. =P --- src/cuchaz/enigma/gui/CrashDialog.java | 77 ++++++++++++++++------------------ 1 file changed, 35 insertions(+), 42 deletions(-) (limited to 'src/cuchaz/enigma/gui/CrashDialog.java') diff --git a/src/cuchaz/enigma/gui/CrashDialog.java b/src/cuchaz/enigma/gui/CrashDialog.java index 0eb9830..360091a 100644 --- a/src/cuchaz/enigma/gui/CrashDialog.java +++ b/src/cuchaz/enigma/gui/CrashDialog.java @@ -29,80 +29,73 @@ import javax.swing.WindowConstants; import cuchaz.enigma.Constants; -public class CrashDialog -{ +public class CrashDialog { + private static CrashDialog m_instance = null; private JFrame m_frame; private JTextArea m_text; - private CrashDialog( JFrame parent ) - { + private CrashDialog(JFrame parent) { // init frame - m_frame = new JFrame( Constants.Name + " - Crash Report" ); + m_frame = new JFrame(Constants.Name + " - Crash Report"); final Container pane = m_frame.getContentPane(); - pane.setLayout( new BorderLayout() ); + 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 ); + 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 ); + 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( new ActionListener( ) - { + 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(new ActionListener() { @Override - public void actionPerformed( ActionEvent event ) - { + public void actionPerformed(ActionEvent event) { // close (hide) the dialog - m_frame.setVisible( false ); + m_frame.setVisible(false); } - } ); - buttonsPanel.add( ignoreButton ); - JButton exitButton = new JButton( "Exit" ); - exitButton.addActionListener( new ActionListener( ) - { + }); + buttonsPanel.add(ignoreButton); + JButton exitButton = new JButton("Exit"); + exitButton.addActionListener(new ActionListener() { @Override - public void actionPerformed( ActionEvent event ) - { + public void actionPerformed(ActionEvent event) { // exit enigma - System.exit( 1 ); + System.exit(1); } - } ); - buttonsPanel.add( exitButton ); - pane.add( buttonsPanel, BorderLayout.SOUTH ); + }); + 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 ); + 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 init(JFrame parent) { + m_instance = new CrashDialog(parent); } - public static void show( Throwable ex ) - { + public static void show(Throwable ex) { // get the error report StringWriter buf = new StringWriter(); - ex.printStackTrace( new PrintWriter( buf ) ); + ex.printStackTrace(new PrintWriter(buf)); String report = buf.toString(); // show it! - m_instance.m_text.setText( report ); + m_instance.m_text.setText(report); m_instance.m_frame.doLayout(); - m_instance.m_frame.setVisible( true ); + m_instance.m_frame.setVisible(true); } } -- cgit v1.2.3