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

Cannot change the title of a dialog that is not visible

XMLWordPrintable

    • x86
    • windows_nt



      Name: el35337 Date: 05/20/98


      For a dialog that has been created but is not visible
      calling setTitle doesn't change the title of the
      dialog. The following code illustrates the problem.
      Each time you open the dialog the title should be
      incremented. However, the title always remains "0".
      NOTE: This problem only occurs on Windows NT, it works
      correctly on Solaris 2.51.

      import com.sun.java.swing.*;
      import java.awt.event.*;
      import java.awt.*;
      public class TestDialogTitle {
          private Frame frame;
          private JDialog dialog;
          private int count = 0;
          public TestDialogTitle() {
              frame = new Frame();
              Button b = new Button("open dialog");
              b.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  showDialog();
      }});
      frame.add(b);
      frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent evt) {
      System.exit(0);
      }});
              frame.pack();
              frame.show();
              
          }
          private void showDialog() {
              if (dialog == null)
                  dialog = new JDialog(JOptionPane.getFrameForComponent(null),"Test",true);
              dialog.getContentPane().setLayout(new FlowLayout());
              dialog.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent evt) {
      dialog.setVisible(false);
      }});
              dialog.setTitle(" " + count++);
      dialog.pack();
              dialog.show();
          }
          public static void main(String[] args){
              new TestDialogTitle();
          }
              
      }
      (Review ID: 30707)
      ======================================================================

            lbunnisunw Lara Bunni (Inactive)
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: