Java GUI (SWT) - display text while performing other actions like reading that text

I have is a java class that reads a text file. For each line read, this class (called X), writes a record into a database.

This works without any GUI, only from a linux shell.

I'd like to have a nice GUI where, when that X class reads one single line (and so on for every line), it can display a popup or similar (Jframe, Jtable, etc.) and ask the user if that line has to be written to database.

How do I let those two classes (the databaseSaver and the GUIdisplayer) interoperate? It's not necessary to parallelize the work, it could be something like:

For each line:

  1. read a line (by class databaseSaver)

  2. tell to GUI to display and ask what to do (maybe send an event to the class GUIdisplay)

  3. listen to the response and do what to do (by class databaseSaver)

Is it possible to attach a GUI Event Listener to actions of a class?

Answers


I assume you are reading the values in a loop. Inside that loop, make a call to the GUI and pass the text with a confirm yes/no option. On yes, call a method to insert into the database. On no, continue to the next line.

Am I missing something?


Need Your Help

default form is not shown

c# dynamics-crm dynamics-crm-2011

I added a custom form to my opportunity entity so now I have the default "Information" form and now my new custom form.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.