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

The following examples show how to use javafx.scene.control.Button#setOnMousePressed() . 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: 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 2
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 3
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;
}
 
Example 4
Source File: PluginManagerWidget.java    From BowlerStudio with GNU General Public License v3.0 5 votes vote down vote up
public PluginManagerWidget(PluginManager m, Node graphic){
	HBox content = new HBox(20);

	content.setPadding(new Insets(0, 20, 10, 20)); 
	this.manager = m;
	ArrayList<TitledPane> plugins = manager.getPlugins();
	accordion.getPanes().addAll(plugins);
	disconnectTHis = new Button("Disconnect "+manager.getName(), AssetFactory.loadIcon("Disconnect-Device.png"));

	disconnectTHis.setOnMousePressed(	event -> {
		new Thread(){
			public void run(){
				Thread.currentThread().setUncaughtExceptionHandler(new IssueReportingExceptionHandler());

				setName("disconnect plugins");
			    	Log.warning("Disconnect button for "+manager.getName()+" pressed");
			    	getManager().getDevice().disconnect();
		    	
			}
		}.start();

	});
	setGraphic(AssetFactory.loadIcon("Bowler-Device-In-Manager.png"));
	deviceName.setOnAction(event -> {
		getManager().setName(deviceName.getText());
		setText(manager.getName());
		disconnectTHis.setText("Disconnect "+manager.getName());
	});
	Platform.runLater(()->deviceName.setText(manager.getName()));
	content.setHgrow(accordion, Priority.ALWAYS);
	content.getChildren().addAll(graphic,disconnectTHis,deviceName,accordion);
	setContent(content);
	setText(manager.getName());
}