modules/controls/src/main/java/com/sun/javafx/scene/control/CustomColorDialog.java
Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization
@@ -21,12 +21,16 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package com.sun.javafx.scene.control.skin;
+package com.sun.javafx.scene.control;
+import com.sun.javafx.scene.control.IntegerField;
+import com.sun.javafx.scene.control.WebColorField;
+import com.sun.javafx.scene.control.skin.IntegerFieldSkin;
+import com.sun.javafx.scene.control.skin.WebColorFieldSkin;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.*;
import javafx.event.EventHandler;
import javafx.scene.Scene;
@@ -46,15 +50,12 @@
import javafx.geometry.Rectangle2D;
import javafx.scene.input.KeyEvent;
import javafx.stage.Screen;
import javafx.stage.WindowEvent;
-import static com.sun.javafx.scene.control.skin.ColorPickerSkin.getString;
-
/**
*
- * @author paru
*/
public class CustomColorDialog extends HBox {
private final Stage dialog = new Stage();
private ColorRectPane colorRectPane;
@@ -70,11 +71,11 @@
private Scene customScene;
public CustomColorDialog(Window owner) {
getStyleClass().add("custom-color-dialog");
if (owner != null) dialog.initOwner(owner);
- dialog.setTitle(getString("customColorDialogTitle"));
+ dialog.setTitle(Properties.getColorPickerString("customColorDialogTitle"));
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.initStyle(StageStyle.UTILITY);
dialog.setResizable(false);
colorRectPane = new ColorRectPane();
controlsPane = new ControlsPane();
@@ -106,23 +107,23 @@
public void setCurrentColor(Color currentColor) {
this.currentColorProperty.set(currentColor);
}
- Color getCurrentColor() {
+ public final Color getCurrentColor() {
return currentColorProperty.get();
}
- ObjectProperty<Color> customColorProperty() {
+ public final ObjectProperty<Color> customColorProperty() {
return customColorProperty;
}
- void setCustomColor(Color color) {
+ public final void setCustomColor(Color color) {
customColorProperty.set(color);
}
- Color getCustomColor() {
+ public final Color getCustomColor() {
return customColorProperty.get();
}
public Runnable getOnSave() {
return onSave;
@@ -150,11 +151,11 @@
public void setOnHidden(EventHandler<WindowEvent> onHidden) {
dialog.setOnHidden(onHidden);
}
- Stage getDialog() {
+ public Stage getDialog() {
return dialog;
}
public void show() {
if (dialog.getOwner() != null) {
@@ -522,21 +523,21 @@
@Override protected Background computeValue() {
return new Background(new BackgroundFill(customColorProperty.get(), CornerRadii.EMPTY, Insets.EMPTY));
}
});
- currentColorLabel = new Label(getString("currentColor"));
- newColorLabel = new Label(getString("newColor"));
+ currentColorLabel = new Label(Properties.getColorPickerString("currentColor"));
+ newColorLabel = new Label(Properties.getColorPickerString("newColor"));
whiteBox = new Region();
whiteBox.getStyleClass().add("customcolor-controls-background");
- hsbButton = new ToggleButton(getString("colorType.hsb"));
+ hsbButton = new ToggleButton(Properties.getColorPickerString("colorType.hsb"));
hsbButton.getStyleClass().add("left-pill");
- rgbButton = new ToggleButton(getString("colorType.rgb"));
+ rgbButton = new ToggleButton(Properties.getColorPickerString("colorType.rgb"));
rgbButton.getStyleClass().add("center-pill");
- webButton = new ToggleButton(getString("colorType.web"));
+ webButton = new ToggleButton(Properties.getColorPickerString("colorType.web"));
webButton.getStyleClass().add("right-pill");
final ToggleGroup group = new ToggleGroup();
hBox = new HBox();
hBox.setAlignment(Pos.CENTER);
@@ -630,11 +631,11 @@
settingsPane.add(sliders[i], 2, row);
settingsPane.add(fields[i], 3, row);
settingsPane.add(units[i], 4, row);
}
- set(3, getString("opacity_colon"), 100, colorRectPane.alpha);
+ set(3, Properties.getColorPickerString("opacity_colon"), 100, colorRectPane.alpha);
hsbButton.setToggleGroup(group);
rgbButton.setToggleGroup(group);
webButton.setToggleGroup(group);
group.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
@@ -653,28 +654,28 @@
group.selectToggle(hsbButton);
buttonBox = new HBox();
buttonBox.setId("buttons-hbox");
- Button saveButton = new Button(getString("Save"));
+ Button saveButton = new Button(Properties.getColorPickerString("Save"));
saveButton.setDefaultButton(true);
saveButton.setOnAction(t -> {
if (onSave != null) {
onSave.run();
}
dialog.hide();
});
- Button useButton = new Button(getString("Use"));
+ Button useButton = new Button(Properties.getColorPickerString("Use"));
useButton.setOnAction(t -> {
if (onUse != null) {
onUse.run();
}
dialog.hide();
});
- Button cancelButton = new Button(getString("Cancel"));
+ Button cancelButton = new Button(Properties.getColorPickerString("Cancel"));
cancelButton.setCancelButton(true);
cancelButton.setOnAction(e -> {
customColorProperty.set(getCurrentColor());
if (onCancel != null) {
onCancel.run();
@@ -685,23 +686,23 @@
getChildren().addAll(currentAndNewColor, settingsPane, buttonBox);
}
private void showHSBSettings() {
- set(0, getString("hue_colon"), 360, colorRectPane.hue);
- set(1, getString("saturation_colon"), 100, colorRectPane.sat);
- set(2, getString("brightness_colon"), 100, colorRectPane.bright);
+ set(0, Properties.getColorPickerString("hue_colon"), 360, colorRectPane.hue);
+ set(1, Properties.getColorPickerString("saturation_colon"), 100, colorRectPane.sat);
+ set(2, Properties.getColorPickerString("brightness_colon"), 100, colorRectPane.bright);
}
private void showRGBSettings() {
- set(0, getString("red_colon"), 255, colorRectPane.red);
- set(1, getString("green_colon"), 255, colorRectPane.green);
- set(2, getString("blue_colon"), 255, colorRectPane.blue);
+ set(0, Properties.getColorPickerString("red_colon"), 255, colorRectPane.red);
+ set(1, Properties.getColorPickerString("green_colon"), 255, colorRectPane.green);
+ set(2, Properties.getColorPickerString("blue_colon"), 255, colorRectPane.blue);
}
private void showWebSettings() {
- labels[0].setText(getString("web_colon"));
+ labels[0].setText(Properties.getColorPickerString("web_colon"));
}
private Property<Number>[] bindedProperties = new Property[4];
private void set(int row, String caption, int maxValue, Property<Number> prop) {