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

"Dead-Spot" in dialog where no component can get focus.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P1 P1
    • None
    • 1.2.1
    • client-libs
    • None

        In the included test case a JDialog is created using JOptionPane.createDialog. The dialog contains a number of text components which are used to receive assorted input from the user. The JDialog is launched by pressing a button in the main applet window. When the JDialog is brought up a weird "Dead-spot" appears to be present where any component that is located within the dead-spot cannot get focus via mouse clicks. The dead spot seems to be located 1/2 inch below and to the right of the lower right corner of the button that launches the dialog. If you move the JDialog, the component which used to be in the dead spot can now receive focus, but any component that occupies the space now cannot receive focus.
        If you try several times occasionally the component will get focus but it is not clear what sequence of events needs to occur.

      Test case contains 2 files. test.html contains the applet tag and Appet1.java contains the source code.

      java -fullversion
      JAVA.EXE full version "JDK-1.2.1-A"

      java -version
      Classic VM (build JDK-1.2.1-A, native threads)

      test.html
      ----------
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
      <html>
        <head>
          <title>3924216 Applet MemLeak test</title>
        </head>

        <body>
            <h1>3924216 Applet MemLeak test</h1>
      <applet code="memleak.Applet1" width=500 height=500></applet>


            <hr>
            <address><a href="mailto:sdirose@shadowfax">Stephen DiRose</a></address>
      <!-- Created: Fri Apr 30 16:33:20 EDT 1999 -->
      <!-- hhmts start -->
      Last modified: Fri Apr 30 16:34:00 EDT 1999
      <!-- hhmts end -->
        </body>
      </html>

      --------

      Applet1.java
      --------
      package memleak;

      import java.awt.*;
      import java.awt.event.*;
      import java.applet.*;
      import java.text.*;
      import java.util.*;
      import javax.swing.*;
      import javax.swing.event.*;
      import javax.swing.table.*;

      public class Applet1 extends JApplet {
        static Applet1 applet1;
        boolean isStandalone = false;
        Container contentPane;
        BorderLayout borderLayout = new BorderLayout();
        JPanel jPanel = new JPanel(new GridBagLayout());
        JPanel promiseDatePanel = new JPanel(new GridBagLayout());
          JTextField tf0 = new
      JTextField("textxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
          JTextField tf1 = new
      JTextField("textzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
          JTextField tf2 = new
      JTextField("textaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
          JTextField tf3 = new
      JTextField("textbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
      ;
          String htmlText =
              "<html>A JLabel with <i>various <font color=blue>text styles<br>" +
              "And a new line!</font></i>";
          JLabel msgsLabel = new JLabel(htmlText);
          JList msgsList = new JList(new String[] {"message1","message2"});
          JSeparator separator = new JSeparator();
          JLabel datesLabel = new JLabel("The dates below are valid for this order:");
          JList datesList = new JList(new String[] {"1999-Jan-01 Optimal Promise Date",
            "1999-Jan-01 Requested Promise Date", "1999-Jan-01 Next Available Date"});
        JButton promiseButton = new JButton("promise");


        public Applet1() {
        }

        public void init() {
          try {
          jbInit();
          }
          catch (Exception e) {
          e.printStackTrace();
          }
        }

        private void jbInit() throws Exception {
          applet1 = this;
          contentPane = this.getContentPane();

          setSize(new Dimension(800, 600));
          contentPane.setLayout(new BorderLayout());
          contentPane.add(jPanel, BorderLayout.CENTER);
          contentPane = this.getContentPane();
          contentPane.add(jPanel);

          promiseButton.addActionListener(new ActionListener()
           {
            //to detect pulldown; invoked on both! coordinate with another event to
            //prevent action when pulldown disappears?
            public void actionPerformed(ActionEvent e) {
              promise();
            }
          });


          { OrdGBConstraints c = new OrdGBConstraints();
            jPanel.add(promiseButton, c); c.gridy++;
          }


          //Promise Date Panel
          { OrdGBConstraints c = new OrdGBConstraints();
            promiseDatePanel.add(tf0, c); c.gridy++;
            promiseDatePanel.add(tf1, c); c.gridy++;
            promiseDatePanel.add(tf2, c); c.gridy++;
            promiseDatePanel.add(tf3, c); c.gridy++;
            c.fill=c.HORIZONTAL;
            promiseDatePanel.add(msgsLabel, c); c.gridy++;
            promiseDatePanel.add(msgsList, c); c.gridy++;
            promiseDatePanel.add(separator, c); c.gridy++;
            promiseDatePanel.add(datesLabel, c); c.gridy++;
            promiseDatePanel.add(datesList, c);
          }
          datesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);


        }


        void promise() {
          JOptionPane pane = new JOptionPane();
          pane.setMessage(promiseDatePanel);
          String changeDate = "Change Promise Date",
            changeDateAndConsume = "Change Promise Date and Consume",
            close = "Close";
          pane.setOptions(new String[] {changeDate, changeDateAndConsume, close});
          JDialog dialog = pane.createDialog(contentPane, "my title");
          dialog.pack();
          dialog.show();
          System.out.println("totmem=" + Runtime.getRuntime().totalMemory() +
                " freemem=" + Runtime.getRuntime().freeMemory());
        }


        public String getAppletInfo() {
          return "Applet Information";
        }


        public String[][] getParameterInfo() {
          return null;
        }

      }

      class OrdGBConstraints extends GridBagConstraints {
        OrdGBConstraints() {
          gridx=0; gridy=0; gridwidth=1; gridheight=1; weightx=1.0; weighty=1.0;
          anchor=GridBagConstraints.WEST; fill=GridBagConstraints.NONE;
          insets=new Insets(10,0,0,0); ipadx=0; ipady=0;
        }
      }

            hgajewsksunw Hania Gajewska (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: