You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vasily Zakharov (JIRA)" <ji...@apache.org> on 2007/07/23 03:13:31 UTC

[jira] Commented: (HARMONY-4491) [classlib][awt] Exception when trying to create custom cursor

    [ https://issues.apache.org/jira/browse/HARMONY-4491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12514535 ] 

Vasily Zakharov commented on HARMONY-4491:
------------------------------------------

The exception occurs because createImage() creates Image of width -1 and height -1 (both on RI and Harmony), and createCustomCursor() on Harmony throws IndexOutOfBoundsException if hotSpot coordinates are beyond (0, width - 1) and (0, height - 1) range.

On RI createCustomCursor() doesn't throw exception in this situation. Moreover, this behavior has a basis in specification: "If the image to display is invalid, the cursor will be hidden (made completely transparent), and the hotspot will be set to (0, 0)". It seems image having negative dimensions is clearly invalid, so we shouldn't check if hotspot falls into its dimensions, but should set hotspot position to 0 instead.


> [classlib][awt] Exception when trying to create custom cursor
> -------------------------------------------------------------
>
>                 Key: HARMONY-4491
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4491
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitriy Matveev
>
> import java.awt.Cursor;
> import java.awt.Point;
> import java.awt.Toolkit;
> public class TestCursor {
>     public static void main(String[] args) {
>         Toolkit tk = Toolkit.getDefaultToolkit();
>         byte b[] = { (byte) 0 };
>         try{
>             Cursor blankCursor =
>                 tk.createCustomCursor( tk.createImage( b ), new Point(0, 0), "" );
>         }catch(IndexOutOfBoundsException e){
>             e.printStackTrace();
>         }
>     }
> }
> Exception below:
> java.lang.IndexOutOfBoundsException: invalid hotSpot
> 	at java.awt.Toolkit.createCustomCursor(Toolkit.java:740)
> 	at JavaTest.TestFonts2D.main(TestFonts2D.java:51)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.