Skip to content

Commit c347c1c

Browse files
author
Me No Dev
committed
make output text selectable
1 parent dbc55de commit c347c1c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/EspExceptionDecoder.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747

4848
public class EspExceptionDecoder implements Tool, DocumentListener {
4949
Editor editor;
50-
JLabel outputArea;
50+
JTextPane outputArea;
51+
String outputText;
5152
JTextArea inputArea;
5253
JFrame frame;
5354
File tool;
@@ -105,11 +106,14 @@ public void run() {
105106
try {
106107
if(listenOnProcess(arguments) != 0){
107108
editor.statusError("Decode Failed");
109+
outputArea.setText("<html><font color=red>Decode Failed</font></html>");
108110
} else {
109111
editor.statusNotice("Decode Success");
112+
outputArea.setText(outputText);
110113
}
111114
} catch (Exception e){
112115
editor.statusError("Decode Exception");
116+
outputArea.setText("<html><font color=red><b>Decode Exception:</b> "+e.getMessage()+"</font></html>");
113117
}
114118
}
115119
};
@@ -207,8 +211,16 @@ private void createAndUpload(){
207211
inputArea.getActionMap().put("commit", new CommitAction());
208212
inputArea.getDocument().addDocumentListener(this);
209213
frame.getContentPane().add(new JScrollPane(inputArea), BorderLayout.PAGE_START);
210-
211-
outputArea = new JLabel();
214+
215+
outputText = "";
216+
outputArea = new JTextPane();
217+
outputArea.setContentType("text/html");
218+
outputArea.setEditable(false);
219+
outputArea.setBackground(null);
220+
outputArea.setBorder(null);
221+
outputArea.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
222+
outputArea.setText(outputText);
223+
212224
JScrollPane outputScrollPane = new JScrollPane(outputArea);
213225
outputScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
214226
outputScrollPane.setPreferredSize(new Dimension(640, 200));
@@ -247,7 +259,7 @@ private void printLine(String line){
247259
String html = "" +
248260
"<font color=green>" + address + ": </font>" +
249261
"<b><font color=blue>" + method + "</font></b> at " + file + " line <b>" + line + "</b>";
250-
outputArea.setText(outputArea.getText() + html +"<br>");
262+
outputText += html +"\n";
251263
}
252264

253265
public void run() {
@@ -275,7 +287,7 @@ private void parseText(){
275287
while(m.find()) {
276288
command[i++] = content.substring(m.start(), m.end());
277289
}
278-
outputArea.setText("<html><i>Decoding "+count+" results</i><br>");
290+
outputText = "<html><pre><i>Decoding "+count+" results</i>\n";
279291
sysExec(command);
280292
}
281293

@@ -296,5 +308,4 @@ public void removeUpdate(DocumentEvent ev) {
296308
public void insertUpdate(DocumentEvent ev) {
297309
parseText();
298310
}
299-
300311
}

0 commit comments

Comments
 (0)