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

Hang with dialogs remote displayed from solaris to linux

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs
    • None
    • x86
    • linux

      I took this text from 4387314, since the evaluator felt it was unrelated
      to the original bug.

      ###@###.### 2002-09-30



      Name: yyT116575 Date: 11/28/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)

      Since Java 1.2 the AWT Dialog has had a number of problems evident when run
      on Linux and to some extent even on Sparc platforms.

      When a Dialog is requested to be displayed for the second time, it does
      not always appear on the screen. If it is a modal dialog, the whole
      program is then locked up in an unusable state.

      JDK 1.3 does not fix the problem. It does not appear on the Windows
      version of Java. The problem is evident even in the example program
      that Sun provided on the use of Dialogs (DialogWindow.java below). This
      works fine when run in Netscape (JDK 1.1).

      I have played with the code and have learned a little about how to avoid
      the problem. Of the many ways of removing a Dialog from the screen when
      it is no longer wanted (eg. hide(), setVisible(false), dispose(),
      removeNotify() ), the first two cause problems. However, I have found
      that if dispose() is used then the second display of the Dialog is always
      successful.

      I am using fvwm2 window manager on either my Linux pc running Red Hat 6.2
      or on our Sparc SUNW,Ultra-Enterprise running Solaris 5.7 and accessed
      via a Tektronix X-terminal.

      -------------------------------------------------------------------------
      import java.awt.*;
      import java.awt.event.*;

      public class DialogWindow extends Frame
                                implements ActionListener {
          boolean inAnApplet = true; //should be private
          private SimpleDialog dialog;
          private TextArea textArea;
          String newline;

          public DialogWindow() {
              textArea = new TextArea(5, 40);
              textArea.setEditable(false);
              add("Center", textArea);
              Button button = new Button("Click to bring up dialog");
              button.addActionListener(this);
              Panel panel = new Panel();
              panel.add(button);
              add("South", panel);

              addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      if (inAnApplet) {
                          setVisible(false);
                          dispose();
                      } else {
                          System.exit(0);
                      }
                  }
              });

              newline = System.getProperty("line.separator");
          }

          public void actionPerformed(ActionEvent event) {
              if (dialog == null) {
                  dialog = new SimpleDialog(this, "A Simple Dialog");
              }
              dialog.setVisible(true);
          }

          public void setText(String text) {
              textArea.append(text + newline);
          }

          public static void main(String args[]) {
              DialogWindow window = new DialogWindow();
              window.inAnApplet = false;

              window.setTitle("DialogWindow Application");
              window.pack();
              window.setVisible(true);
          }
      }

      class SimpleDialog extends Dialog implements ActionListener {
          TextField field;
          DialogWindow parent;
          Button setButton;

          SimpleDialog(Frame dw, String title) {
              super(dw, title, false);
              parent = (DialogWindow)dw;

              //Create middle section.
              Panel p1 = new Panel();
              Label label = new Label("Enter random text here:");
              p1.add(label);
              field = new TextField(40);
              field.addActionListener(this);
              p1.add(field);
              add("Center", p1);

              //Create bottom row.
              Panel p2 = new Panel();
              p2.setLayout(new FlowLayout(FlowLayout.RIGHT));
              Button b = new Button("Cancel");
              b.addActionListener(this);
              setButton = new Button("Set");
              setButton.addActionListener(this);
              p2.add(b);
              p2.add(setButton);
              add("South", p2);

              //Initialize this dialog to its preferred size.
              pack();
          }

          public void actionPerformed(ActionEvent event) {
              Object source = event.getSource();
              if ( (source == setButton)
                 | (source == field)) {
                  parent.setText(field.getText());
              }
              field.selectAll();
              setVisible(false);
              //dispose();
          }
      }
      // If the dispose() is uncommented (to replace the preceding setVisible),
      // the Dialog is successfully displayed on the second and subsequent
      // attempts as well as the first one.
      (Review ID: 112717)

            son Oleg Sukhodolsky (Inactive)
            ehawkessunw Eric Hawkes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: