I've read a couple of similar questions on here but none have addressed, specifically, the problem I've been having. As an idea this seems like it should be remarkably simple, in practice I have found it to be utterly impossible.
What I want to do is have a form, let's call it form A, create another form, let's call it form B, and wait for input on form B before continuing. So, you'd have your main window, press a button and another window comes up prompting you for some value, the main window then waits for the input to be entered and processed and for the input window to close, then it uses that entered value to do something else.
I know this can be accomplished because JOptionPane does exactly that, but I'm going to be using mostly numerical values and I don't want to go through the extra step of converting it. Also, it just seems like a good idea to know how to do something like this since it sounds so basic yet is proving quite difficult.
Edit: It was suggested that this may be similar to some sort of "modal" something, but I read through that and it didn't even seem at all related to what I'm asking.
Edit 2: There is a response with code that does exactly what I need, but whenever I attempt to modify it in almost any way, it ceases to function, this is what my class looks like, or at least this is the part that I'm testing, the rest of it is mostly empty methods that aren't being called yet:
public Gather(GraphWindow parent, int type)
{
super(parent);
parentWindow=parent;
this.info=new String[0];
constructType(type);
}
private void constructType(int type)
{
msgLab=new JLabel();
if(type==TEXT)
{
goText();
}
}
private void goText()
{
final JTextField jtf = new JTextField();
JButton done = new JButton("Done");
if(info.length==0)
{
setTitle(TEXT_T);
msgLab.setText(TEXT_M);
}
else
{
if(info[0].length()==0)
{
setTitle(TEXT_T);
msgLab.setText(info[1]);
}
else if(info[1].length()==0)
{
setTitle(info[1]);
msgLab.setText(TEXT_M);
}
else
{
setTitle(info[0]);
msgLab.setText(info[1]);
}
}
done.addActionListener(new ActionListener()
{
@Override public void actionPerformed(ActionEvent e)
{
parentWindow.setText(jtf.getText());
Gather.this.dispose();
}
});
this.setLayout(new GridLayout(3,1));
this.setSize(250, 150);
this.add(msgLab);
this.add(jtf);
this.add(done);
this.setVisible(true);
}