Start here:
The key is that a script that is going to block reading from the serial port (even briefly) must be run in a background thread. Data to deliver to your UI must use system.util.invokeLater() to delegate snippets of code back on the UI thread.
system.util.invokeLater()