本文整理汇总了Java中javafx.scene.control.ColorPicker类的典型用法代码示例。如果您正苦于以下问题:Java ColorPicker类的具体用法?Java ColorPicker怎么用?Java ColorPicker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColorPicker类属于javafx.scene.control包,在下文中一共展示了ColorPicker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getText
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
@Test public void getText() {
ColorPicker colorPicker = (ColorPicker) getPrimaryStage().getScene().getRoot().lookup(".color-picker");
LoggingRecorder lr = new LoggingRecorder();
List<String> text = new ArrayList<>();
Platform.runLater(() -> {
RFXColorPicker rfxColorPicker = new RFXColorPicker(colorPicker, null, null, lr);
colorPicker.setValue(Color.rgb(234, 156, 44));
rfxColorPicker.focusLost(null);
text.add(rfxColorPicker._getText());
});
new Wait("Waiting for color picker text.") {
@Override public boolean until() {
return text.size() > 0;
}
};
AssertJUnit.assertEquals("#ea9c2c", text.get(0));
}
示例2: 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();
}
示例3: initialize
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
private void initialize () {
fonts = new ComboBox<>();
fonts.getItems().addAll(Font.getFamilies());
root.getChildren().add(GUIUtils.makeRow(new CustomText("Font"), fonts));
fontSize = new NumberTextField();
root.getChildren().add(GUIUtils.makeRow(new CustomText("Font Size"), fontSize));
color = new ColorPicker();
root.getChildren().add(GUIUtils.makeRow(new CustomText("Color"), color));
style = new ComboBox<>();
style.getItems().addAll(VoogaBundles.textStyles.keySet());
root.getChildren().add(GUIUtils.makeRow(new CustomText("Style"), style));
ButtonMaker maker = new ButtonMaker();
Button apply = maker.makeButton("Apply", e -> {
establishStyle();
this.close();
});
Button cancel = maker.makeButton("Cancel", e -> this.close());
root.getChildren().add(GUIUtils.makeRow(apply, cancel));
}
示例4: ColorPickerTableCell
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
public ColorPickerTableCell(TableColumn<T, Color> column , ColorCellFactory parent) {
this.parent = parent;
this.colorPicker = new ColorPicker();
this.colorPicker.getStyleClass().add("button");
this.colorPicker.setStyle("-fx-color-label-visible:false;");
this.colorPicker.editableProperty().bind(column.editableProperty());
this.colorPicker.disableProperty().bind(column.editableProperty().not());
this.colorPicker.setOnShowing(event -> {
final TableView<T> tableView = getTableView();
tableView.getSelectionModel().clearSelection();
tableView.getSelectionModel().select(getTableRow().getIndex());
tableView.edit(getIndex(), column);
});
this.colorPicker.valueProperty().addListener((observable, oldValue, newValue) -> {
if (isEditing()) {
commitEdit(newValue);
parent.chage(getIndex());
}
});
// 텍스트는 화면에 보여주지않음.
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
示例5: colorPropertyTest
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
@Smoke
@Test(timeout = 300000)
@Covers(value = {"javafx.scene.control.ColorPicker.value.BEHAVIOR", "javafx.scene.control.ColorPicker.value.GET",
"javafx.scene.control.ColorPicker.value.BIND", "javafx.scene.control.ColorPicker.value.DEFAULT",
"javafx.scene.control.ColorPicker.value.SET"}, level = Covers.Level.FULL)
public void colorPropertyTest() {
assertTrue(new ColorPicker().getValue().equals(Color.WHITE));
setColor("aaeeaa");
checkCurrentColorValue(Color.web("#aaeeaa"));
for (SettingType settingType : EnumSet.of(SettingType.BIDIRECTIONAL, SettingType.SETTER, SettingType.UNIDIRECTIONAL)) {
for (Color color : predefinedColors) {
setPropertyByChoiceBox(settingType, color, Properties.value);
checkTextFieldText(Properties.value, color.toString());
}
}
}
示例6: start
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
/**
*
* @param stage
* @throws Exception
*/
@Override
public void start(Stage stage) throws Exception {
VBox box = new VBox();
Scene scene = new Scene(box);
ColorPicker picker = new ColorPicker();
picker.setId("picker id");
box.getChildren().add(picker);
stage.setScene(scene);
stage.setWidth(300);
stage.setHeight(300);
stage.show();
}
示例7: ImageGenerator
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
public ImageGenerator() {
TextField[] fields = new TextField[] {(TextField) Components.imageSize[1], (TextField) Components.imageSize[2], (TextField) Components.shadowLength[1]};
for(TextField field : fields) {
Validate.removeError(field);
if(!Validate.isNumber(field)) {
error = true;
Validate.addError(field);
}
}
if(error) return;
this.width = Integer.parseInt(fields[0].getText());
this.height = Integer.parseInt(fields[1].getText());
this.length = Integer.parseInt(fields[2].getText());
javafx.scene.paint.Color color = ((ColorPicker) Components.backgroundColors[1]).getValue();
this.color = new Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue());
this.fading = ((CheckBox) Components.fading[1]).isSelected();
this.opacity = (float) ((Slider) Components.shadowOpacity[1]).getValue() / 100;
}
示例8: init
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
public static void init() {
JFXHelper.runLater(() -> {
Stage stage = new Stage();
stage.setTitle("ColorPicker");
Scene scene = new Scene(new HBox(20), 240, 30);
HBox box = (HBox) scene.getRoot();
box.setPadding(new Insets(5, 5, 5, 5));
color_picker = new ColorPicker();
color_picker.setValue(Color.CORAL);
color_picker.setOnAction(e -> {
Color color = color_picker.getValue();
a = 1 - (float) color.getOpacity();
r = (float) color.getRed();
g = (float) color.getGreen();
b = (float) color.getBlue();
});
box.getChildren().addAll(color_picker);
stage.setScene(scene);
stage.show();
});
}
示例9: ThemeBuilderShortcutsPane
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
/**
* Constructs a new {@link ThemeBuilderShortcutsPane}.
* @param styling the {@link JavaFxStyle}.
* @param shortcuts the {@link ThemeBuilderShortcutProperties}.
*/
ThemeBuilderShortcutsPane( JavaFxStyle styling, ThemeBuilderShortcutProperties shortcuts ){
this.shortcuts = shortcuts;
this.registrations = new RegistrationManager();
styling.configureHalfWidthConstraints( this );
label = styling.createBoldLabel( LABEL_TEXT );
add( label, 0, 0 );
picker = new ColorPicker();
styling.configureColorPicker( picker, ( Color )null );
add( picker, 1, 0 );
this.registrations.apply(
new ChangeListenerBindingImpl< Color >( picker.valueProperty(), shortcuts.shortcutColorProperty()
) );
styling.applyBasicPadding( this );
}
示例10: addItemConfiguration
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
/**
* General mechanism for adding {@link ColorPicker}s.
* @param row the row to add the items on.
* @param label the {@link Label} describing the {@link ColorPicker}.
* @param picker the {@link ColorPicker}.
* @param shortcut the {@link Button} providing the shortcut.
* @param map the {@link ObservableMap} providing the {@link Color}.
*/
private void addItemConfiguration( int row, Label label, ColorPicker picker, Button shortcut, ObservableMap< BuildResultStatus, Color > map ) {
add( label, 0, row );
styling.configureColorPicker( picker, map.get( status ) );
map.addListener(
new StatusFilterPropertyUpdater( map, status, picker.valueProperty() )
);
picker.valueProperty().addListener( ( s, o, n ) -> map.put( status, n ) );
add( picker, 1, row );
shortcut.setMaxWidth( Double.MAX_VALUE );
shortcut.setOnAction( e -> picker.setValue( shortcuts.shortcutColorProperty().get() ) );
add( shortcut, 2, row );
}
示例11: assertThatElementsAreProvided
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
private void assertThatElementsAreProvided(
Label label, String labelText,
ColorPicker picker,
Button button,
ObservableMap< BuildResultStatus, Color > map
){
assertThat( systemUnderTest.getChildren().contains( label ), is( true ) );
assertThat( label.getText(), is( labelText ) );
verify( styling ).createBoldLabel( labelText );
assertThat( systemUnderTest.getChildren().contains( picker ), is( true ) );
verify( styling ).configureColorPicker( picker, map.get( status ) );
assertThat( systemUnderTest.getChildren().contains( button ), is( true ) );
assertThat( button.getText(), is( StatusConfigurationPane.SHORTCUT_BUTTON_TEXT ) );
assertThat( button.getMaxWidth(), is( Double.MAX_VALUE ) );
}
示例12: initDraw
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
private void initDraw(GraphicsContext gc){
colorPicker = new ColorPicker();
double canvasWidth = gc.getCanvas().getWidth();
double canvasHeight = gc.getCanvas().getHeight();
gc.setFill(Color.LIGHTGRAY);
gc.setStroke(Color.BLACK);
gc.setLineWidth(5);
gc.fill();
gc.strokeRect(
0, //x of the upper left corner
0, //y of the upper left corner
canvasWidth, //width of the rectangle
canvasHeight); //height of the rectangle
gc.setFill(colorPicker.getValue());
gc.setStroke(colorPicker.getValue());
gc.setLineWidth(1);
}
示例13: updateColor
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
private void updateColor() {
final ColorPicker colorPicker = (ColorPicker) getSkinnable();
// update picker box color
Circle colorCircle = new Circle();
colorCircle.setFill(colorPicker.getValue());
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(colorPicker.getValue().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(colorPicker.getValue()));
} else {
displayNode.setText("");
}
}
示例14: ColorTableCell
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
public ColorTableCell(TableColumn<T, Color> column) {
colorPicker = new ColorPicker();
colorPicker.editableProperty().bind(column.editableProperty());
colorPicker.disableProperty().bind(column.editableProperty().not());
colorPicker.setOnShowing(event -> {
final TableView<T> tableView = getTableView();
tableView.getSelectionModel().select(getTableRow().getIndex());
tableView.edit(tableView.getSelectionModel().getSelectedIndex(), column);
});
colorPicker.valueProperty().addListener((observable, oldValue, newValue) -> {
if (isEditing()) {
commitEdit(newValue);
}
});
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
示例15: start
import javafx.scene.control.ColorPicker; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
this.stage = stage;
configureScene();
configureStage();
Button btn = new Button("Sai Pradeep");
btn.getStyleClass().add("my-btn");
btn.setPrefSize(90, 28);
final SimpleObjectProperty<ColorPalette> cp = new SimpleObjectProperty<>();
final ColorPicker p = new ColorPicker();
p.showingProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> paramObservableValue, Boolean paramT1, Boolean showing) {
if(showing && cp.get()==null){
// /color-palette
System.out.println("Showing the pop up.");
System.out.println(p.lookup(".color-palette"));
}
}
});
root.getChildren().add(p);
}