TextArea may not be thread-safe
This commit is contained in:
@@ -32,7 +32,7 @@ public class Main {
|
|||||||
JPanel mainPanel = new JPanel();
|
JPanel mainPanel = new JPanel();
|
||||||
mainPanel.setBorder(new TitledBorder(new EtchedBorder(), "Process:"));
|
mainPanel.setBorder(new TitledBorder(new EtchedBorder(), "Process:"));
|
||||||
|
|
||||||
JTextArea textArea = new JTextArea(16, 58);
|
final JTextArea textArea = new JTextArea(16, 58);
|
||||||
textArea.setEditable(false);
|
textArea.setEditable(false);
|
||||||
JScrollPane scroll = new JScrollPane(textArea);
|
JScrollPane scroll = new JScrollPane(textArea);
|
||||||
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
@@ -71,7 +71,9 @@ public class Main {
|
|||||||
.parallelStream()
|
.parallelStream()
|
||||||
.forEach(p -> {
|
.forEach(p -> {
|
||||||
if (aborted) return;
|
if (aborted) return;
|
||||||
|
synchronized (textArea) {
|
||||||
textArea.append("Processing: " + p.getFileName().toString() + "\n");
|
textArea.append("Processing: " + p.getFileName().toString() + "\n");
|
||||||
|
}
|
||||||
Image img = new Image(p.toFile());
|
Image img = new Image(p.toFile());
|
||||||
img.rotate();
|
img.rotate();
|
||||||
img.saveAs(p.toFile());
|
img.saveAs(p.toFile());
|
||||||
|
|||||||
Reference in New Issue
Block a user