@@ -375,7 +375,7 @@ public Frame initFrame(PApplet sketch, Color backgroundColor,
375375 }
376376 frame .getContentPane ().setBackground (backgroundColor );
377377
378- // Set the trimmings around the image
378+ // Put the p5 logo in the Frame's corner to override the Java coffee cup.
379379 setIconImage (frame );
380380
381381 // For 0149, moving this code (up to the pack() method) before init().
@@ -812,7 +812,7 @@ private boolean checkRetina() {
812812 }
813813
814814
815- // get the bounds for all displays
815+ /** Get the bounds rectangle for all displays. */
816816 static Rectangle getDisplaySpan () {
817817 Rectangle bounds = new Rectangle ();
818818 GraphicsEnvironment environment =
@@ -1418,8 +1418,8 @@ public void run() {
14181418 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14191419
14201420
1421- int cursorType = PConstants .ARROW ; // cursor type
1422- boolean cursorVisible = true ; // cursor visibility flag
1421+ int cursorType = PConstants .ARROW ;
1422+ boolean cursorVisible = true ;
14231423 Cursor invisibleCursor ;
14241424
14251425
@@ -1436,26 +1436,22 @@ public void setCursor(int kind) {
14361436
14371437
14381438 public void setCursor (PImage img , int x , int y ) {
1439- // don 't set this as cursor type , instead use cursor_type
1440- // to save the last cursor used in case cursor() is called
1439+ // Don 't set cursorType , instead use cursorType to save the last
1440+ // regular cursor type used for when cursor() is called.
14411441 //cursor_type = Cursor.CUSTOM_CURSOR;
1442- Image jimage =
1443- canvas .getToolkit ().createImage (new MemoryImageSource (img .width , img .height ,
1444- img .pixels , 0 , img .width ));
1445- Point hotspot = new Point (x , y );
1446- Toolkit tk = Toolkit .getDefaultToolkit ();
1447- Cursor cursor = tk .createCustomCursor (jimage , hotspot , "Custom Cursor" );
1442+ Cursor cursor =
1443+ canvas .getToolkit ().createCustomCursor ((Image ) img .getNative (),
1444+ new Point (x , y ),
1445+ "custom" );
14481446 canvas .setCursor (cursor );
14491447 cursorVisible = true ;
1450-
14511448 }
14521449
14531450
14541451 public void showCursor () {
1455- // maybe should always set here? seems dangerous, since
1456- // it's likely that java will set the cursor to something
1457- // else on its own, and the applet will be stuck b/c bagel
1458- // thinks that the cursor is set to one particular thing
1452+ // Maybe should always set here? Seems dangerous, since it's likely that
1453+ // Java will set the cursor to something else on its own, and the sketch
1454+ // will be stuck b/c p5 thinks the cursor is set to one particular thing.
14591455 if (!cursorVisible ) {
14601456 cursorVisible = true ;
14611457 canvas .setCursor (Cursor .getPredefinedCursor (cursorType ));
@@ -1464,18 +1460,15 @@ public void showCursor() {
14641460
14651461
14661462 public void hideCursor () {
1467- // in 0216, just re-hide it?
1468- // if (!cursorVisible) return; // don't hide if already hidden.
1463+ // Because the OS may have shown the cursor on its own,
1464+ // don't return if 'cursorVisible' is set to true. [rev 0216]
14691465
14701466 if (invisibleCursor == null ) {
14711467 BufferedImage cursorImg =
14721468 new BufferedImage (16 , 16 , BufferedImage .TYPE_INT_ARGB );
14731469 invisibleCursor =
14741470 canvas .getToolkit ().createCustomCursor (cursorImg , new Point (8 , 8 ), "blank" );
14751471 }
1476- // was formerly 16x16, but the 0x0 was added by jdf as a fix
1477- // for macosx, which wasn't honoring the invisible cursor
1478- // cursor(invisibleCursor, 8, 8);
14791472 canvas .setCursor (invisibleCursor );
14801473 cursorVisible = false ;
14811474 }
0 commit comments