I'm trying to open a new window when I click on a button. In this new window there is a form. The form contains information which is used to create a JScrollPane in the first window. I'd like to create the JScrollPane when the user completes all the element in the form. I tried with Thread but this does not work.
This is my code :
f(e.getSource() == menuAjoutern){
JScrollPane scrollpane;
nomniveaux++;
Frame p = new Frame();
p.setContentPane(new PanelInfoCrea());
p.setVisible(true);
/*Thread t = new Thread(new Runnable() {
@Override
public void run() {
Frame p = new Frame();
p.setContentPane(new PanelInfoCrea());
p.setVisible(true);
}
});
t.start();
Frame.creation = true;
while(Frame.creation) {
try {
System.out.println("oui");
Thread.sleep(1);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}*/
scrollpane = new JScrollPane(Frame.p.getListeNiveau().get(Frame.p.getListeNiveau().size()-1).dessinerPlateauCreation(this.getWidth(), this.getHeight(), hauteur));
pane.add("niveau "+nomniveaux ,scrollpane);
}
Here I try to wait that boolean is false for create the JScrollPane. The boolean change state when second window is close. Do you have any ideas?