Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4127154

Modal dialogs in Swing 1.0 cause update problems in parent.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.5
    • client-libs



      Name: rk38400 Date: 04/08/98


      Create and display a modal JDialog from a parent
      JFrame. Exiting the dialog causes the parent JFrame
      to go blank or incorrectly repaint the parent. (In
      the example code below it causes the first button to
      appear twice sometimes after closing the dialog).

      import java.awt.*;
      import java.awt.event.*;
      import com.sun.java.swing.*;

      class bug extends JFrame implements ActionListener
      {
        JButton btnDialog = new JButton("Show Dialog");
        JDialog dialog = new JDialog(this, true);
        JButton btnClose = new JButton("Close");

        public static void main(String[] args)
        {
          bug myBug = new bug();
        }

        bug()
        {
          setTitle("Mr Modal Bug");
          setSize(300,300);
          getContentPane().setLayout(new FlowLayout());
          getContentPane().add(btnDialog);
          getContentPane().add(new JButton("dummy1"));
          getContentPane().add(new JButton("dummy2"));
          getContentPane().add(new JButton("dummy3"));
          getContentPane().add(new JButton("dummy4"));
          getContentPane().add(new JButton("dummy5"));
          dialog.setSize(300,300);
          dialog.getContentPane().add(btnClose);
          btnDialog.addActionListener(this);
          btnClose.addActionListener(this);
          setVisible(true);
        }

        public void actionPerformed(ActionEvent evt)
        {
          if (evt.getSource() == btnDialog)
            dialog.setVisible(true);
          else if (evt.getSource() == btnClose)
            dialog.setVisible(false);
        }
      }
      (Review ID: 25859)
      ======================================================================

            amfowler Anne Fowler (Inactive)
            rkarsunw Ralph Kar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: