- final JPanel contentPanel = new JPanel(new BorderLayout());
- final Throwable cause = exception.getCause();
-
- // build top panel
- {
- final JPanel topPanel = new JPanel();
- topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
-
- // add exception type
- final JLabel exceptionType = new JLabel("Exception type: "
- + exception.getClass().getCanonicalName());
- topPanel.add(exceptionType);
-
- // add error message
- final JLabel message = new JLabel("Error message: "
- + exception.getMessage());
- topPanel.add(message);
-
- // add cause message
- if (cause != null)
- if (cause.getMessage() != null) {
- final JLabel message2 = new JLabel("Cause: "
- + cause.getMessage());
- topPanel.add(message2);
- }
-
- contentPanel.add(topPanel, BorderLayout.NORTH);
- }
+ frame.getContentPane().add(contentPanel);
+ frame.setSize(800, 600);
+ frame.setVisible(true);
+ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
+ centerFrameOnScreen(frame);
+ }
+
+ private void centerFrameOnScreen(JFrame frame) {
+ final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ frame.setLocation(
+ (screenSize.width - frame.getWidth()) / 2,
+ (screenSize.height - frame.getHeight()) / 2);
+ }