views:

186

answers:

1

Hi Geeks,

I am making a GUI application for operating a remote device through serial port. For this I am using two threads - "reading from" and "writing to" serial port. My main application frame contains one menubar with menuItems and submenu items and one scrollable text area. Now I am putting all the output from serial port to text area so its just feeling like the console. The serial port shell give me command output something like this

line1 word1 word2 wordd3 word4 word5 :
    line2 word1 = 0x00000000
    line3 word2 = 0x00000000
line3Word1 : line3word2
line4Word1 : line4Word2
line5Word1 : line5word2
line6Word1 : line6Word2

Now I want to put some lines in my main frame in labels. Something like this.

line4Word1(in label1) : line4Word2(in label2)
line5Word1(in label3) : line5word2(in label4)

Now If i will put the checks on strings line4Word1 and line5Word1 at reading serial ports, I fear will be able to process the string and create labels while realtime data recieving?

Can anybody suggest me some better way to do this?

I am sorry if I am unable to explain the problem clearly. But If not clear please let me know I will explain it better way....

+2  A: 

For your scrolling area, the append() method of JTextArea happens to be thread-safe. To get thread-safe updates to other GUI components, I'd go with SwingWorker, also discussed here.

trashgod
I will test this and let you know....
Surjya Narayana Padhi