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

The sun.awt.motif.MToolkit.getBestCursorSize(int,int) does not check params


    • Subcomponent:
    • CPU:
    • OS:
      solaris_2.6, solaris_7


      Name: akC57697 Date: 11/21/97

      The sun.awt.motif.MToolkit.getBestCursorSize(int,int) does not work in accordance
      with spec when use Integer.MIN_VALUE or 0 as parameters.

      The comments for Toolkit.getBestCursorSize(int,int) says:
      " /**
           * 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>
           * Note: if an image is used whose dimensions don't match a supported size
           * (as returned by this method), the Toolkit implementation will attempt to
           * resize the image to a supported size.
           * Since converting low-resolution images is difficult,
           * no guarantees are made as to the quality of a cursor image which isn't a
           * supported size. It is therefore recommended that this method
           * be called and an appropriate image used so no image conversion is made.
           * @param desiredWidth the preferred cursor width the component would like
           * to use.
           * @param desiredHeight the preferred cursor height the component would like
           * to use.
           * @return the closest matching supported cursor size, or a dimension of 0,0 if
           * the Toolkit implementation doesn't support custom cursors.
           * @since JDK1.2

      Parameters Result dimension
      Integer.MAX_VALUE,Integer.MAX_VALUE 65535,65535
      0,0 0,0
      -1,-1 65535,65535
      -1000,-1000 64536,64536
      Integer.MIN_VALUE,Integer.MIN_VALUE 0,0

      Works under Windows95.

      import java.awt.*;

      public class CCursor {
          public static void main(String s[]) {

       Toolkit tk = Toolkit.getDefaultToolkit();
       if (!(tk.getBestCursorSize(16,16).getWidth()<1)) { // Use normal
        System.out.println("The system supports custom cursors.");
                                                                   // Use other..
       if (tk.getBestCursorSize(Integer.MIN_VALUE,Integer.MIN_VALUE).getWidth()<1) {
        System.out.println("The system does not support custom cursors.");
      (novo35 61): javac CCursor.java
      (novo35 62): java CCursor
      The system supports custom cursors.
      The system does not support custom cursors.
      (novo35 63): java -fullversion
      java full version "JDK-1.2beta2-V"





            • Assignee:
              bino Bino George
              akuzminorcl Alexander Kuzmin (Inactive)
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: