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:
read a line (by class databaseSaver)
tell to GUI to display and ask what to do (maybe send an event to the class GUIdisplay)
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?
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?