FANDOM


Mouse Cursors (Compiler)Edit

Move mouse over the labels to display the different inbuild images of the mouse cursor.

import javafx.ext.swing.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.geometry.*;
import javafx.scene.transform.*;
import javafx.scene.text.*;


public class CursorInfo {
    public attribute cursor     : Cursor;
    public attribute description: String;
}// CursorInfo


var cursors = [CursorInfo{cursor: Cursor.CROSSHAIR description: 'crosshair cursor'},
               CursorInfo{cursor: Cursor.HAND      description: 'hand cursor'},
               CursorInfo{cursor: Cursor.MOVE      description: 'move cursor'},
               CursorInfo{cursor: Cursor.TEXT      description: 'text cursor'},
               CursorInfo{cursor: Cursor.WAIT      description: 'wait cursor'},
               CursorInfo{cursor: Cursor.DEFAULT   description: 'default cursor'},
               CursorInfo{cursor: Cursor.NONE      description: 'none cursor'},

               CursorInfo{cursor: Cursor.NW_RESIZE description: 'north-west-resize'},
               CursorInfo{cursor: Cursor.N_RESIZE  description: 'north-resize cursor'},
               CursorInfo{cursor: Cursor.NE_RESIZE description: 'north-east-resize cursor'},
               CursorInfo{cursor: Cursor.E_RESIZE  description: 'east-resize cursor'},
               CursorInfo{cursor: Cursor.SE_RESIZE description: 'south-east-resize cursor'},
               CursorInfo{cursor: Cursor.S_RESIZE  description: 'south-resize cursor'},
               CursorInfo{cursor: Cursor.SW_RESIZE description: 'south-west-resize cursor'},
               CursorInfo{cursor: Cursor.W_RESIZE  description: 'west-resize cursor'},

               CursorInfo{cursor: Cursor.H_RESIZE  description: 'horizontal cursor'},
               CursorInfo{cursor: Cursor.V_RESIZE  description: 'vertical cursor'}
              ];              ;


public class CursorLabel extends CustomNode {
    public attribute description: String;
    
    public override function create(): Node {
        var text = Text{transform : Transform.translate(20, 4)
                        textOrigin: TextOrigin.TOP
                        fill      : Color.WHITE
                        font      : Font{size: 20}
                        content   : description
        };
        
         
        Group{
            content: [Rectangle {width : text.getWidth() + 24
                                 height: text.getHeight() + 8
                                 fill  : Color.BLACK},           
                      text]
        }// Group
    }// create()
}// CursorLabel


                    
SwingFrame {
    closeAction: function(): Void {java.lang.System.exit(0);}
     
    title      : 'Mouse cursors'
    background : Color.WHITE;
    visible    : true

    content: GridPanel{
        columns: 1
        rows   : sizeof cursors
        
        content: [for(mouseCursor in cursors) 
                      Canvas{content: CursorLabel{cursor     : mouseCursor.cursor
                                                  description: mouseCursor.description}}   
                 ]
    }// GridPanel
}// SwingFrame


Mouse Cursors (Interpreter)Edit

Move mouse over the buttons to display the different inbuild images of the mouse cursor. Example works in JFXPad.

import javafx.ui.*;


Frame {
    title : 'Mouse cursors'
    width : 600
    height: 600

    content: Box {
         orientation: VERTICAL
         
         content: [foreach(mouseCursor in [CROSSHAIR:Cursor, DEFAULT:Cursor,   
                                           E_RESIZE:Cursor,  HAND:Cursor,
                                           H_RESIZE:Cursor,  MOVE:Cursor,
                                           NE_RESIZE:Cursor, NW_RESIZE:Cursor,
                                           N_RESIZE:Cursor,  SE_RESIZE:Cursor,
                                           SW_RESIZE:Cursor, S_RESIZE:Cursor,
                                           TEXT:Cursor,      V_RESIZE:Cursor,
                                           WAIT:Cursor,      W_RESIZE:Cursor]) 
                   Button {text  : mouseCursor.getCursor().name
                           cursor: mouseCursor}]
    }// Box
    
    visible: true
}// Frame

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.