我的方法必须在用户按下按钮后返回.经过一些研究,我认为这样可行:
方法本身:
public Aluno getAlunoFromUser() throws InterruptedException
{
//Wait to be notified from ActionListener
synchronized(this)
{
this.wait();
}
//return
return null;
}
Run Code Online (Sandbox Code Playgroud)
ActionListener:
Button.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
this.notify();
}
});
Run Code Online (Sandbox Code Playgroud)
但该计划正在冻结.我想知道如何解决这个问题.