javafx.scene.input.MouseButton Java Examples

The following examples show how to use javafx.scene.input.MouseButton. 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: Pencil.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Binds a DnD interaction to draw squared shapes.
 */
private void bindDnDToDrawSquaredShape() {
	nodeBinder()
		.usingInteraction(() -> new DnD(false, true))
		.toProduce(i -> {
			final SquaredShape sq = (SquaredShape) editing.createShapeInstance();
			final Point pt = getAdaptedPoint(i.getSrcLocalPoint());
			sq.setPosition(pt.getX() - 1d, pt.getY() - 1d);
			sq.setWidth(2d);
			return new AddShape(sq, canvas.getDrawing());
		})
		.on(canvas)
		.first((i, c) -> {
			canvas.requestFocus();
			canvas.setTempView(viewFactory.createView(c.getShape()).orElse(null));
		})
		.then((i, c) -> updateShapeFromCentre((SquaredShape) c.getShape(), getAdaptedPoint(i.getSrcLocalPoint()), getAdaptedPoint(i.getTgtLocalPoint()).getX()))
		.endOrCancel(i -> canvas.setTempView(null))
		.when(i -> i.getButton() == MouseButton.PRIMARY && (editing.getCurrentChoice() == EditionChoice.SQUARE ||
			editing.getCurrentChoice() == EditionChoice.CIRCLE || editing.getCurrentChoice() == EditionChoice.CIRCLE_ARC))
		.strictStart()
		.bind();
}
 
Example #2
Source File: ConnectorDragManager.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Handles mouse-released events on the given connector.
 *
 * @param event a mouse-released event
 * @param connector the {@link GConnector} on which this event occured
 */
private void handleMouseReleased(final MouseEvent event, final GConnector connector) {

    if (!event.getButton().equals(MouseButton.PRIMARY)) {
        return;
    }

    if (targetConnector != null && skinLookup.lookupConnector(targetConnector) != null) {
        skinLookup.lookupConnector(targetConnector).applyStyle(GConnectorStyle.DEFAULT);
    }

    sourceConnector = null;
    removalConnector = null;
    repositionAllowed = true;

    tailManager.cleanUp();

    event.consume();
}
 
Example #3
Source File: RFXButtonBaseTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void getText() {
    Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
            text.add(rfxButtonBase.getAttribute("text"));
        }
    });
    new Wait("Waiting for button text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Color", text.get(0));
}
 
Example #4
Source File: ASTTreeCell.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void commonUpdate(Node item) {
    setContextMenu(buildContextMenu(item));

    DragAndDropUtil.registerAsNodeDragSource(this, item, root);

    // Reclicking the selected node in the ast will scroll back to the node in the editor
    this.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
        TreeItem<Node> selectedItem = getTreeView().getSelectionModel().getSelectedItem();
        if (t.getButton() == MouseButton.PRIMARY
            && selectedItem != null && selectedItem.getValue() == item) {
            onNodeItemSelected.accept(item);
            t.consume();
        }
    });
}
 
Example #5
Source File: DesktopApp.java    From FXTutorials with MIT License 6 votes vote down vote up
DesktopWindow(Parent root) {
    setBackground(new Background(new BackgroundFill(Color.BLUE, null, null)));

    root.setTranslateY(15);

    setOnMousePressed(e -> {
        offsetX = e.getX();
        offsetY = e.getY();
    });

    setOnMouseDragged(e -> {
        if (e.getButton() != MouseButton.PRIMARY)
            return;

        setTranslateX(e.getSceneX() - offsetX);
        setTranslateY(e.getSceneY() - offsetY);
    });

    getChildren().add(root);
}
 
Example #6
Source File: ContextHandling.java    From Recaf with MIT License 6 votes vote down vote up
/**
 * @param controller
 * 		Controller to use.
 * @param codeArea
 * 		Text editor events originate from.
 */
public ContextHandling(GuiController controller, CodeArea codeArea) {
	this.codeArea = codeArea;
	this.controller = controller;
	codeArea.setOnMousePressed(e -> {
		// Only accept right-click presses
		if (e.getButton() != MouseButton.SECONDARY)
			return;
		// Reset
		codeArea.setContextMenu(null);
		// Mouse to location
		CharacterHit hit = codeArea.hit(e.getX(), e.getY());
		int charPos = hit.getInsertionIndex();
		codeArea.getCaretSelectionBind().displaceCaret(charPos);
		TwoDimensional.Position pos = codeArea.offsetToPosition(charPos,
				TwoDimensional.Bias.Backward);
		// Get selection
		Object selection = getSelection(pos);
		if (selection == null)
			return;
		if (consumer != null)
			consumer.accept(selection);
	});
}
 
Example #7
Source File: ConnectorDragManager.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Handles drag-entered events on the given connector.
 *
 * @param event a drag-entered event
 * @param connector the {@link GConnector} on which this event occured
 */
private void handleDragEntered(final MouseEvent event, final GConnector connector) {

    if (!event.getButton().equals(MouseButton.PRIMARY)) {
        return;
    }

    if (event.getButton().equals(MouseButton.PRIMARY) && validator.prevalidate(sourceConnector, connector)) {

        final boolean valid = validator.validate(sourceConnector, connector);
        tailManager.snapPosition(sourceConnector, connector, valid);

        repositionAllowed = false;

        if (valid) {
            skinLookup.lookupConnector(connector).applyStyle(GConnectorStyle.DRAG_OVER_ALLOWED);
        } else {
            skinLookup.lookupConnector(connector).applyStyle(GConnectorStyle.DRAG_OVER_FORBIDDEN);
        }
    }

    event.consume();
}
 
Example #8
Source File: UICanvasEditor.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
/**
 This is called when the mouse listener is invoked and a mouse release was the event

 @param mousex x position of mouse relative to canvas
 @param mousey y position of mouse relative to canvas
 @param mb mouse button that was released
 */
protected void mouseReleased(int mousex, int mousey, @NotNull MouseButton mb) {
	this.mouseButtonDown = MouseButton.NONE;
	selection.setSelecting(false);
	setContextMenu(null, mousex, mousey);
	contextMenuControl = null;
	if (mb == MouseButton.SECONDARY) {
		if (menuCreator != null && selection.getFirst() != null) {
			contextMenuControl = selection.getFirst();
			setContextMenu(menuCreator.initialize(contextMenuControl.getComponent()), mousex, mousey);
		} else if (canvasContextMenu != null) {
			setContextMenu(canvasContextMenu, mousex, mousey);
		}
	} else {
		if (hasDoubleClickedCtrl) {
			doubleClickUpdateGroup.update(selection.getFirst());
		}
	}
}
 
Example #9
Source File: RequestCollectionComponent.java    From milkman with MIT License 6 votes vote down vote up
private Node createRequestEntry(Collection collection, RequestContainer request) {
		Label requestType = new Label(request.getType());
		requestType.getStyleClass().add("request-type");
		Label button = new Label(request.getName());

		VBox vBox = new VBox(new HBox(requestType,button));
		vBox.getStyleClass().add("request-entry");
		vBox.setOnMouseClicked(e -> {
//			if (e.getButton() == MouseButton.PRIMARY)
//				onCommand.invoke(new UiCommand.LoadRequest(request.getId()));
//			else
			if (e.getButton() == MouseButton.PRIMARY) {
				onCommand.invoke(new UiCommand.LoadRequest(request.getId()));
				e.consume();
			}
			if (e.getButton() == MouseButton.SECONDARY) {
				reqCtxMenu.show(request, collection, vBox, e.getScreenX(), e.getScreenY());
				e.consume();
			}
				
		});
		return vBox;
	}
 
Example #10
Source File: SpaceRunnerApp.java    From FXGLGames with MIT License 6 votes vote down vote up
@Override
protected void initInput() {
    onKey(KeyCode.W, () -> playerComponent.up());
    onKey(KeyCode.S, () -> playerComponent.down());

    getInput().addAction(new UserAction("Change Weapon") {
        @Override
        protected void onAction() {
            playerComponent.changeWeapon();

            weaponTexture.setImage(image("sprite_laser.png"));
            bullets.textProperty().bind(getip("laser").asString("x %d"));
        }
    }, KeyCode.F);

    getInput().addAction(new UserAction("Shoot") {
        @Override
        protected void onAction() {
            playerComponent.shoot();
        }
    }, MouseButton.PRIMARY);
}
 
Example #11
Source File: GoapSample.java    From FXGLGames with MIT License 6 votes vote down vote up
@Override
protected void initInput() {
    onBtnDown(MouseButton.PRIMARY, "move", () -> {
        player.getComponent(ActionComponent.class).pushAction(new ContinuousAction() {
            Point2D p = new Point2D(getInput().getMouseXWorld(), getInput().getMouseYWorld());

            @Override
            protected void perform(double tpf) {

                if (player.getPosition().distance(p) > 10) {
                    player.getTransformComponent().translateTowards(p, 5);
                } else {
                    isCompleted = true;
                }
            }
        });
    });
}
 
Example #12
Source File: ConnectorDragManager.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Handles mouse-dragged events on the given connector.
 *
 * @param event a mouse-dragged event
 * @param connector the {@link GConnector} on which this event occured
 */
private void handleMouseDragged(final MouseEvent event, final GConnector connector) {

    if (!event.getButton().equals(MouseButton.PRIMARY)) {
        return;
    }

    if (!repositionAllowed) {
        event.consume();
        return;
    }

    // Case for when the mouse first exits a connector during a drag gesture.
    if (removalConnector != null && !removalConnector.equals(hoveredConnector)) {
        detachConnection(event, connector);
    } else {
        tailManager.updatePosition(event);
    }

    event.consume();
}
 
Example #13
Source File: TicTacToe.java    From games_oop_javafx with Apache License 2.0 6 votes vote down vote up
private EventHandler<MouseEvent> buildMouseEvent(Group panel) {
    return event -> {
        Figure3T rect = (Figure3T) event.getTarget();
        if (this.checkState()) {
            if (event.getButton() == MouseButton.PRIMARY) {
                rect.take(true);
                panel.getChildren().add(
                        this.buildMarkX(rect.getX(), rect.getY(), 50)
                );
            } else {
                rect.take(false);
                panel.getChildren().add(
                        this.buildMarkO(rect.getX(), rect.getY(), 50)
                );
            }
            this.checkWinner();
            this.checkState();
        }
    };
}
 
Example #14
Source File: FXNonApplicationThreadRule.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Fires a newly created {@link MouseEvent} of type
 * {@link MouseEvent#MOUSE_RELEASED} to the target {@link Node} of the last
 * mouse interaction.
 *
 * @param mods
 *            The {@link Modifiers} for the {@link MouseEvent}.
 */
public void mouseRelease(final Modifiers mods) {
	waitForIdle();
	run(() -> {
		Point2D local = lastMouseInteraction.target.sceneToLocal(lastMouseInteraction.sceneX,
				lastMouseInteraction.sceneY);
		Point2D screen = lastMouseInteraction.target.localToScreen(local.getX(), local.getY());
		fireEvent(lastMouseInteraction.target,
				new MouseEvent(lastMouseInteraction.target, lastMouseInteraction.target, MouseEvent.MOUSE_RELEASED,
						local.getX(), local.getY(), screen.getX(), screen.getY(), MouseButton.PRIMARY, 1,
						mods.shift, mods.control, mods.alt, mods.meta, false, false, false, false, false, false,
						new PickResult(lastMouseInteraction.target, lastMouseInteraction.sceneX,
								lastMouseInteraction.sceneY)));
	});
	waitForIdle();
}
 
Example #15
Source File: ListNodePanel.java    From oim-fx with MIT License 6 votes vote down vote up
private void iniEvent() {
    topBox.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
        	if(event.getButton()==MouseButton.PRIMARY) {
        		if (isShow) {
                    isShow = false;
                    imageView.setImage(closed);
                    ListNodePanel.this.getChildren().remove(box);
                } else {
                    isShow = true;
                    imageView.setImage(open);
                    ListNodePanel.this.getChildren().add(box);
                }
        	}
        }
    });
}
 
Example #16
Source File: JFXChartUtil.java    From jfxutils with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an {@link EventHandler} that sets X and/or Y axis auto ranging when the primary mouse button is
 * double-clicked. If the click occurs inside the X axis area auto range only the X axis and similarly for Y axis. But
 * if the event is in the plot area or anywhere else, auto range both axes.
 */
public static EventHandler<MouseEvent> getDoublePrimaryClickAutoRangeHandler( final XYChartInfo chartInfo ) {
	return new EventHandler<MouseEvent>() {
		@Override
		public void handle( MouseEvent event ) {
			if ( event.getClickCount() == 2 && event.getButton() == MouseButton.PRIMARY ) {
				double x = event.getX();
				double y = event.getY();
				if ( !chartInfo.getXAxisArea().contains( x, y ) )
					chartInfo.getChart().getYAxis().setAutoRanging( true );
				if ( !chartInfo.getYAxisArea().contains( x, y ) )
					chartInfo.getChart().getXAxis().setAutoRanging( true );
			}
		}
	};
}
 
Example #17
Source File: ResultList.java    From iliasDownloaderTool with GNU General Public License v2.0 6 votes vote down vote up
private void showContextMenu(MouseEvent event) {
	menu.hide();
	final List<IliasTreeNode> selectedNodes = ((ResultList) event.getSource())
			.getSelectionModel().getSelectedItems();
	if (selectedNodes.isEmpty() || selectedNodes == null) {
		return;
	}
	if (selectedNodes.size() == 1) {
		dashboard.getCoursesTreeView().selectFile((IliasFile) selectedNodes.get(0));
	}

	if (event.getButton() == MouseButton.SECONDARY) {
		menu = new FileContextMenu(dashboard).createMenu(selectedNodes, event);
		menu.show(this, event.getScreenX(), event.getScreenY());
	}
}
 
Example #18
Source File: GoapSample.java    From FXGLGames with MIT License 6 votes vote down vote up
@Override
protected void initInput() {
    onBtnDown(MouseButton.PRIMARY, "move", () -> {
        player.getComponent(ActionComponent.class).pushAction(new ContinuousAction() {
            Point2D p = new Point2D(getInput().getMouseXWorld(), getInput().getMouseYWorld());

            @Override
            protected void perform(double tpf) {

                if (player.getPosition().distance(p) > 10) {
                    player.getTransformComponent().translateTowards(p, 5);
                } else {
                    isCompleted = true;
                }
            }
        });
    });
}
 
Example #19
Source File: FX.java    From FxDock with Apache License 2.0 5 votes vote down vote up
/** sometimes MouseEvent.isPopupTrigger() is not enough */
public static boolean isPopupTrigger(MouseEvent ev)
{
	if(ev.getButton() == MouseButton.SECONDARY)
	{
		if(CPlatform.isMac())
		{
			if
			(
				!ev.isAltDown() &&
				!ev.isMetaDown() &&
				!ev.isShiftDown()
			)
			{
				return true;
			}
		}
		else
		{
			if
			(
				!ev.isAltDown() &&
				!ev.isControlDown() &&
				!ev.isMetaDown() &&
				!ev.isShiftDown()
			)
			{
				return true;
			}
		}
	}
	return false;
}
 
Example #20
Source File: ClickableBitcoinAddress.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
@FXML
protected void requestMoney(MouseEvent event) {
    if (event.getButton() == MouseButton.SECONDARY || (event.getButton() == MouseButton.PRIMARY && event.isMetaDown())) {
        // User right clicked or the Mac equivalent. Show the context menu.
        addressMenu.show(addressLabel, event.getScreenX(), event.getScreenY());
    } else {
        // User left clicked.
        try {
            Desktop.getDesktop().browse(URI.create(uri()));
        } catch (IOException e) {
            GuiUtils.informationalAlert("Opening wallet app failed", "Perhaps you don't have one installed?");
        }
    }
}
 
Example #21
Source File: SeqTraceView.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
private void onTraceClicked(MouseEvent me) {
    if(me.getButton().equals(MouseButton.PRIMARY)) {
        if(me.getClickCount() == 2) {
            SeqTraceLog selectedItem = table.getSelectionModel().getSelectedItem();

            if(selectedItem != null) {
                showTraceTermView(selectedItem);
            }
        }
    }
}
 
Example #22
Source File: TestCanvasCreation.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDrawSquare() {
	final Point2D pos = point(canvas).query();
	Cmds.of(CmdFXVoid.of(() -> editing.setCurrentChoice(EditionChoice.SQUARE)),
		() -> drag(pos, MouseButton.PRIMARY).dropBy(101d, 11d)).execute();

	assertEquals(1, drawing.size());
	assertTrue(drawing.getShapeAt(0).orElseThrow() instanceof Square);
	assertEquals(202d, drawing.getShapeAt(0).orElseThrow().getWidth(), 0.00001d);
	assertEquals(202d, drawing.getShapeAt(0).orElseThrow().getHeight(), 0.00001d);

	assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getX() - 101d, drawing.getShapeAt(0).orElseThrow().getTopLeftPoint().getX(), 0.00001d);
	assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getY() - 101d, drawing.getShapeAt(0).orElseThrow().getTopLeftPoint().getY(), 0.00001d);
}
 
Example #23
Source File: ImageManufacturePenController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
    @Override
    public void mouseDragged(MouseEvent event) {
        if (null == opType || imageView == null || imageView.getImage() == null) {
            return;
        }
        DoublePoint p = imageController.getImageXY(event, imageView);
        imageController.showXY(event, p);

        if (event.getButton() == MouseButton.SECONDARY || p == null) {
            return;
        }

        switch (opType) {
            case Polyline:
                if (lastX == event.getX() && lastY == event.getY()) {
                    return;
                }
                imageController.scrollPane.setPannable(false);
                imageController.maskLineData.add(p);
                lastX = event.getX();
                lastY = event.getY();
                drawPolyline();
                break;
            case DrawLines:
            case Erase:
//            case Mosaic:
//            case Frosted:
                imageController.scrollPane.setPannable(false);
                imageController.maskPenData.addPoint(p);
                lastX = event.getX();
                lastY = event.getY();
                updateMask();
        }

    }
 
Example #24
Source File: ProjectFileTreeView.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void handleClicks(TreeItem<File> item, MouseButton button, int clickCount) {
	if (button == MouseButton.PRIMARY && item != null && item.getValue().isFile()) {
		if (clickCount == 1)
			fileEditorManager.openPreviewEditor(item.getValue());
		else if (clickCount == 2)
			fileEditorManager.openEditor(item.getValue());
	}
}
 
Example #25
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void doubleClickedEllipse(MouseEvent event) {
    if (maskEllipseLine == null || !maskEllipseLine.isVisible()) {
        return;
    }
    DoublePoint p = getImageXY(event, imageView);
    if (p == null) {
        return;
    }
    double x = p.getX();
    double y = p.getY();
    if (event.getButton() == MouseButton.PRIMARY) {
        if (x != maskEllipseData.getCenterX()) {
            double xr = Math.abs(x - maskEllipseData.getCenterX());
            maskEllipseData = new DoubleEllipse(
                    maskEllipseData.getCenterX() - xr,
                    maskEllipseData.getCenterY() - maskEllipseData.getRadiusY(),
                    maskEllipseData.getCenterX() + xr,
                    maskEllipseData.getCenterY() + maskEllipseData.getRadiusY()
            );
            drawMaskEllipseLine();
        }

    } else if (event.getButton() == MouseButton.SECONDARY) {
        if (y != maskEllipseData.getCenterY()) {
            double yr = Math.abs(y - maskEllipseData.getCenterY());
            maskEllipseData = new DoubleEllipse(
                    maskEllipseData.getCenterX() - maskEllipseData.getRadiusX(),
                    maskEllipseData.getCenterY() - yr,
                    maskEllipseData.getCenterX() + maskEllipseData.getRadiusX(),
                    maskEllipseData.getCenterY() + yr
            );
            drawMaskEllipseLine();
        }

    }
}
 
Example #26
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void doubleClickedRectangle(MouseEvent event) {
    if (maskRectangleLine == null || !maskRectangleLine.isVisible()) {
        return;
    }
    DoublePoint p = getImageXY(event, imageView);
    if (p != null) {
        double x = p.getX();
        double y = p.getY();
        if (event.getButton() == MouseButton.PRIMARY) {

            if (x < maskRectangleData.getBigX() && y < maskRectangleData.getBigY()) {
                maskRectangleData.setSmallX(x);
                maskRectangleData.setSmallY(y);
                drawMaskRectangleLine();
            }

        } else if (event.getButton() == MouseButton.SECONDARY) {

            if (x > maskRectangleData.getSmallX() && y > maskRectangleData.getSmallY()) {
                maskRectangleData.setBigX(x);
                maskRectangleData.setBigY(y);
                drawMaskRectangleLine();
            }

        }
    }
}
 
Example #27
Source File: ContextMenuTests.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void pressing_middle_mouse_button_hides_context_menu() {
    // given menu is showing
    showContextMenuAt();

    moveTo(firstLineOfArea()).press(MouseButton.MIDDLE);

    assertFalse(area.getContextMenu().isShowing());
}
 
Example #28
Source File: ListboxRenderer.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
@Override
public void mousePress(@NotNull MouseButton mb) {
	super.mousePress(mb);
	if (mouseButtonDown != MouseButton.PRIMARY) {
		return;
	}
	this.selectedRow = Math.abs(this.mouseOverY - this.y1) / getRowPixelHeight();
}
 
Example #29
Source File: Exercise_15_15.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a pane
	Pane pane = new Pane();

	// Create and register the handle
	pane.setOnMouseClicked(e -> {
		// Create a circle
		Circle circle = new Circle(e.getX(), e.getY(), 5);
		circle.setFill(Color.WHITE);
		circle.setStroke(Color.BLACK);
		if (e.getButton() == MouseButton.PRIMARY) {
			pane.getChildren().add(circle);
		}
		else if (e.getButton() == MouseButton.SECONDARY) {
			ObservableList<Node> list = pane.getChildren();
			for (int i = 0; i < list.size(); i++) {
				Circle c = (Circle)list.get(i);
				if (circle.contains(c.getCenterX(), c.getCenterY())) {
					list.remove(i);
				}
			}
		}
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_15_15"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example #30
Source File: UICanvasPreview.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
@Override
protected void mouseReleased(int mousex, int mousey, @NotNull MouseButton mb) {
	if (mousePressControl == null) {
		return;
	}
	mousePressControl.getRenderer().mouseRelease();
	if (mousePressControl.getRenderer().canHaveFocus()) {
		focusHandler.setFocusedControl(mousePressControl);
	}
}