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

JToolTip fails to execute under WindowsLookAndFeel if .pack() method is used

    Details

      Description

      Name: jbT81659 Date: 05/27/2001

      OS: All Windows Platforms
      JDK: JDK1.4.0-Beta-b65
      Testcase: jToolTip.java

      The following "java.lang.NullPointerException" is thrown when I try to run the test case jToolTip.java
      under WindowsLookAndFeel under all windows platforms:

      ------------------------------------------------
      I:\JDK1.4\LAF>java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel jToolTip&
      Exception in thread "main" java.lang.NullPointerException
              at com.sun.java.swing.plaf.windows.WindowsButtonUI.getPreferredSize(WindowsButtonUI.java:12
              at javax.swing.JComponent.getPreferredSize(JComponent.java:1176)
              at java.awt.GridLayout.preferredLayoutSize(GridLayout.java:316)
              at java.awt.Container.preferredSize(Container.java:951)
              at java.awt.Container.getPreferredSize(Container.java:935)
              at javax.swing.JComponent.getPreferredSize(JComponent.java:1178)
              at javax.swing.JRootPane$RootLayout.preferredLayoutSize(JRootPane.java:807)
              at java.awt.Container.preferredSize(Container.java:951)
              at java.awt.Container.getPreferredSize(Container.java:935)
              at javax.swing.JComponent.getPreferredSize(JComponent.java:1178)
              at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:567)
              at java.awt.Container.preferredSize(Container.java:951)
              at java.awt.Container.getPreferredSize(Container.java:935)
              at java.awt.Window.pack(Window.java:409)
              at jToolTip.main(jToolTip.java:23)
      ------------------------------------------------
      This problem is related to the pack() method used with Frame. If I use the frame.setSize(x, y) where x and y are any
      integer valid numbers, then the problem is resolved.

      To reproduce this bug:
      1- Compile and run the following code "jToolTip.java"
      2- Note that the above exception is thrown.
      3- Change the following lines in the source code:
         frame.pack() to //frame.pack()
         //frame.setSize(300, 300) to frame.setSize(300, 300)
      4- Compile and execute the example again
      5- Note that application is displayed on screen.

      ----------Code------------------------
      /* Copyright (c) Sun Microsystems 1998

      $Header: /home-bazelet/sun/src/JDK1.4/standard/jToolTip.java,v 1.1 2001/05/04 07:12:47 isam Exp $

      */

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

      public class jToolTip extends JApplet
      {
              public void init()
              {
                      TooltipPanel1 tooltip = new TooltipPanel1();
                      getContentPane().add(tooltip);
              }

              public static void main(String[] argv)
              {
              JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
              frame.setContentPane(new TooltipPanel1());
              frame.pack();
              //frame.setSize(300, 300);
              frame.setVisible(true);
              frame.addWindowListener( new WindowAdapter()
              {
                   public void windowClosing( WindowEvent e)
                   {
                       System.exit(0);
                   }
              });
              }
      }
      class TooltipPanel1 extends JPanel
      {
              public TooltipPanel1()
              {
                      setLayout(new GridLayout(5,1));
                      UIManager.getDefaults().put("ToolTip.font",new Font("Lucida Sans Regular" , Font.PLAIN, 16));

                      JButton Button1 = new JButton();
                      JToolTip Button1TT = new JToolTip();

                      Button1TT.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
                      Button1.setToolTipText ("\u0647\u0630\u0627\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd" );
                      Button1.add(Button1TT);

                      Button1.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
                      Button1.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631\u0020\u0042\u0049\u0047\u0020\u0052\u0045\u0044\u0020\u0041\u0050\u0050\u004c\u0045\u0053\u0665\u0667\u0669\u0661");

                      JButton Button2 = new JButton();
                      Button2.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
                      Button2.setText("\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038");
                      Button2.setToolTipText ("\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038");

                      JButton Button3 = new JButton();
                      Button3.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
                      Button3.setText("\u05ea\u05e4\u05d5\u05d6\u05d9\u05dd\u0020\u05d8\u05e2\u05de\u05d9\u05dd\u0020\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e");
                      Button3.setToolTipText ("\u05ea\u05e4\u05d5\u05d6\u05d9\u05dd\u0020\u05d8\u05e2\u05de\u05d9\u05dd\u0020\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e");

                      JButton Button4 = new JButton();
                      Button4.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
                      Button4.setText("\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8");
                      Button4.setToolTipText ("\u006c\u0069\u006d\u0065\u0020\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e");

                      JButton Button5 = new JButton();
                      Button5.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
                      Button5.setText("\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u0020\u05d9\u05e7\u05e8");
                      Button5.setToolTipText ("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631");
                      add(Button1);
                      add(Button2);
                      add(Button3);
                      add(Button4);
                      add(Button5);
              }
      }



      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              alexp Alexander Potochkin (Inactive)
              Reporter:
              jbenavrasunw Jonathan Benavraham (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: