Amit
Amit

Reputation:

JOptionPane popup window

I'm reading data from serial port for that I've created one window. When I click connect button I'll get another window showing message as "connected" with ok option and at the same time data starts coming but it wont dump until i click ok button of the front window. I want data should dump without clicking the ok button of the front window. How can I do that?

Upvotes: 0

Views: 1021

Answers (2)

Jérôme
Jérôme

Reputation: 2720

A JOptionPane is a modal dialog, and can not be tuned. A modal dialog blocks the invoking thread.

If you don't want to create another thread (which seems indeed to be the best method), you must create your own dialog window, with JDialog class.

You can watch JDialog tutorial.

Upvotes: 0

David Grant
David Grant

Reputation: 14243

You need to read the data from the serial port in a different thread to that used to display the dialog box. I'd recommend reading the Concurrency in Swing lesson from Sun.

Upvotes: 2

Related Questions