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

Toolkit.getBestCursorSize(int, int) works wrong for (0,0)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: dsR10051 Date: 04/28/2000


      The method
      public Dimension java.awt.Toolkit.getBestCursorSize(int preferredWidth, int preferredHeight)
      works wrong when parameters are (0,0) or (Integer.MIN_VALUE, Integer.MIN_VALUE).
      In this case it returns (0,0) dimension, but by documentation (0,0) dimension indicates that
      the Toolkit implementation doesn't support custom cursors:
      -----
          /**
           * Returns the supported cursor dimension which is closest to the desired
           * sizes. Systems which only support a single cursor size will return that
           * size regardless of the desired sizes. Systems which don't support custom
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           * cursors will return a dimension of 0, 0. <p>
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      ...
           * @return the closest matching supported cursor size, or a dimension of 0,0 if
                                                                         ^^^^^^^^^^^^^^^^^^^
           * the Toolkit implementation doesn't support custom cursors.
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           * @since 1.2
           */

      -----

      Here is a minimized test:
      import java.awt.*;

      public class ToolkitTest01 {

          public static void main(String args[]) {

              Toolkit tk = Toolkit.getDefaultToolkit();
              Dimension d = tk.getBestCursorSize(0,0);
              if(d.width == 0 && d.height == 0) {
                  System.out.println("System does not support custom cursor");
              } else {
                  System.out.println(d.width + " " + d.height);
              }
              d = tk.getBestCursorSize(Integer.MIN_VALUE, Integer.MIN_VALUE);
              if(d.width == 0 && d.height == 0) {
                  System.out.println("System does not support custom cursor");
              } else {
                  System.out.println(d.width + " " + d.height);
              }
          }
      }

      Output:
      %java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-B)
      Java HotSpot(TM) Client VM (build 1.3.0-B, interpreted mode)
      %java ToolkitTest01
      System does not support custom cursor
      System does not support custom cursor

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

        Attachments

          Activity

            People

            Assignee:
            rraysunw Richard Ray (Inactive)
            Reporter:
            sdasunw Sda Sda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: