1 package net.sourceforge.pmd.util.viewer.gui;
2
3 import net.sourceforge.pmd.util.viewer.util.NLS;
4
5 import javax.swing.*;
6 import java.awt.*;
7 import java.awt.event.ActionEvent;
8 import java.awt.event.ActionListener;
9
10
11 /***
12 * handles parsing exceptions
13 *
14 * @author Boris Gruschko ( boris at gruschko.org )
15 * @version $Id: ParseExceptionHandler.java,v 1.3 2004/04/15 18:21:58 tomcopeland Exp $
16 */
17 public class ParseExceptionHandler
18 extends JDialog
19 implements ActionListener
20 {
21 private Exception exc;
22 private JTextArea errorArea;
23 private JButton okBtn;
24
25 /***
26 * creates the dialog
27 *
28 * @param parent dialog's parent
29 * @param exc exception to be handled
30 */
31 public ParseExceptionHandler( JFrame parent, Exception exc )
32 {
33 super( parent, NLS.nls( "COMPILE_ERROR.DIALOG.TITLE" ), true );
34
35 this.exc = exc;
36
37 init( );
38 }
39
40 private void init( )
41 {
42 errorArea = new JTextArea( );
43 errorArea.setEditable( false );
44 errorArea.setText( exc.getMessage( ) + "\n" );
45
46 getContentPane( ).setLayout( new BorderLayout( ) );
47
48 JPanel messagePanel = new JPanel( new BorderLayout( ) );
49
50 messagePanel.setBorder(
51 BorderFactory.createCompoundBorder(
52 BorderFactory.createRaisedBevelBorder( ),
53 BorderFactory.createTitledBorder(
54 BorderFactory.createEtchedBorder( ),
55 NLS.nls( "COMPILE_ERROR.PANEL.TITLE" ) ) ) );
56
57 messagePanel.add( new JScrollPane( errorArea ), BorderLayout.CENTER );
58
59 getContentPane( ).add( messagePanel, BorderLayout.CENTER );
60
61 JPanel btnPane = new JPanel( new FlowLayout( FlowLayout.RIGHT ) );
62
63 okBtn = new JButton( NLS.nls( "COMPILE_ERROR.OK_BUTTON.CAPTION" ) );
64
65 okBtn.addActionListener( this );
66
67 btnPane.add( okBtn );
68
69 getRootPane( ).setDefaultButton( okBtn );
70
71 getContentPane( ).add( btnPane, BorderLayout.SOUTH );
72
73 pack( );
74
75 setLocationRelativeTo( getParent( ) );
76
77 setVisible( true );
78 }
79
80 /***
81 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
82 */
83 public void actionPerformed( ActionEvent e )
84 {
85 if ( e.getSource( ) == okBtn )
86 {
87 dispose( );
88 }
89 }
90 }
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113