Public Member Functions | |
GuiExceptionFrame (JFrame gui) | |
void | showException (Exception e) |
void | actionPerformed (ActionEvent e) |
Package Attributes | |
JTextField | errorMessage |
JTextField | classMessage |
JTextArea | traceMessage |
JTextAreaWriter | writer |
PrintWriter | printWriter |
JButton | showMe |
Static Package Attributes | |
final int | FRAME_WIDTH = 500 |
final int | SHORT_HEIGHT = 200 |
final int | LONG_HEIGHT = 400 |
Definition at line 58 of file GuiExceptionFrame.java.
|
Creates a new
Definition at line 76 of file GuiExceptionFrame.java. 00077 { 00078 super(gui, true); 00079 setTitle(GuiTranslate.get("frame.exception.title")); 00080 00081 00082 GuiConstants.centerComponent(this,FRAME_WIDTH,SHORT_HEIGHT); 00083 setVisible(false); 00084 00085 getContentPane().setLayout(new BorderLayout()); 00086 00087 GridLayout layout = new GridLayout(6, 1); 00088 JPanel messagePanel = new JPanel(layout); 00089 messagePanel.add(new JLabel(GuiTranslate.get("frame.exception.error.type"))); 00090 classMessage = new JTextField(0); 00091 classMessage.setBackground(Color.white); 00092 classMessage.setAlignmentX(CENTER_ALIGNMENT); 00093 classMessage.setEditable(false); 00094 messagePanel.add(classMessage); 00095 00096 messagePanel.add(new JLabel(GuiTranslate.get("frame.exception.error.message"))); 00097 errorMessage = new JTextField(0); 00098 errorMessage.setBackground(Color.white); 00099 errorMessage.setAlignmentX(CENTER_ALIGNMENT); 00100 errorMessage.setEditable(false); 00101 messagePanel.add(errorMessage); 00102 00103 // Trace 00104 JLabel label = new JLabel(GuiTranslate.get("frame.exception.stack.trace")); 00105 // Show/hide trace 00106 showMe = new JButton(); 00107 showMe.addActionListener(this); 00108 setShowMeToShow(); 00109 00110 messagePanel.add(label); 00111 messagePanel.add(showMe); 00112 00113 traceMessage = new JTextArea(); 00114 traceMessage.setVisible(false); 00115 traceMessage.setAlignmentX(CENTER_ALIGNMENT); 00116 traceMessage.setEditable(false); 00117 traceMessage.setFont(GuiConstants.CENTER_PANE_FONT); 00118 traceMessage.setPreferredSize(new Dimension(FRAME_WIDTH, LONG_HEIGHT / 2)); 00119 writer = new JTextAreaWriter(traceMessage); 00120 printWriter = new PrintWriter(writer); 00121 scrollPane = new JScrollPane(); 00122 scrollPane.getViewport().add(traceMessage); 00123 scrollPane.setVisible(false); 00124 00125 // on the left 00126 JButton iconPane = new JButton(); 00127 Icon icon = GuiIcons.FRAME_ERROR_ICON; 00128 iconPane.setIcon(icon); 00129 Dimension dime = new Dimension(icon.getIconWidth(), icon.getIconHeight()); 00130 iconPane.setMaximumSize(dime); 00131 iconPane.setPreferredSize(dime); 00132 iconPane.setActionCommand(GuiCommands.COMMAND_HIDE_ERROR_FRAME); 00133 iconPane.addActionListener(this); 00134 getContentPane().add(iconPane, BorderLayout.EAST); 00135 00136 // on the center 00137 getContentPane().add(messagePanel, BorderLayout.CENTER); 00138 00139 // on the right 00140 getContentPane().add(scrollPane, BorderLayout.SOUTH); 00141 00142 setVisible(false); 00143 setBackground(Color.white); 00144 setDefaultCloseOperation(HIDE_ON_CLOSE); 00145 validate(); 00146 }
|
|
Definition at line 189 of file GuiExceptionFrame.java. 00190 { 00191 if (e.getActionCommand().equals(GuiCommands.COMMAND_HIDE_ERROR_FRAME)) 00192 { 00193 scrollPane.setVisible(false); 00194 this.setVisible(false); 00195 } 00196 else if (e.getActionCommand().equals(GuiCommands.COMMAND_SHOW_ERROR_TRACE)) 00197 { 00198 setSize(FRAME_WIDTH, LONG_HEIGHT); 00199 traceMessage.setVisible(true); 00200 scrollPane.setVisible(true); 00201 validate(); 00202 repaint(); 00203 scrollPane.repaint(); 00204 setShowMeToHide(); 00205 } 00206 else if (e.getActionCommand().equals(GuiCommands.COMMAND_HIDE_ERROR_TRACE)) 00207 { 00208 setSize(FRAME_WIDTH, SHORT_HEIGHT); 00209 traceMessage.setVisible(false); 00210 scrollPane.setVisible(false); 00211 validate(); 00212 repaint(); 00213 scrollPane.repaint(); 00214 setShowMeToShow(); 00215 } 00216 }
|
|
Show the exception in a dialog box
Definition at line 153 of file GuiExceptionFrame.java. 00154 { 00155 errorMessage.setText(e.getMessage()); 00156 classMessage.setText(e.getClass().getName()); 00157 traceMessage.setText(""); 00158 e.printStackTrace(printWriter); 00159 try 00160 { 00161 writer.flush(); 00162 } 00163 catch (IOException e1) 00164 { 00165 // can't show, do not show 00166 } 00167 setVisible(true); 00168 }
|