Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: yyT116575 Date: 06/19/2001 java version "1.3.1" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24) Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode) A non-modal JDialog remains visible even after a call to setVisible(false). This happens when the call to setVisible(false) is made at the time the parent JFrame has been minimized (iconified) by the user. /** To duplicate the bug: * 0. Compile and run the program below. * 1. Hit the "Perform Long Computation" button * 2. Minimize (iconify) the application. * 3. Wait for 5 seconds (until "computation" is over). * 4. Restore (de-iconify) the application window. * 5. The "Wait" JDialog is still visible, although * a call to setVisible(false) has been made. * 6. This behavior didn't happen on Solaris and Linux platform */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class FrameDemo { JFrame mFrame; JButton mTestButton; JDialog mDialog; public FrameDemo() { mFrame = new JFrame("FrameDemo"); mFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); mFrame.setBounds(200, 200, 400, 200); mDialog = new JDialog(mFrame, "Please Wait", false); mDialog.setBounds(new Rectangle(300, 250, 200, 100)); mTestButton = new JButton("Perform Long Computation..."); mFrame.getContentPane().add(mTestButton, BorderLayout.SOUTH); mFrame.setVisible(true); mTestButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent f) { mDialog.setVisible(true); System.out.println("Starting Computation....."); try{ Thread.sleep(5000); } catch (Exception e) { } System.out.println("Finished Computation."); mDialog.setVisible(false); } }); } public static void main(String s[]) { FrameDemo f = new FrameDemo(); } } (Review ID: 126905) ======================================================================
|