javafx.scene.Cursor Java Examples

The following examples show how to use javafx.scene.Cursor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VncImageView.java    From jfxvnc with Apache License 2.0 6 votes vote down vote up
public void registerListener() {

    setOnMouseEntered(event -> {
      if (!isDisabled()) {
        requestFocus();
        setCursor(remoteCursor != null ? remoteCursor : Cursor.DEFAULT);
      }
    });

    setOnMouseExited(event -> {
      if (!isDisabled()) {
        setCursor(Cursor.DEFAULT);
      }
    });
    
    zoomLevelProperty().addListener(l -> {
      if (getImage() != null) {
        setFitHeight(getImage().getHeight() * zoomLevelProperty().get());
      }
    });
  }
 
Example #2
Source File: ConnectDialogController.java    From trex-stateless-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(URL url, ResourceBundle rb) {
    initializeConnections();

    isConnectionInProgress = new SimpleBooleanProperty(false);
    isConnectionInProgress.addListener(
        (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
            if (newValue != null) {
                mainViewContainer.setDisable(newValue);
                mainViewContainer.getScene().setCursor(newValue ? Cursor.WAIT : Cursor.DEFAULT);
            }
        }
    );

    timeoutField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("\\d*")) {
            timeoutField.setText(newValue.replaceAll("[^\\d]", ""));
        }
    });
}
 
Example #3
Source File: PauseResumeButton.java    From G-Earth with MIT License 6 votes vote down vote up
public PauseResumeButton(boolean isPaused) {
    this.isPaused[0] = isPaused;

    this.imagePause = new Image(getClass().getResourceAsStream("/gearth/ui/buttons/files/ButtonPause.png"));
    this.imagePauseOnHover = new Image(getClass().getResourceAsStream("/gearth/ui/buttons/files/ButtonPauseHover.png"));
    this.imageResume = new Image(getClass().getResourceAsStream("/gearth/ui/buttons/files/ButtonResume.png"));
    this.imageResumeOnHover = new Image(getClass().getResourceAsStream("/gearth/ui/buttons/files/ButtonResumeHover.png"));
    this.imageView = new ImageView();

    setCursor(Cursor.DEFAULT);
    getChildren().add(imageView);
    setOnMouseEntered(onMouseHover);
    setOnMouseExited(onMouseHoverDone);

    imageView.setImage(isPaused() ? imageResume : imagePause);

    setEventHandler(MouseEvent.MOUSE_CLICKED, event -> click());
}
 
Example #4
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();

	final Rectangle resizeHandleNW = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleNW.xProperty().bind(xProperty.subtract(handleRadius / 2));
	resizeHandleNW.yProperty().bind(yProperty.subtract(handleRadius / 2));

	setUpDragging(resizeHandleNW, mouseLocation, Cursor.NW_RESIZE);

	resizeHandleNW.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragNorth(event, mouseLocation, region, handleRadius);
			dragWest(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleNW;
}
 
Example #5
Source File: PointsEditor.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Activate mode
 *
 *  <p>Display required UI elements, hook event handlers
 *  @param mode Desired mode
 */
private void startMode(final Mode mode)
{
    this.mode = mode;
    if (mode == Mode.APPEND)
    {
        handle_group.getScene().addEventFilter(MouseEvent.MOUSE_PRESSED, append_mouse_filter);
        handle_group.getScene().addEventFilter(MouseEvent.MOUSE_MOVED, append_mouse_filter);
        handle_group.getChildren().setAll(line);
        line.setVisible(false);
        if (cursor_add != null)
            handle_group.getScene().setCursor(cursor_add);
    }
    else
    {
        final ObservableList<Node> parent = handle_group.getChildren();
        parent.clear();
        for (int i = 0; i < points.size(); ++i)
            parent.add(new Handle(i));
        handle_group.getScene().setCursor(Cursor.HAND);
    }
}
 
