Okay, I have a code that looks like this:
public class Test
{
private JPanel dummy;
public checker()
{
dummy = new JPanel();
dummy.setVisible(false);
dummy.addComponentListener(new ComponentAdapter()
{
@Override
public void componentShown(ComponentEvent arg0)
{
dummy.setVisible(false);
runCheck();
}
});
runCheck();
}
private void runCheck()
{
if (a)
{
//do something
dummy.setVisible(true);
}
}
}
This will create a dummy JPanel and add a component adapter that will fire each time dummy is set to be visible. It works like a while loop, only it makes sure that GUI is updated before it goes into another cycle.
But I need method checker()
to return a value once the cycle is broken.
NOTE:
This is symplified version of code, I cannot check for condition a
, that is not a solution.