Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dialog.show is depreciated; what replaced it? 1

Status
Not open for further replies.

Miros

Programmer
Jan 27, 2001
506
US
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...

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.
 
The JDK1.5 apidocs state that setVisible(boolean) should be used instead. Make sure your calling this method on the Gui Event Dispatch Thread, though.

Tim
 
Thanks, will try this yet again, now that the rest of the code is working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top