Example #6
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();
	final DoubleBinding halfHeightProperty = heightProperty.divide(2);

	final Rectangle resizeHandleW = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleW.xProperty().bind(xProperty.subtract(handleRadius / 2));
	resizeHandleW.yProperty().bind(yProperty.add(halfHeightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleW, mouseLocation, Cursor.W_RESIZE);

	resizeHandleW.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragWest(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleW;
}
 
Example #7
Source File: AbstractSingleValueIndicator.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private void initLine() {
    // mouse transparent if not editable
    line.setMouseTransparent(true);
    pickLine.setPickOnBounds(true);
    pickLine.setStroke(Color.TRANSPARENT);
    pickLine.setStrokeWidth(getPickingDistance());
    pickLine.mouseTransparentProperty().bind(editableIndicatorProperty().not());
    pickLine.setOnMousePressed(mouseEvent -> {
        /*
         * Record a delta distance for the drag and drop operation. Because layoutLine() sets the start/end points
         * we have to use these here. It is enough to use the start point. For X indicators, start x and end x are
         * identical and for Y indicators start y and end y are identical.
         */
        dragDelta.x = pickLine.getStartX() - mouseEvent.getX();
        dragDelta.y = pickLine.getStartY() - mouseEvent.getY();
        pickLine.setCursor(Cursor.MOVE);
        mouseEvent.consume();
    });
}
 
Example #8
Source File: LoginController.java    From ChatRoom-JavaFX with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
	// TODO Auto-generated method stub
	/* Drag and Drop */
       borderPane.setOnMousePressed(event -> {
           xOffset = getLocalStage().getX() - event.getScreenX();
           yOffset = getLocalStage().getY() - event.getScreenY();
           borderPane.setCursor(Cursor.CLOSED_HAND);
       });
       borderPane.setOnMouseDragged(event -> {
       	getLocalStage().setX(event.getScreenX() + xOffset);
       	getLocalStage().setY(event.getScreenY() + yOffset);
       });
       borderPane.setOnMouseReleased(event -> {
           borderPane.setCursor(Cursor.DEFAULT);
       });
       //设置图标
       setIcon("images/icon_chatroom.png");
       //房间号选择
       roomIDChoiceBox.getSelectionModel().selectedItemProperty().addListener(
       		(ObservableValue<? extends String> ov, String old_val, String new_val)->
       		{roomID = new_val;});
}
 
Example #9
Source File: SkinAction.java    From DashboardFx with GNU General Public License v3.0 6 votes vote down vote up
private void setupListeners() {

        final TextField textField = getSkinnable();

        button.setOnMouseReleased(event -> mouseReleased());
        button.setOnMousePressed(event -> mousePressed());
        button.addEventFilter(MouseEvent.MOUSE_CLICKED, event -> {
            if(graphic.isVisible())button.setCursor(Cursor.HAND);
            else button.setCursor(Cursor.DEFAULT);

        });
        button.setOnMouseMoved(event -> {
            if(graphic.isVisible())button.setCursor(Cursor.HAND);
            else button.setCursor(Cursor.DEFAULT);
        });
        textField.textProperty().addListener((observable, oldValue, newValue) -> textChanged());
        textField.focusedProperty().addListener((observable, oldValue, newValue) -> focusChanged());

        button.setMinWidth(10);
        button.setMinHeight(10);
        graphic.setMinWidth(10);
        graphic.setMinHeight(10);
    }
 
Example #10
Source File: UICanvasEditor.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
private void changeCursorToScale(Edge edge) {
	if (edge == Edge.None) {
		changeCursorToDefault();
		return;
	}
	if (edge == Edge.TopLeft || edge == Edge.BottomRight) {
		canvas.setCursor(Cursor.NW_RESIZE);
		return;
	}
	if (edge == Edge.TopRight || edge == Edge.BottomLeft) {
		canvas.setCursor(Cursor.NE_RESIZE);
		return;
	}
	if (edge == Edge.Top || edge == Edge.Bottom) {
		canvas.setCursor(Cursor.N_RESIZE);
		return;
	}
	if (edge == Edge.Left || edge == Edge.Right) {
		canvas.setCursor(Cursor.W_RESIZE);
		return;
	}
	throw new IllegalStateException("couldn't find correct cursor for edge:" + edge.name());
}
 
