I've got a problem: I've got a jframe1 who calls at ActionPerformed the jframe2. JFrames are threads or? and so I've tried in the jframe2 the wait() method, and then I would notify the jframe2's in jframe1..
my code in jframe2 (a method what run, when a button is clicked):
private void read(){
synchronized(jframe1){
try {
if(writer.checkLast() == null){
this.wait();
jLabel.setText(writer.getLast());
}
else{
jLabel.setText(writer.getLast());
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
But the Problem is, that if I use this.wait(); in jframe2, my jframe1 is also locked.. what I do wrong?
sry for my bad english, thanks if anyone have got an answer!
I get the feeling that you're trying to emulate the behavior of a modal dialog by using the wait() method, but as Michael explains well above, don't call wait on a Swing component and don't use Thread.sleep. Instead if you want to display another window modally use a JOptionPane or a modal JDialog. It's all well explained in the tutorials.