A question similar to this has been asked before, and will be asked again I am sure. I have spent some time googling and trying to work this out for myself, but I am at an impasse.
What I am trying to achieve is to implement a database search screen for an application I have been tasked with creating.
What I am doing is loading a JFrame with JPanels through a cardlayout. On a few of these JPanels I will have a button that calls another JFrame that will search a DB and load the result set into a table displayed on the frame. The search is only conducted after the user has typed in the search data and pressed search. The screen is to be disposed of, and return the values once the user has selected a row in the table and pressed another button.
I have all the GUI components created, and the DB search functionality working. The problem I have is returning the value.
At the moment I have the Search JFrame object created by the JPanel that has the button, but any attempts I ave made to get the data from the search frame have resulted in null results.
Is there a way to return a value through this way and if so how?
I have tried getter/setter methods, but obviously since the initial results of the variables are null it returns as null. I tried linking the result to the table with the same result. (Actually it returned -1, but that's just splitting hairs). I tried changing the search screen to a JDialog as I read that that can halt the running code while waiting for a response. I tried various methods to check if the search screen was enabled/visible and to hold on those.
All to no avail.
Any help is appreciated.