Example #11
Source File: TemplateManager.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void configureBindings() {
	buttonBinder()
		.toProduce(() -> new UpdateTemplates(templatePane, svgGen, true))
		.on(updateTemplates)
		.bind();

	nodeBinder()
		.usingInteraction(DnD::new)
		.toProduce(i -> new LoadTemplate(svgGen, drawing, new File((String) i.getSrcObject().orElseThrow().getUserData()),
			statusController.getProgressBar(), statusController.getLabel(), app))
		.on(templatePane)
		.first(c -> templatePane.setCursor(Cursor.CLOSED_HAND))
		.then((i, c) -> {
			final Node srcObj = i.getSrcObject().orElseThrow();
			final Point3D pt3d = i.getTgtObject().orElseThrow().sceneToLocal(srcObj.localToScene(i.getTgtLocalPoint())).
				subtract(Canvas.ORIGIN.getX() + srcObj.getLayoutX(), Canvas.ORIGIN.getY() + srcObj.getLayoutY(), 0d);
			c.setPosition(ShapeFactory.INST.createPoint(pt3d));
		})
		.when(i -> i.getSrcObject().orElse(null) instanceof ImageView &&
			i.getSrcObject().get().getUserData() instanceof String &&
			i.getTgtObject().orElse(null) instanceof Canvas)
		.endOrCancel(i -> templatePane.setCursor(Cursor.MOVE))
		.bind();
}
 
Example #12
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleSE = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2));
	resizeHandleSE.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSE, mouseLocation, Cursor.SE_RESIZE);

	resizeHandleSE.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragEast(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSE;
}
 
Example #13
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty();
	final DoubleBinding halfWidthProperty = widthProperty.divide(2);
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleS = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleS.xProperty().bind(xProperty.add(halfWidthProperty).subtract(handleRadius / 2));
	resizeHandleS.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleS, mouseLocation, Cursor.S_RESIZE);

	resizeHandleS.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleS;
}
 
Example #14
Source File: StopWatchSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
Button(Color colorWeak, Color colorStrong) {
    this.colorStrong = colorStrong;
    this.colorWeak = colorWeak;
    configureDesign();
    setCursor(Cursor.HAND);
    getChildren().addAll(rectangleVisual, rectangleSmall, rectangleBig, rectangleWatch);
}
 
Example #15
Source File: JFXCursor.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Map<UICursor, Cursor> createCursorMap() {
	Map<UICursor, Cursor> cursorMap = new HashMap<UICursor, Cursor>();
	cursorMap.put(UICursor.NORMAL, Cursor.DEFAULT);
	cursorMap.put(UICursor.WAIT, Cursor.WAIT);
	cursorMap.put(UICursor.HAND, Cursor.HAND);
	cursorMap.put(UICursor.SIZEWE, Cursor.H_RESIZE);
	cursorMap.put(UICursor.SIZENS, Cursor.V_RESIZE);
	return cursorMap;
}
 
