本文整理汇总了Java中javafx.scene.control.ColorPicker.setOnAction方法的典型用法代码示例。如果您正苦于以下问题:Java ColorPicker.setOnAction方法的具体用法?Java ColorPicker.setOnAction怎么用?Java ColorPicker.setOnAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ColorPicker
的用法示例。
在下文中一共展示了ColorPicker.setOnAction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import javafx.scene.control.ColorPicker; //导入方法依赖的package包/类
@Override
public void handle() {
Pane root = new Pane();
Text splash = createText();
ColorPicker colorPicker = new ColorPicker();
Circle circle = new Circle(100,100,30);
circle.setFill(colorPicker.getValue());
colorPicker.setOnAction(e -> circle.setFill(colorPicker.getValue()));
Button okayButton = createButton(root, colorPicker);
root.getChildren().addAll(circle, colorPicker, okayButton, splash);
Scene scene = new Scene(root,400,200);
scene.getStylesheets().setAll(CSS_LOCATION);
stage.setScene(scene);
stage.show();
}
示例2: initializeColorPicker
import javafx.scene.control.ColorPicker; //导入方法依赖的package包/类
private void initializeColorPicker(HBox alignment){
ColorPicker cp = new ColorPicker();
c = Color.WHITE;
cp.setOnAction(e -> {
c = cp.getValue();
String rgb = Math.round(c.getRed()*255) + " " + Math.round(c.getGreen()*255) + " " + Math.round(c.getBlue()*255);
Tooltip tp = new Tooltip(rgb);
Tooltip.install(cp, tp);
});
alignment.getChildren().add(cp);
}
示例3: createColorPicker
import javafx.scene.control.ColorPicker; //导入方法依赖的package包/类
private ColorPicker createColorPicker (String id) {
ColorPicker colorPicker = new ColorPicker();
colorPicker.setId(id);
colorPicker.setOnAction(e -> updateValue(resourceBundle.getString(id),
colorPicker.getValue().toString()));
return colorPicker;
}
示例4: putColorPicker
import javafx.scene.control.ColorPicker; //导入方法依赖的package包/类
private ColorPicker putColorPicker () {
ColorPicker colorPicker = new ColorPicker();
colorPicker.setOnAction(event -> {
colorChosen = colorPicker.getValue();
});
return colorPicker;
}
示例5: createColorPicker
import javafx.scene.control.ColorPicker; //导入方法依赖的package包/类
/** @param section Segment of the color map
* @return ColorPicker that updates this segment in #color_sections
*/
private ColorPicker createColorPicker(final ColorSection section)
{
final Color color = section.color;
final int index = color_sections.indexOf(section);
if (index < 0)
throw new IllegalArgumentException("Cannot locate color section " + section);
final ColorPicker picker = new ColorPicker(color);
picker.setOnAction(event ->
{
color_sections.set(index, new ColorSection(section.value, picker.getValue()));
updateMapFromSections();
});
return picker;
}
示例6: toolbarControlsFactory
import javafx.scene.control.ColorPicker; //导入方法依赖的package包/类
@Override
public List<Node> toolbarControlsFactory() {
List<Node> controls = super.toolbarControlsFactory();
CheckBox ellipsesCheckBox = new CheckBox("Ellipses");
ellipsesCheckBox.setSelected(true);
ellipsesCheckBox.setOnAction(mouseEvent -> {
plot.setProperty(ELLIPSES, ellipsesCheckBox.isSelected());
});
ChoiceBox<SigmaPresentationModes> uncertaintyChoiceBox = new ChoiceBox<>(FXCollections.observableArrayList(SigmaPresentationModes.values()));
uncertaintyChoiceBox.setValue(SigmaPresentationModes.TWO_SIGMA_ABSOLUTE);
uncertaintyChoiceBox.setConverter(new StringConverter<SigmaPresentationModes>() {
@Override
public String toString(SigmaPresentationModes object) {
return object.getDisplayName();
}
@Override
public SigmaPresentationModes fromString(String string) {
return null;
}
});
uncertaintyChoiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<SigmaPresentationModes>() {
@Override
public void changed(ObservableValue observable, SigmaPresentationModes oldValue, SigmaPresentationModes newValue) {
plot.setProperty(UNCERTAINTY, newValue.getSigmaMultiplier());
}
});
ColorPicker ellipsesColorPicker = new ColorPicker(Color.RED);
ellipsesColorPicker.setStyle(COLORPICKER_CSS_STYLE_SPECS);
ellipsesColorPicker.setPrefWidth(100);
ellipsesColorPicker.setOnAction(mouseEvent -> {
// to satisfy D3
plot.setProperty(ELLIPSE_FILL_COLOR, ellipsesColorPicker.getValue().toString().substring(0, 8).replaceAll("0x", "#"));
});
CheckBox concordiaLineCheckBox = new CheckBox("Concordia");
concordiaLineCheckBox.setSelected(true);
concordiaLineCheckBox.setOnAction(mouseEvent -> {
plot.setProperty(CONCORDIA_LINE, concordiaLineCheckBox.isSelected());
});
CheckBox allSelectedCheckBox = new CheckBox("Select All");
allSelectedCheckBox.setSelected(true);
allSelectedCheckBox.setOnAction(mouseEvent -> {
setSelectedAllData(allSelectedCheckBox.isSelected());
});
CheckBox regressionUnctEnvelopeCheckBox = new CheckBox("2D Regression Unct");
regressionUnctEnvelopeCheckBox.setSelected(false);
regressionUnctEnvelopeCheckBox.setOnAction(mouseEvent -> {
plot.setProperty(REGRESSION_ENVELOPE, regressionUnctEnvelopeCheckBox.isSelected());
});
CheckBox regressionCheckBox = new CheckBox("2D Regression");
regressionCheckBox.setSelected(false);
regressionUnctEnvelopeCheckBox.setDisable(true);
regressionCheckBox.setOnAction(mouseEvent -> {
boolean isRegression = regressionCheckBox.isSelected();
plot.setProperty(REGRESSION_LINE, isRegression);
regressionUnctEnvelopeCheckBox.setDisable(!isRegression);
});
controls.add(ellipsesCheckBox);
controls.add(uncertaintyChoiceBox);
controls.add(ellipsesColorPicker);
controls.add(allSelectedCheckBox);
controls.add(concordiaLineCheckBox);
controls.add(regressionCheckBox);
controls.add(regressionUnctEnvelopeCheckBox);
return controls;
}
示例7: StrokeProperty
import javafx.scene.control.ColorPicker; //导入方法依赖的package包/类
public StrokeProperty(final GObject gObj, String name, String getter, final String setter, String fxml, String defaultValue, GridPane gp, int row, Node settingsNode, HistoryManager hm) {
this.gObj = gObj;
this.node = (Shape)gObj;
this.historyManager = hm;
gp.add(new Label("Stroke:"), 0, row);
gp.add(new Label("Stroke Width:"), 0, row + 1);
colorPicker = new ColorPicker();
textField = new TextField();
Color defaultStrokeColor = Color.LIMEGREEN;
double defaultStrokeWidth = 0;
//Grab value from settingsNode if given
if (settingsNode != null) {
Color loadedStrokeColor = (Color)((Shape)settingsNode).getStroke();
if (loadedStrokeColor != null) {
defaultStrokeColor = loadedStrokeColor;
defaultStrokeWidth = ((Shape)settingsNode).getStrokeWidth();// Inside IF otherwise loads as width=1 when no width is set
}
}
colorPicker.setValue(defaultStrokeColor);
textField.setText("" + defaultStrokeWidth);
setColor();
setWidth();
gp.add(colorPicker, 1, row);
gp.add(textField, 1, row + 1);
//On action, save to the GObject
colorPicker.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
setColor();
}
});
textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2) {
if (!aBoolean2) {
setWidth();
}
}
});
}