I have a cancel dialog that only displays when a thread is running. Apparently the JDialog.show() method is depreciated. What do I use in place of it? setVisible doesn't work...
setCancel just sets a boolean which is checked periodically by longtimeconsumingprocess() to see if the user clicked the cancel button.
Code:
public void threadwrapper( )
{
Object[] options = { "Cancel" } ;
JOptionPane optionPane = new JOptionPane(
"Long time consuming operation in process.",
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
options,
options[0] ) ;
final JDialog dialog = optionPane.createDialog( textfield,
"Please wait" );
setCancel( false ) ;
final SwingWorker worker = new SwingWorker()
{
public Object construct()
{
longtimeconsumingprocess( ) ;
dialog.setVisible( false ) ;
return null ;
}
//Runs on the event-dispatching thread.
public void finished()
{
}
};
worker.start() ;
dialog.show() ; <=== this is the line it doesn't like
setCancel( true ) ;
}
setCancel just sets a boolean which is checked periodically by longtimeconsumingprocess() to see if the user clicked the cancel button.