Example #16
Source File: FloodFill2D.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public void fillAt(final double x, final double y, final long fill)
{
	if (!isVisible.getAsBoolean())
	{
		LOG.info("Selected source is not visible -- will not fill");
		return;
	}

	final int level = 0;
	final int time = 0;
	final MaskInfo<UnsignedLongType> maskInfo = new MaskInfo<>(time, level, new UnsignedLongType(fill));

	final Scene  scene          = viewer.getScene();
	final Cursor previousCursor = scene.getCursor();
	scene.setCursor(Cursor.WAIT);
	try
	{
		final Mask<UnsignedLongType> mask = source.generateMask(maskInfo, FOREGROUND_CHECK);
		final Interval affectedInterval = fillMaskAt(x, y, this.viewer, mask, source, assignment, FILL_VALUE, this.fillDepth.get());
		requestRepaint.run();
		source.applyMask(mask, affectedInterval, FOREGROUND_CHECK);
	} catch (final MaskInUse e)
	{
		LOG.debug(e.getMessage());
	} finally
	{
		scene.setCursor(previousCursor);
	}
}
 
Example #17
Source File: DragResizer.java    From Open-Lowcode with Eclipse Public License 2.0 5 votes vote down vote up
protected void mouseOver(MouseEvent event) {
	if (isInDraggableZone(event) || dragging) {
		region.setCursor(Cursor.S_RESIZE);

	} else {
		region.setCursor(Cursor.DEFAULT);

	}
}
 
Example #18
Source File: RecordingListController.java    From archivo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Disable the TiVo controls and the recording list
 */
private void disableUI() {
    if (!uiDisabled) {
        logger.debug("Disabling UI");
        mainApp.getPrimaryStage().getScene().setCursor(Cursor.WAIT);
        uiDisabled = true;
    }
}
 
Example #19
Source File: TitledNodeSkin.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the content of the node skin - header, title, close button, etc.
 */
private void createContent() {

    header.getStyleClass().setAll(STYLE_CLASS_HEADER);
    header.setAlignment(Pos.CENTER);

    title.getStyleClass().setAll(STYLE_CLASS_TITLE);

    final Region filler = new Region();
    HBox.setHgrow(filler, Priority.ALWAYS);

    final Button closeButton = new Button();
    closeButton.getStyleClass().setAll(STYLE_CLASS_BUTTON);

    header.getChildren().addAll(title, filler, closeButton);
    contentRoot.getChildren().add(header);
    getRoot().getChildren().add(contentRoot);

    closeButton.setGraphic(AwesomeIcon.TIMES.node());
    closeButton.setCursor(Cursor.DEFAULT);
    closeButton.setOnAction(event -> Commands.removeNode(getGraphEditor().getModel(), getNode()));

    contentRoot.minWidthProperty().bind(getRoot().widthProperty());
    contentRoot.prefWidthProperty().bind(getRoot().widthProperty());
    contentRoot.maxWidthProperty().bind(getRoot().widthProperty());
    contentRoot.minHeightProperty().bind(getRoot().heightProperty());
    contentRoot.prefHeightProperty().bind(getRoot().heightProperty());
    contentRoot.maxHeightProperty().bind(getRoot().heightProperty());

    contentRoot.setLayoutX(BORDER_WIDTH);
    contentRoot.setLayoutY(BORDER_WIDTH);

    contentRoot.getStyleClass().setAll(STYLE_CLASS_BACKGROUND);
}
 
Example #20
Source File: EditDataSet.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
public EditDataSet() {
    super();
    editable = true;

    setDragCursor(Cursor.CROSSHAIR);

    selectRectangle.setManaged(false);
    selectRectangle.getStyleClass().add(STYLE_CLASS_SELECT_RECT);
    getChartChildren().add(selectRectangle);

    registerMouseHandlers();
    registerKeyHandlers();

    markerPane.setManaged(false);

    // register marker pane
    chartProperty().addListener((change, o, n) -> {
        if (o != null) {
            o.getCanvasForeground().getChildren().remove(markerPane);
            o.getPlotArea().setBottom(null);
            // markerPane.prefWidthProperty().unbind();
            // markerPane.prefHeightProperty().unbind();
        }
        if (n != null) {
            n.getCanvasForeground().getChildren().add(markerPane);
            markerPane.toFront();
            markerPane.setVisible(true);
            // markerPane.prefWidthProperty().bind(n.getCanvas().widthProperty());
            // markerPane.prefHeightProperty().bind(n.getCanvas().heightProperty());
        }
    });
}
 
