Java Code Examples for javafx.scene.control.ColorPicker#getValue()

The following examples show how to use javafx.scene.control.ColorPicker#getValue() . 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: ColorPickerApp.java    From oim-fx with MIT License 6 votes vote down vote up
public Parent createContent() {
    final ColorPicker colorPicker = new ColorPicker(Color.GREEN);
    final Label coloredText = new Label("Colors");
    Font font = new Font(53);
    coloredText.setFont(font);
    final Button coloredButton = new Button("Colored Control");
    Color c = colorPicker.getValue();
    coloredText.setTextFill(c);
    coloredButton.setStyle(createRGBString(c));
    
    colorPicker.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent t) {
            Color newColor = colorPicker.getValue();
            coloredText.setTextFill(newColor);
            coloredButton.setStyle(createRGBString(newColor));
        }
    });
    
    VBox outerVBox = new VBox(coloredText, coloredButton, colorPicker);
    outerVBox.setAlignment(Pos.CENTER);
    outerVBox.setSpacing(20);
    outerVBox.setMaxSize(VBox.USE_PREF_SIZE, VBox.USE_PREF_SIZE);
    
    return outerVBox;
}
 
Example 2
Source File: JFXColorPickerSkin.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void updateColor() {
    final ColorPicker colorPicker = (ColorPicker) getSkinnable();
    Color color = colorPicker.getValue();
    Color circleColor = color == null ? Color.WHITE : color;
    // update picker box color
    if (((JFXColorPicker) getSkinnable()).isDisableAnimation()) {
        JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, circleColor);
    } else {
        Circle colorCircle = new Circle();
        colorCircle.setFill(circleColor);
        colorCircle.setManaged(false);
        colorCircle.setLayoutX(colorBox.getWidth() / 4);
        colorCircle.setLayoutY(colorBox.getHeight() / 2);
        colorBox.getChildren().add(colorCircle);
        Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240),
            new KeyValue(colorCircle.radiusProperty(),
                200,
                Interpolator.EASE_BOTH)));
        animateColor.setOnFinished((finish) -> {
            JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, colorCircle.getFill());
            colorBox.getChildren().remove(colorCircle);
        });
        animateColor.play();
    }
    // update label color
    displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf(
        "rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
    if (colorLabelVisible.get()) {
        displayNode.setText(JFXNodeUtils.colorToHex(circleColor));
    } else {
        displayNode.setText("");
    }
}
 
Example 3
Source File: JFXColorPickerSkin.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void initColor() {
    final ColorPicker colorPicker = (ColorPicker) getSkinnable();
    Color color = colorPicker.getValue();
    Color circleColor = color == null ? Color.WHITE : color;
    // update picker box color
    colorBox.setBackground(new Background(new BackgroundFill(circleColor, new CornerRadii(3), Insets.EMPTY)));
    // update label color
    displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf(
        "rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
    if (colorLabelVisible.get()) {
        displayNode.setText(JFXNodeUtils.colorToHex(circleColor));
    } else {
        displayNode.setText("");
    }
}
 
Example 4
Source File: ColorParameter.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setValueFromComponent(ColorPicker component) {
  value = component.getValue();
}