Java Code Examples for javafx.scene.control.Button#setOnMouseReleased()

The following examples show how to use javafx.scene.control.Button#setOnMouseReleased() . 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: Dialog.java    From DashboardFx with GNU General Public License v3.0 6 votes vote down vote up
private static Button createButton(ButtonType type, String text, EventHandler<MouseEvent> eventEventHandler){
    Button button = new Button(text);
    button.setCursor(Cursor.HAND);
    button.setOnMouseReleased(eventEventHandler);
    button.setPrefWidth(100);
    button.addEventHandler(MouseEvent.MOUSE_RELEASED, close);

    switch (type){
        case CANCEL:
            button.setDefaultButton(true);
            break;
        case OK:
            button.setDefaultButton(true);
            break;
    }
    return button;
}
 
Example 2
Source File: PlayerController.java    From Simple-Media-Player with MIT License 6 votes vote down vote up
private void setIcon(Button button,String path,int size){
    Image icon = new Image(path);
    ImageView imageView = new ImageView(icon);
    imageView.setFitWidth(size);
    imageView.setFitHeight((int)(size * icon.getHeight() / icon.getWidth()));
    button.setGraphic(imageView);
    //设置图标点击时发亮
    ColorAdjust colorAdjust = new ColorAdjust();
    button.setOnMousePressed(event ->  {
        colorAdjust.setBrightness(0.5);
        button.setEffect(colorAdjust);
    });
    button.setOnMouseReleased(event -> {
        colorAdjust.setBrightness(0);
        button.setEffect(colorAdjust);
    });
}
 
Example 3
Source File: IntegerBaseManagedMenuItem.java    From tcMenu with Apache License 2.0 5 votes vote down vote up
/**
 * For integer items, we put controls on the form to increase and decrease the value using delta
 * value change messages back to the server. Notice we don't change the tree locally, rather we wait
 * for the menu to respond to the change.
 */
@Override
public Node createNodes(RemoteMenuController menuController) {
    itemLabel = new Label();
    itemLabel.setPadding(new Insets(3, 0, 3, 0));

    minusButton = new Button("<");
    plusButton = new Button(">");
    minusButton.setDisable(item.isReadOnly());
    plusButton.setDisable(item.isReadOnly());

    minusButton.setOnAction(e-> {
        if(waitingFor.isPresent()) return;
        waitingFor = Optional.of(menuController.sendDeltaUpdate(item, REDUCE));
    });

    minusButton.setOnMousePressed(e-> {
        repeating = RepeatTypes.REPEAT_DOWN_WAIT;
        lastRepeatStart = System.currentTimeMillis();
    });
    minusButton.setOnMouseReleased(e-> repeating = RepeatTypes.REPEAT_NONE);
    plusButton.setOnMousePressed(e-> {
        repeating = RepeatTypes.REPEAT_UP_WAIT;
        lastRepeatStart = System.currentTimeMillis();
    });
    plusButton.setOnMouseReleased(e-> repeating = RepeatTypes.REPEAT_NONE);
    plusButton.setOnAction(e-> {
        if(waitingFor.isPresent()) return;
        waitingFor = Optional.of(menuController.sendDeltaUpdate(item, INCREASE));
    });

    var border = new BorderPane();
    border.setLeft(minusButton);
    border.setRight(plusButton);
    border.setCenter(itemLabel);
    return border;
}
 
Example 4
Source File: Gui.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * display a warning popup
 * @param message the message to display
 * @param okEvent an event fired when the user presses the ok button
 */
public static void warningPopup(String message, EventHandler<ActionEvent> okEvent) {
	final Stage warningStage = new Stage();
	warningStage.setTitle("Warning");

	warningStage.initModality(Modality.APPLICATION_MODAL);
	warningStage.setResizable(false);

	try {
		Pane main = FXMLLoader.load(Gui.class.getResource("/resources/warning.fxml"));
		warningStage.setScene(new Scene(main, 500, 280));

		Text messageText = (Text) main.lookup("#message");
		messageText.setText(message);

		ImageView image = (ImageView) main.lookup("#image");
		image.setImage(new Image(Gui.class.getResource("/resources/warning.png").toExternalForm()));

		Button okButton = (Button) main.lookup("#ok");
		Button cancelButton = (Button) main.lookup("#cancel");
		okButton.setOnAction(okEvent);
		okButton.setOnMouseReleased(mouseEvent -> warningStage.close());
		okButton.setOnKeyPressed(keyEvent -> warningStage.close());

		cancelButton.setOnAction(actionEvent1 -> warningStage.close());

	} catch (IOException e) {
		e.printStackTrace();
	}
	warningStage.show();
}
 
Example 5
Source File: BoolButtonRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ButtonBase createJFXNode() throws Exception
{
    led = new Ellipse();
    led.getStyleClass().add("led");
    button = new Button("BoolButton", led);
    button.getStyleClass().add("action_button");
    button.setMnemonicParsing(false);

    // Model has width/height, but JFX widget has min, pref, max size.
    // updateChanges() will set the 'pref' size, so make min use that as well.
    button.setMinSize(ButtonBase.USE_PREF_SIZE, ButtonBase.USE_PREF_SIZE);

    // Fix initial layout
    toolkit.execute(() -> Platform.runLater(button::requestLayout));

    if (! toolkit.isEditMode())
    {
        if (model_widget.propMode().getValue() == Mode.TOGGLE)
            button.setOnAction(event -> handlePress(true));
        else
        {
            final boolean inverted = model_widget.propMode().getValue() == Mode.PUSH_INVERTED;
            button.setOnMousePressed(event -> handlePress(! inverted));
            button.setOnMouseReleased(event -> handlePress(inverted));
        }
    }

    return button;
}