i have a question about using JFrame and JDialog properly, I've created a class that extends JDialog, so each time when i'm pressing a button that is located on my JFrame,the button's ActionListener is working, and inside it i'm creating a new instance of the JDialog class, and the JDialog window should appear.
(my JDialog is a Window for filling in a certain animal details)
from my understanding, when i'm creating a new instance of the extended JDialog class, i'm also creating a new thread, and the program is staring to run parallel ( the JDialog window is working, and in the meantime the JFrame code keeps running as well.
actually, i'm not too sure how to handle this kind of situation, the first idea was to somehow make the JFrame "wait" until the user will finish to fill the animal's details, with a method like "join()" or something similar, but it seems that i cannot do that to a JFrame.
// we're in a class that extends from JFrame
private void AddAnimal() throws IOException, InterruptedException {
// we're creating a new instance of a class that extends JDialog.
newAnimal = new CreateInstanceAnimal(this, selectedType);
// i'm trying to make the JFrame to wait till newAnimal will be finished, and then continue to run to the next lines below.
AddCompetitor(newAnimal.getAnimal());
DisplayAnimal(newAnimal.path,true);
}
here's a picture of what i'm trying to accomplish: additional information the class that extends JDialog window is responsible of creating the window with the dog.
and i'm trying to make the JFrame class ( representing the window with the background ), to wait will the user is finished with filling the animals details.
i'm grateful for any kind of help :)