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

Using ToolTips causes inactive app window to exhibit active window behavior

    Details

    • Subcomponent:
    • Introduced In Build:
      b05
    • Introduced In Version:
    • Resolved In Build:
      b02
    • CPU:
      x86
    • OS:
      windows_2000, windows_xp
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        Java Plug-in 1.6.0_10
        Using JRE version 1.6.0_10 Java HotSpot(TM) Client VM

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows 2000 [Version 5.00.2195]



        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Problem seems to occur only on Windows OS -- I cannot reproduce the problem on Solaris. Problem occurred with JRE1.6.0_07, and earlier 1.6 releases, as well as 1.6.0_10). Problem does not occur with Java 1.5 (maybe because tooltips are not shown for not-focussed applets in Java 1.5?)

        I have produced the problem with Firefox 2.0.0.17 and Internet Explorer 6.0 SP1

        A DESCRIPTION OF THE PROBLEM :
        When an applet window has focus and is positioned over an underlying applet embedded in the web browser, moving the mouse over the not-focussed applet and displaying tooltips causes the not-focussed applet (web browser window) to come to the front, thus hiding the focussed applet window.

        Problem only occurs on Windows OS -- I do not see the problem on Solaris.

        This problem appears to be a regression in Java 1.6 from Bug 4148057 which was fixed in Java 1.5.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile test case program, and run in web browser with test case HTML, using Java 1.6 plugin.

        There will be a JTable applet in the web browser, and a little popup window named W2 with a JButton in it. Position the W2 window over the JTable, and click the button a couple times (i.e., verify that the W2 window has focus and is in front of the JTable.

        Now move the mouse over the JTable. Tooltips will display for the items in the JTable. When you move the mouse over an item where the tooltip extends beyond the bounds of the JTable, the Web browser window with the JTable in it will come to the front, hiding W2. (The tooltip for "Function1" in Col3 is very long, so it works -- also the tooltip for any other cell in the JTable will work if it extends beyond the bounds of the JTable.)

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        W2 should stay on top (visible over the Web browser window with the JTable no matter where you move the mouse over the JTable (so long as you don't click the mouse to change focus, of course).
        ACTUAL -
        When mouse moved over a table cell where the tooltip extends beyond the bounds of the table, the Web browser window comes to the top and W2 gets hidden.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        No error messages.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        HTML to run test case:

        <HTML>
        <HEAD><TITLE>Windows tooltip focus problem</TITLE></HEAD>
        <BODY BGCOLOR="#FFFFFF">

        <APPLET CODE = TooltipTest ARCHIVE = TTT.jar WIDTH = 454 HEIGHT = 204>

        </APPLET>
        </BODY>
        </HTML>

        ------------------

        Test case source code:

        //import java.awt.FlowLayout;
        import javax.swing.*;
        import javax.swing.table.*;

        import javax.swing.border.*;
        import java.awt.*;
        import java.awt.event.*;

        public class TooltipTest extends JApplet {


        String[] columnNames = {"Col1",
                                "Col2",
                                "Col3",
                                "Col4",
                                "Col5"};

        Object[][] data = null;


          public void init() {

              data = new Object [40][5];
              for (int ix = 0; ix < 40; ++ix) {
                  data[ix][0] = "Name1-" + ix;
                  data[ix][1] = "Name2-" + ix;
                  data[ix][2] = "Function" + ix;
                  data[ix][3] = "";
                  data[ix][4] = "Name5-" + ix;
              }
              JTable t = new JTable( data, columnNames);
              t.setDefaultRenderer(String.class, new ObjectRenderer());
              t.setDefaultRenderer(Object.class, new ObjectRenderer());

               JScrollPane jsp = new JScrollPane(t);
              setSize(454, 204);

               jsp.setPreferredSize(new Dimension(450, 200));

          // setLayout(new FlowLayout());
              GridBagLayout layout = new GridBagLayout();
              GridBagConstraints gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.gridwidth = 1;
                gbc.anchor = GridBagConstraints.SOUTHEAST;
                gbc.fill = GridBagConstraints.BOTH;
                gbc.insets = new Insets( 2,2,2,2 ) ;
              
              getContentPane().setLayout(layout);
              layout.setConstraints(jsp, gbc);
              getContentPane().add(jsp);
        //add(jsp);

              //setVisible(true);
                System.out.println("Version 1.33 " + getClass().getName());
                JFrame frame2 = new JFrame("W2");
                 JButton buttonX = new JButton("Button TESTX");
                buttonX.setToolTipText("Tooltip TESTX");
                buttonX.addActionListener(new ActionListener() {
                      public void actionPerformed(ActionEvent ae) {
                          System.out.println("buttonX clicked");
                      }

                });
               frame2.getContentPane().setLayout(new FlowLayout());
               frame2.getContentPane().add(buttonX);
                frame2.setSize(200, 200);
                frame2.setLocation(50, 50);
                frame2.setVisible(true);
          }

           static class ObjectRenderer extends DefaultTableCellRenderer {
             public ObjectRenderer(){
             super();
             }
          
        public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

        // if (isSelected)
        // setBorder(BorderFactory.createMatteBorder(2,0,2,0,Color.black));

        //setOpaque(true);
        String s = getText();
                        if (s.equals("Function0")) s = ""; // This does not fail (SmWrappedToolTipUI creates the problem here)
                        if (s.equals("Function1")) s =
                  "very long tool tip test text very long tool tip test text very long tool tip test text very long tool tip test text ends here";
        setToolTipText( s);
        return this;
        }
            }

        }


        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        No workaround.

        Release Regression From : 5.0
        The above release value was the last known release where this
        bug was not reproducible. Since then there has been a regression.
        Customer requested to add the following information
        I've been doing more testing of this problem,
        and I've noticed something *in addition to* what I
        wrote in the CQ:

        For the sample program, in the Bug Report, I wrote that if
        the tooltip for a table cell extends beyond the
        bounds of the table when the table is not the
        focussed frame and it is behind the
        little popup with the button which has focus, then
        if you move the mouse over a cell in the table with a
        tooltip that extends beyond the table frame, then
        the table comes to the top even though the little
        popup with the button has focus.

        What I did not write in that the problem occurrs "in the
        opposite direction", also: If the frame with the table has
        focus and is in front, and if you move the mouse over the
        button in the popup, if the button's tooltip extends beyond its
        frame, then the button popup panel comes to the front even
        though it does not have focus, too.

        This is a kind of "nit", but I think it
        points out that the problem is not only with
        tooltips for widgets embedded in a frame that
        is embedded in the web browser, but the problem occurs for
        other windows associated with the browser session
        also.
        Customer has done further testing and has
        submitted another test program

        More "good" news....

        I did even more testing, and it looks like the
        problem has nothing at all to do with using a
        web browser.

        I modified my Example program to run from the command
        line and reproduced the problem.


        C:\SAM80B130\CONSOLE\smarts\tomcat\webapps\webconsole>\jdk1.6.0_10\bin\j
        avac TooltipTest.java

        C:\SAM80B130\CONSOLE\smarts\tomcat\webapps\webconsole>\jdk1.6.0_10\bin\j
        ava TooltipTest


        Revised source file follows
        TooltipTest.java
        //import java.awt.FlowLayout;
        import javax.swing.*;
        import javax.swing.table.*;

        import javax.swing.border.*;
        import java.awt.*;
        import java.awt.event.*;

        public class TooltipTest extends JApplet {


        String[] columnNames = {"Col1",
                                "Col2",
                                "Col3",
                                "Col4",
                                "Col5"};

        Object[][] data = null;

          public static void main(String[] argv) {
              TooltipTest app = new TooltipTest();

              app.init();


          }


          public void init() {
              JFrame frame = new JFrame("W1");
              data = new Object [40][5];
              for (int ix = 0; ix < 40; ++ix) {
                  data[ix][0] = "Name1-" + ix;
                  data[ix][1] = "Name2-" + ix;
                  data[ix][2] = "Function" + ix;
                  data[ix][3] = "";
                  data[ix][4] = "Name5-" + ix;
              }
              JTable t = new JTable( data, columnNames);
              t.setDefaultRenderer(String.class, new ObjectRenderer());
              t.setDefaultRenderer(Object.class, new ObjectRenderer());

               JScrollPane jsp = new JScrollPane(t);
              //frame.setSize(454, 204);
        frame.setSize(600,400);

               jsp.setPreferredSize(new Dimension(450, 200));

          // setLayout(new FlowLayout());
              GridBagLayout layout = new GridBagLayout();
              GridBagConstraints gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.gridwidth = 1;
                gbc.anchor = GridBagConstraints.SOUTHEAST;
                gbc.fill = GridBagConstraints.BOTH;
                gbc.insets = new Insets( 2,2,2,2 ) ;
              
              frame.getContentPane().setLayout(layout);
              layout.setConstraints(jsp, gbc);
              frame.getContentPane().add(jsp);
        //add(jsp);

              frame.setVisible(true);
                System.out.println("Version 3.00 " + getClass().getName());
                JFrame frame2 = new JFrame("W2");
                 JButton buttonX = new JButton("Button TESTX");
                buttonX.setToolTipText("Tooltip TESTX");
                buttonX.addActionListener(new ActionListener() {
                      public void actionPerformed(ActionEvent ae) {
                          System.out.println("buttonX clicked");
                      }

                });
               frame2.getContentPane().setLayout(new FlowLayout());
               frame2.getContentPane().add(buttonX);
                frame2.setSize(200, 200);
                frame2.setLocation(50, 50);
                frame2.setVisible(true);
          }

           static class ObjectRenderer extends DefaultTableCellRenderer {
                public ObjectRenderer(){
                        super();
                }
          
                    public Component getTableCellRendererComponent(JTable table, Object value,
                                                               boolean isSelected, boolean hasFocus, int row, int column) {
                                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

                        // if (isSelected)
                        // setBorder(BorderFactory.createMatteBorder(2,0,2,0,Color.black));
                        
                        //setOpaque(true);
                        String s = getText();
                        if (s.equals("Function0")) s = ""; // This does not fail (SmWrappedToolTipUI creates the problem here)
                        if (s.equals("Function1")) s =
                  "very long tool tip test text very long tool tip test text very long tool tip test text very long tool tip test text ends here";
                        setToolTipText( s);
                        return this;
                    }
            }

        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dcherepanov Dmitry Cherepanov
                  Reporter:
                  ndcosta Nelson Dcosta (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: