1
2
3
4 package net.sourceforge.pmd.util.viewer.gui;
5
6 import java.awt.BorderLayout;
7 import java.awt.FlowLayout;
8 import java.awt.event.ActionEvent;
9 import java.awt.event.ActionListener;
10
11 import javax.swing.BorderFactory;
12 import javax.swing.JButton;
13 import javax.swing.JDialog;
14 import javax.swing.JFrame;
15 import javax.swing.JPanel;
16 import javax.swing.JScrollPane;
17 import javax.swing.JTextArea;
18
19 import net.sourceforge.pmd.util.viewer.util.NLS;
20
21
22
23
24
25
26
27
28
29 public class ParseExceptionHandler extends JDialog implements ActionListener {
30 private Exception exc;
31 private JButton okBtn;
32
33
34
35
36
37
38
39 public ParseExceptionHandler(JFrame parent, Exception exc) {
40 super(parent, NLS.nls("COMPILE_ERROR.DIALOG.TITLE"), true);
41 this.exc = exc;
42 init();
43 }
44
45 private void init() {
46 JTextArea errorArea = new JTextArea();
47 errorArea.setEditable(false);
48 errorArea.setText(exc.getMessage() + "\n");
49 getContentPane().setLayout(new BorderLayout());
50 JPanel messagePanel = new JPanel(new BorderLayout());
51 messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
52 BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
53 NLS.nls("COMPILE_ERROR.PANEL.TITLE"))));
54 messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER);
55 getContentPane().add(messagePanel, BorderLayout.CENTER);
56 JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
57 okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION"));
58 okBtn.addActionListener(this);
59 btnPane.add(okBtn);
60 getRootPane().setDefaultButton(okBtn);
61 getContentPane().add(btnPane, BorderLayout.SOUTH);
62 pack();
63 setLocationRelativeTo(getParent());
64 setVisible(true);
65 }
66
67
68
69
70 public void actionPerformed(ActionEvent e) {
71 if (e.getSource() == okBtn) {
72 dispose();
73 }
74 }
75 }