Example #21
Source File: Game2048.java    From fx2048 with GNU General Public License v3.0 5 votes vote down vote up
private void setEnhancedDeviceSettings(Stage primaryStage, Scene scene) {
    var isARM = System.getProperty("os.arch").toUpperCase().contains("ARM");
    if (isARM) {
        primaryStage.setFullScreen(true);
        primaryStage.setFullScreenExitHint("");
    }

    if (Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) {
        scene.setCursor(Cursor.NONE);
    }
}
 
Example #22
Source File: MainMenu.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Swaps the mouse cursor type between DEFAULT and HAND
 *
 * @param node
 */
public static void setMouseCursor(Node node) {
	node.addEventHandler(MouseEvent.MOUSE_EXITED, event -> {
		node.setCursor(Cursor.DEFAULT);
	});

	node.addEventHandler(MouseEvent.MOUSE_ENTERED, event -> {
		node.setCursor(Cursor.HAND);
	});
}
 
Example #23
Source File: CursorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Node createBox(Cursor cursor) {
    Label label = new Label(cursor.toString());
    label.setAlignment(Pos.CENTER);
    label.setPrefSize(85, 85);
    label.setStyle("-fx-border-color: #aaaaaa; -fx-background-color: #dddddd;");
    label.setCursor(cursor);
    return label;
}
 
Example #24
Source File: BooleanLangGUIOption.java    From MSPaintIDE with MIT License 5 votes vote down vote up
@Override
public Control getDisplay() {
    var checkbox = new JFXCheckBox("");
    checkbox.styleProperty().set("-jfx-checked-color: -primary-button-color;");
    checkbox.setMnemonicParsing(false);
    checkbox.setCursor(Cursor.HAND);
    checkbox.selectedProperty().bindBidirectional(this.value);
    GridPane.setColumnIndex(checkbox, 1);

    return checkbox;
}
 
