Here is my problem. When i use the following code:
package xyz.lexium.giapb.ui;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java
You're forgetting that the JScrollPane has a border.
frame.getContentPane().add(new JScrollPane(textArea), BorderLayout.CENTER);
Set it to null.
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setBorder(null);
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
Another issue: this isn't Swing thread-safe:
public synchronized void run() {
try {
while (Thread.currentThread() == reader) {
try {
this.wait(100);
} catch (InterruptedException ie) {
}
if (pin.available() != 0) {
String input = this.readLine(pin);
textArea.append(input); // **************
}
if (quit)
return;
}
while (Thread.currentThread() == reader2) {
try {
this.wait(100);
} catch (InterruptedException ie) {
}
if (pin2.available() != 0) {
String input = this.readLine(pin2);
textArea.append(input); // **************
}
if (quit)
return;
}
} catch (Exception e) {
textArea.append("\nConsole reports an Internal error."); // **************
textArea.append("The error is: " + e); // **************
}
}
You're making textArea.append(...)
calls off of the Swing event thread, and this can cause hard to debug intermittent exceptions to be thrown. Be sure to only append to this text component on the event dispatch thread.