functional/ControlsTests/src/javafx/scene/control/test/colorpicker/ColorPickerApp.java

Print this page




 117 
 118             tb.addSimpleListener(testedColorPicker.focusedProperty(), testedColorPicker);
 119             tb.addSimpleListener(testedColorPicker.pressedProperty(), testedColorPicker);
 120             tb.addSimpleListener(testedColorPicker.showingProperty(), testedColorPicker);
 121             tb.addSimpleListener(testedColorPicker.sceneProperty(), testedColorPicker);
 122 
 123             tb.addStringLine(testedColorPicker.promptTextProperty(), "prompt");
 124 
 125             pane.setMinSize(240, 240);
 126             pane.setPrefSize(240, 240);
 127             pane.setStyle("-fx-border-color : red;");
 128             pane.getChildren().add(testedColorPicker);
 129 
 130             VBox vb = new VBox();
 131             vb.setSpacing(5);
 132 
 133             HBox hb = (HBox) getRoot();
 134             hb.setPadding(new Insets(5, 5, 5, 5));
 135             hb.setStyle("-fx-border-color : green;");
 136 
 137             Button hardResetButton = ButtonBuilder.create().id(HARD_RESET_BUTTON_ID).text("Hard reset").build();

 138             hardResetButton.setOnAction(new EventHandler<ActionEvent>() {
 139                 public void handle(ActionEvent t) {
 140                     HBox hb = (HBox) getRoot();
 141                     hb.getChildren().clear();
 142                     prepareMainSceneStructure();
 143                     prepareScene();
 144                 }
 145             });
 146 
 147             Button softResetButton = ButtonBuilder.create().id(SOFT_RESET_BUTTON_ID).text("Soft reset").build();

 148             softResetButton.setOnAction(new EventHandler<ActionEvent>() {
 149                 public void handle(ActionEvent t) {
 150                     tb.refresh();
 151                     ColorPicker newOne = new ColorPicker();
 152                     testedColorPicker.setValue(newOne.getValue());
 153                 }
 154             });
 155 
 156             HBox resetButtonsHBox = new HBox();
 157             resetButtonsHBox.getChildren().addAll(hardResetButton, softResetButton);
 158             resetButtonsHBox.setAlignment(Pos.CENTER);
 159 
 160             VBox vb1 = new VBox(5);
 161             vb1.getChildren().addAll(resetButtonsHBox, setColorHbox());
 162 
 163             setTestedControl(testedColorPicker);
 164             setControllersContent(vb1);
 165             setPropertiesContent(tb);
 166         }
 167 
 168         private HBox setColorHbox() {
 169             HBox hb = new HBox();
 170             Label lb = new Label("Set color");
 171             final TextField colorTf = TextFieldBuilder.create().prefWidth(100).id(SET_COLOR_TEXT_FIELD_ID).build();
 172             Button bt = ButtonBuilder.create().text("Set!").id(SET_COLOR_BUTTON_ID).build();



 173             bt.setOnAction(new EventHandler() {
 174                 public void handle(Event t) {
 175                     testedColorPicker.setValue(Color.web(colorTf.getText()));
 176                 }
 177             });
 178             hb.getChildren().addAll(lb, colorTf, bt);
 179             hb.setAlignment(Pos.CENTER);
 180             return hb;
 181         }
 182     }
 183 }


 117 
 118             tb.addSimpleListener(testedColorPicker.focusedProperty(), testedColorPicker);
 119             tb.addSimpleListener(testedColorPicker.pressedProperty(), testedColorPicker);
 120             tb.addSimpleListener(testedColorPicker.showingProperty(), testedColorPicker);
 121             tb.addSimpleListener(testedColorPicker.sceneProperty(), testedColorPicker);
 122 
 123             tb.addStringLine(testedColorPicker.promptTextProperty(), "prompt");
 124 
 125             pane.setMinSize(240, 240);
 126             pane.setPrefSize(240, 240);
 127             pane.setStyle("-fx-border-color : red;");
 128             pane.getChildren().add(testedColorPicker);
 129 
 130             VBox vb = new VBox();
 131             vb.setSpacing(5);
 132 
 133             HBox hb = (HBox) getRoot();
 134             hb.setPadding(new Insets(5, 5, 5, 5));
 135             hb.setStyle("-fx-border-color : green;");
 136 
 137             Button hardResetButton = new Button("Hard reset");

 138             hardResetButton.setId(HARD_RESET_BUTTON_ID);

 139             hardResetButton.setOnAction(new EventHandler<ActionEvent>() {
 140                 public void handle(ActionEvent t) {
 141                     HBox hb = (HBox) getRoot();
 142                     hb.getChildren().clear();
 143                     prepareMainSceneStructure();
 144                     prepareScene();
 145                 }
 146             });
 147 
 148             Button softResetButton = new Button("Soft reset");

 149             softResetButton.setId(SOFT_RESET_BUTTON_ID);

 150             softResetButton.setOnAction(new EventHandler<ActionEvent>() {
 151                 public void handle(ActionEvent t) {
 152                     tb.refresh();
 153                     ColorPicker newOne = new ColorPicker();
 154                     testedColorPicker.setValue(newOne.getValue());
 155                 }
 156             });
 157 
 158             HBox resetButtonsHBox = new HBox();
 159             resetButtonsHBox.getChildren().addAll(hardResetButton, softResetButton);
 160             resetButtonsHBox.setAlignment(Pos.CENTER);
 161 
 162             VBox vb1 = new VBox(5);
 163             vb1.getChildren().addAll(resetButtonsHBox, setColorHbox());
 164 
 165             setTestedControl(testedColorPicker);
 166             setControllersContent(vb1);
 167             setPropertiesContent(tb);
 168         }
 169 
 170         private HBox setColorHbox() {
 171             HBox hb = new HBox();
 172             Label lb = new Label("Set color");
 173             final TextField colorTf = new TextField();

 174             colorTf.setPrefWidth(100);

 175             colorTf.setId(SET_COLOR_TEXT_FIELD_ID);

 176             Button bt = new Button("Set!");

 177             bt.setId(SET_COLOR_BUTTON_ID);

 178             bt.setOnAction(new EventHandler() {
 179                 public void handle(Event t) {
 180                     testedColorPicker.setValue(Color.web(colorTf.getText()));
 181                 }
 182             });
 183             hb.getChildren().addAll(lb, colorTf, bt);
 184             hb.setAlignment(Pos.CENTER);
 185             return hb;
 186         }
 187     }
 188 }