Example #25
Source File: AbstractValueIndicator.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of the indicator.
 *
 * @param axis the axis this indicator is associated with
 * @param text the text to be shown by the label. Value of {@link #textProperty()}.
 */
protected AbstractValueIndicator(Axis axis, final String text) {
    super();
    this.axis = axis;
    setText(text);

    label.mouseTransparentProperty().bind(editableIndicatorProperty().not());
    label.pickOnBoundsProperty().set(true);

    label.setOnMousePressed(mouseEvent -> {
        /*
         * Record a delta distance for the drag and drop operation. PROBLEM: At this point, we need to know the
         * relative position of the label with respect to the indicator value.
         */
        Point2D c = label.sceneToLocal(mouseEvent.getSceneX(), mouseEvent.getSceneY());
        dragDelta.x = -(c.getX() + xOffset);
        dragDelta.y = c.getY() + yOffset;
        label.setCursor(Cursor.MOVE);
        mouseEvent.consume();
    });

    editableIndicatorProperty().addListener((ch, o, n) -> updateMouseListener(n));
    updateMouseListener(isEditable());

    chartProperty().addListener((obs, oldChart, newChart) -> {
        if (oldChart != null) {
            removeAxisListener();
            removePluginsListListener(oldChart);
        }
        if (newChart != null) {
            addAxisListener();
            addPluginsListListener(newChart);
        }
    });

    textProperty().addListener((obs, oldText, newText) -> layoutChildren());
}
 
Example #26
Source File: WebDisplayable.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new web displayable.
 *
 * @param url the url for the displayable.
 */
public WebDisplayable(String url) {
    this.url = url;
    webView = new WebView();
    webEngine = webView.getEngine();
    webEngine.setJavaScriptEnabled(true);
    webView.setCursor(Cursor.NONE);
    webView.setZoom(zoomLevel);
    webEngine.load(getUrl());
    webEngine.getLoadWorker().exceptionProperty().addListener((ObservableValue<? extends Throwable> ov, Throwable t, Throwable t1) -> {
        LOGGER.log(Level.WARNING, "Website loading exception: ", t1);
    });
}
 
Example #27
Source File: ResizeListener.java    From Path-of-Leveling with MIT License 5 votes vote down vote up
public ResizeListener(Stage stage) {
    this.stage = stage;
    isPressed = false;
    cursorEvent = Cursor.DEFAULT;
    border = 3;
    stageStartH = 0;
    stageStartW = 0;
    stageStartX = 0;
    stageStartY = 0;
    this.addResizeListener();
}
 
Example #28
Source File: ShowSplitPane.java    From oim-fx with MIT License 5 votes vote down vote up
private Cursor getCursor(MouseEvent me, Pane pane) {
	Cursor cursor = Cursor.DEFAULT;

	double grp = 4;
	double width = pane.getWidth();
	double height = pane.getHeight();

	double x = me.getX();
	double y = me.getY();

	if (x < grp && y < grp) {
		// cursor = Cursor.SE_RESIZE;
		type = 1;
	} else if (x > (width - grp) && y < grp) {
		// cursor = Cursor.SW_RESIZE;
		type = 2;
	} else if (x < grp && y > (height - grp)) {
		// cursor = Cursor.SW_RESIZE;
		type = 3;
	} else if (x > (width - grp) && y > (height - grp)) {
		// cursor = Cursor.SE_RESIZE;
		type = 4;
	} else if (x < grp) {
		// cursor = Cursor.H_RESIZE;
		type = 5;
	} else if (x > (width - grp)) {
		// cursor = Cursor.H_RESIZE;
		type = 6;
	} else if (y < grp) {
		cursor = Cursor.V_RESIZE;
		type = 7;
	} else if (y > (height - grp)) {
		// cursor = Cursor.V_RESIZE;
		type = 8;
	} else {
		type = 0;
	}
	return cursor;
}
 
Example #29
Source File: JFXDecorator.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void showDragCursorOnBorders(MouseEvent mouseEvent) {
    if (primaryStage.isMaximized() || primaryStage.isFullScreen() || maximized) {
        this.setCursor(Cursor.DEFAULT);
        return; // maximized mode does not support resize
    }
    if (!primaryStage.isResizable()) {
        return;
    }
    double x = mouseEvent.getX();
    double y = mouseEvent.getY();
    if (contentPlaceHolder.getBorder() != null && contentPlaceHolder.getBorder().getStrokes().size() > 0) {
        double borderWidth = contentPlaceHolder.snappedLeftInset();
        if (isRightEdge(x)) {
            if (y < borderWidth) {
                this.setCursor(Cursor.NE_RESIZE);
            } else if (y > this.getHeight() - borderWidth) {
                this.setCursor(Cursor.SE_RESIZE);
            } else {
                this.setCursor(Cursor.E_RESIZE);
            }
        } else if (isLeftEdge(x)) {
            if (y < borderWidth) {
                this.setCursor(Cursor.NW_RESIZE);
            } else if (y > this.getHeight() - borderWidth) {
                this.setCursor(Cursor.SW_RESIZE);
            } else {
                this.setCursor(Cursor.W_RESIZE);
            }
        } else if (isTopEdge(y)) {
            this.setCursor(Cursor.N_RESIZE);
        } else if (isBottomEdge(y)) {
            this.setCursor(Cursor.S_RESIZE);
        } else {
            this.setCursor(Cursor.DEFAULT);
        }
    }
}
 
Example #30
Source File: Text.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void mouseEntered(CircuitManager manager, CircuitState state) {
	Scene scene = manager.getSimulatorWindow().getScene();
	prevCursor = scene.getCursor();
	scene.setCursor(Cursor.TEXT);
	
	entered = true;
}