Java Code Examples for javafx.scene.control.TextField

The following are top voted examples for showing how to use javafx.scene.control.TextField. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: marathonv5   File: SearchBoxSample.java   Source Code and License 10 votes vote down vote up
public SearchBox() {
    setId("SearchBox");
    getStyleClass().add("search-box");
    setMinHeight(24);
    setPrefSize(200, 24);
    setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
    textBox = new TextField();
    textBox.setPromptText("Search");
    clearButton = new Button();
    clearButton.setVisible(false);
    getChildren().addAll(textBox, clearButton);
    clearButton.setOnAction(new EventHandler<ActionEvent>() {                
        @Override public void handle(ActionEvent actionEvent) {
            textBox.setText("");
            textBox.requestFocus();
        }
    });
    textBox.textProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            clearButton.setVisible(textBox.getText().length() != 0);
        }
    });
}
 
Example 2
Project: CSS-Editor-FX   File: OptionsController.java   Source Code and License 7 votes vote down vote up
private void createField() {
  field = new TextField(getString());
  field.setEditable(false);
  field.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
    if (e.getCode() == KeyCode.ENTER) {
      try {
        commitEdit(KeyCombination.valueOf(field.getText()));
      } catch (Exception ee) {
        cancelEdit();
      }
    } else if (e.getCode() == KeyCode.ESCAPE) {
      cancelEdit();
    } else {
      field.setText(convert(e).toString());
    }
    e.consume();
  });
}
 
Example 3
Project: CDN-FX-2.2   File: TDATableFilter.java   Source Code and License 7 votes vote down vote up
public static SortedList<Ticket> createTableFilter(TextField textSearch, ListView listView){

        if(isPrepared)
            return new SortedList<>(filteredTickets);

        textSearch.setOnKeyPressed((KeyEvent ke) ->{
            if(ke.getCode().equals(KeyCode.ENTER)){
                text = textSearch.getText().toLowerCase();
                filterTickets();
            }
        });

        //Listview
        listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
                categoryText = newValue.split(" ")[0];
                if(categoryText.equals("DownloadPlayChild"))
                    categoryText = "DLP";
                filterTickets();
            }
        });

        isPrepared = true;
        return new SortedList<>(filteredTickets);
    }
 
Example 4
Project: SensorThingsManager   File: EntityGuiController.java   Source Code and License 7 votes vote down vote up
@Override
public void init(SensorThingsService service, Observation entity, GridPane gridProperties, Accordion accordionLinks, Label labelId, boolean editable) {
    this.labelId = labelId;
    this.entity = entity;
    int i = 0;
    textPhenomenonTime = addFieldTo(gridProperties, i, "PhenomenonTime", new TextField(), false, editable);
    textResultTime = addFieldTo(gridProperties, ++i, "ResultTime", new TextField(), false, editable);
    textResult = addFieldTo(gridProperties, ++i, "Result", new TextArea(), true, editable);
    textResultQuality = addFieldTo(gridProperties, ++i, "ResultQuality", new TextField(), false, editable);
    textValidTime = addFieldTo(gridProperties, ++i, "ValidTime", new TextField(), false, editable);
    textParameters = addFieldTo(gridProperties, ++i, "Parameters", new TextArea(), true, editable);

    if (accordionLinks != null) {
        try {
            accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getDatastream(), service.datastreams().query(), entity::setDatastream));
            accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getMultiDatastream(), service.multiDatastreams().query(), entity::setMultiDatastream));
            accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getFeatureOfInterest(), service.featuresOfInterest().query(), entity::setFeatureOfInterest));
        } catch (IOException | ServiceFailureException ex) {
            LOGGER.error("Failed to create panel.", ex);
        }
    }
}
 
Example 5
Project: WholesomeChat   File: MainController.java   Source Code and License 7 votes vote down vote up
public void initialize(URL location, ResourceBundle resources) {
	gson = new Gson();
	timer = new ReschedulableTimer();
	runnable = new Runnable() {
   		public void run() {
   			Scene scene = stage.getScene();
   			TextField inputTextField = (TextField) scene.lookup("#textfield");
   	    	if (inputTextField.getText().trim().length() != 0) {
    	        JsonObject str = new JsonObject();
    	        str.addProperty("text", inputTextField.getText().trim());
    	        str.addProperty("intent", "precheck");
    	        chatAccess.send(gson.toJson(str));
   	    	}
   		}
	};
}
 
Example 6
Project: incubator-netbeans   File: WebViewBrowser.java   Source Code and License 7 votes vote down vote up
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
Example 7
Project: Conan   File: RulePane.java   Source Code and License 7 votes vote down vote up
public RulePane() {
    ArrayList<TextField> rulePrompts = new ArrayList<TextField>(3);
    this.setMaxWidth(340);
    TextField rule = new TextField();
    rule.getStyleClass().add("myText");
    rule.setPromptText("Rule");
    rule.setId("rightTextField");
    rule.setMaxWidth(100);
    for (int i = 0; i < 3; i++) {
        TextField temp = new TextField();
        temp.setVisible(false);
        temp.getStyleClass().add("myText");
        temp.setMaxWidth(80);
        rulePrompts.add(temp);
    }
    this.getChildren().addAll(rule, rulePrompts.get(0), rulePrompts.get(1), rulePrompts.get(2));
}
 
Example 8
Project: SystemMonitorJFX   File: MainStage.java   Source Code and License 7 votes vote down vote up
private void initTableContextMenu() {
      TextField textField = new TextField("Type Something"); // we will add a popup menu to this text field
      contextMenu = new ContextMenu();

      MenuItem pauseP = new MenuItem("Stop process");
pauseP.setId("pausep");
		
MenuItem continueP = new MenuItem("Continue process");
continueP.setId("continuep");
		
MenuItem killP = new MenuItem("Kill process");
killP.setId("killp");
      
pauseP.setOnAction(actionEventHandler);
continueP.setOnAction(actionEventHandler);
killP.setOnAction(actionEventHandler);


      contextMenu.getItems().addAll(pauseP, continueP, new SeparatorMenuItem(), killP);
      // ...
      textField.setContextMenu(contextMenu);
  }
 
Example 9
Project: GameAuthoringEnvironment   File: TestFacebook.java   Source Code and License 7 votes vote down vote up
private Node makeMyHighScorePost () {
    HBox box = new HBox(5);
    TextField field = new TextField("Game name");
    ComboBox<ScoreOrder> combo = new ComboBox<>();
    for (ScoreOrder s : ScoreOrder.values()) {
        combo.getItems().add(s);
    }
    box.getChildren().addAll(field, combo);
    Button button = new Button("Post about my scores");
    button.setOnMouseClicked(e -> {
        myUser = mySocial.getActiveUser();
        myUser.getProfiles().getActiveProfile().highScorePost(mySocial.getHighScoreBoard(),
                                                              field.getText(),
                                                              myUser,
                                                              combo.getValue());
    });
    box.getChildren().add(button);
    return box;
}
 
Example 10
Project: marathonv5   File: SearchBoxSample.java   Source Code and License 7 votes vote down vote up
public SearchBox() {
    setId("SearchBox");
    getStyleClass().add("search-box");
    setMinHeight(24);
    setPrefSize(200, 24);
    setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
    textBox = new TextField();
    textBox.setPromptText("Search");
    clearButton = new Button();
    clearButton.setVisible(false);
    getChildren().addAll(textBox, clearButton);
    clearButton.setOnAction(new EventHandler<ActionEvent>() {                
        @Override public void handle(ActionEvent actionEvent) {
            textBox.setText("");
            textBox.requestFocus();
        }
    });
    textBox.textProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            clearButton.setVisible(textBox.getText().length() != 0);
        }
    });
}
 
Example 11
Project: FlashLib   File: MainWindow.java   Source Code and License 7 votes vote down vote up
public VisionControl() {
	slider = new Slider();
	slider.setMin(0.0);
	slider.setMax(255.0);
	slider.setValue(0.0);
	slider.setMaxWidth(350.0);
	slider.setDisable(true);
	
	inputText = new TextField();
	inputText.setText("0");
	inputText.setMaxWidth(50.0);
	inputText.setOnKeyPressed((e)->{
		if(e.getCode() == KeyCode.ENTER){
			setTextFromField();
		}
	});
	inputText.focusedProperty().addListener((obs, o, n)->{
		if(!n.booleanValue()){
			inputText.setText(String.valueOf((int)slider.getValue()));
		}
	});
	
	slider.valueProperty().addListener((obs, o, n)->{
		inputText.setText(String.valueOf((int)slider.getValue()));
	});
	
	nameLabel = new Label("");
	
	HBox top = new HBox();
	top.setSpacing(5.0);
	top.getChildren().addAll(nameLabel, inputText);
	
	VBox all = new VBox();
	all.setSpacing(10.0);
	all.getChildren().addAll(top, slider);
	root = all;
}
 
Example 12
Project: ExtremeGuiMakeover   File: MovieViewSkin.java   Source Code and License 6 votes vote down vote up
private void addToolBar() {
    TextField textField = new TextField();
    textField.getStyleClass().add("search-field");
    textField.textProperty().bindBidirectional(getSkinnable().filterTextProperty());

    Text clearIcon = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.TIMES_CIRCLE, "18");
    CustomTextField customTextField = new CustomTextField();
    customTextField.getStyleClass().add("search-field");
    customTextField.setLeft(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.SEARCH, "18px"));
    customTextField.setRight(clearIcon);
    customTextField.textProperty().bindBidirectional(getSkinnable().filterTextProperty());
    clearIcon.setOnMouseClicked(evt -> customTextField.setText(""));

    FlipPanel searchFlipPanel = new FlipPanel();
    searchFlipPanel.setFlipDirection(Orientation.HORIZONTAL);
    searchFlipPanel.getFront().getChildren().add(textField);
    searchFlipPanel.getBack().getChildren().add(customTextField);
    searchFlipPanel.visibleProperty().bind(getSkinnable().enableSortingAndFilteringProperty());

    getSkinnable().useControlsFXProperty().addListener(it -> {
        if (getSkinnable().isUseControlsFX()) {
            searchFlipPanel.flipToBack();
        } else {
            searchFlipPanel.flipToFront();
        }
    });

    showTrailerButton = new Button("Show Trailer");
    showTrailerButton.getStyleClass().add("trailer-button");
    showTrailerButton.setMaxHeight(Double.MAX_VALUE);
    showTrailerButton.setOnAction(evt -> showTrailer());

    BorderPane toolBar = new BorderPane();
    toolBar.setLeft(showTrailerButton);
    toolBar.setRight(searchFlipPanel);
    toolBar.getStyleClass().add("movie-toolbar");

    container.add(toolBar, 1, 0);
}
 
Example 13
Project: Elementary-Number-Theory   File: HelpingClass.java   Source Code and License 6 votes vote down vote up
public static long[] input2ArrayOfLongs(TextField tf) throws NumberFormatException {

        String[] inputs = tf.getText().trim().split("[, ]+");
        long[] result = new long[inputs.length];
        try {
            for (int i = 0; i < inputs.length; i++) {
                result[i] = strPow(inputs[i]);
            }
        } catch (NumberFormatException ex) {
            throw new NumberFormatException("Invaild Number (" + tf.getText() + ")");
        }
        return result;
    }
 
Example 14
Project: Socket_Chat   File: ClientGUI.java   Source Code and License 6 votes vote down vote up
private GridPane initGridPane() {

        GridPane gridPane = new GridPane();
        //
        TextField faddress = new TextField();
        faddress.setPromptText("Enter server adders");
        faddress.setOnAction(s -> client.makeConnection(faddress.getText()));
        //text field init
        TextField textField = new TextField();

        textField.setPromptText("Enter command");
        textField.setOnAction(s -> {
            process(textField.getText());
            textField.setText("");
        });

        //btn
        Button button = new Button("Connect");
        button.setOnAction(s -> client.makeConnection(faddress.getText()));
        gridPane.add(button, 0, 0);
        gridPane.add(faddress, 1, 0, 1, 1);
        gridPane.add(clientConsole.view, 0, 1, 2, 1);
        gridPane.add(textField, 0, 2, 2, 1);

        gridPane.setAlignment(Pos.CENTER);


        //grid settings
        gridPane.setHgap(10);
        gridPane.setVgap(10);


        return gridPane;
    }
 
Example 15
Project: marathonv5   File: RFXTextFieldTest.java   Source Code and License 6 votes vote down vote up
@Test public void getText() {
    final TextField textField = (TextField) getPrimaryStage().getScene().getRoot().lookup(".text-field");
    LoggingRecorder lr = new LoggingRecorder();
    List<Object> text = new ArrayList<>();
    Platform.runLater(() -> {
        RFXComponent rTextField = new RFXTextInputControl(textField, null, null, lr);
        textField.setText("Hello World");
        rTextField.focusLost(null);
        text.add(rTextField.getAttribute("text"));
    });
    new Wait("Waiting for text field text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Hello World", text.get(0));
}
 
Example 16
Project: fxexperience2   File: GradientSlider.java   Source Code and License 6 votes vote down vote up
private void incOrDecFieldValue(KeyEvent e, double x) {

        if (!(e.getSource() instanceof TextField)) {
            return; // check it's a textField
        }        // increment or decrement the value
        final TextField tf = (TextField) e.getSource();
        final Double newValue = Double.valueOf(tf.getText()) + x;
        double rounded = round(newValue, roundingFactor);
        slider_slider.setValue(rounded);
        tf.setText(Double.toString(newValue));
        // Avoid using runLater
        // This should be done somewhere else (need to investigate)
//        Platform.runLater(new Runnable() {
//            @Override
//            public void run() {
//                // position caret after new value for easy editing
//                tf.positionCaret(tf.getText().length());
//            }
//        });
    }
 
Example 17
Project: MasterHash   File: NewLogin.java   Source Code and License 6 votes vote down vote up
public static void display() {
	window = new Stage();
	window.initModality(Modality.APPLICATION_MODAL);
	window.setTitle("Log In");
	HEADING = "New Login";

	Label headingLabel = new Label(HEADING);
	headingLabel.setFont(Font.font("Verdana", FontWeight.BOLD, 30));

	TextField nameTextField = new TextField();
	nameTextField.setPromptText("Name");

	TextField userNameTextField = new TextField();
	userNameTextField.setPromptText("Username");

	PasswordField passwordField = new PasswordField();
	passwordField.setPromptText("Password");
	Button generateButton = new Button("Generate");

	HBox generatePasswordArea = new HBox();
	generatePasswordArea.getChildren().addAll(passwordField, generateButton);

	Button submitButton = new Button("Submit");

	VBox layout = new VBox(10);
	layout.setPadding(new Insets(0, 20, 0, 20));
	layout.setAlignment(Pos.CENTER_LEFT);
	layout.getChildren().addAll(headingLabel, nameTextField, userNameTextField, generatePasswordArea, submitButton);

	Scene scene = new Scene(layout, 300, 400);
	window.setScene(scene);
	window.showAndWait();
}
 
Example 18
Project: marathonv5   File: MarathonModuleStage.java   Source Code and License 6 votes vote down vote up
private void initComponents() {
    moduleNameField.setPrefColumnCount(20);
    moduleNameField.textProperty().addListener((observable, oldValue, newValue) -> validateModuleName());

    descriptionArea.setPrefColumnCount(20);
    descriptionArea.setPrefRowCount(4);

    if (moduleInfo.isNeedModuleFile()) {
        moduleDirComboBox.setItems(FXCollections.observableArrayList(moduleInfo.getModuleDirElements()));
        moduleDirComboBox.getSelectionModel().selectedItemProperty().addListener((e) -> {
            moduleInfo.populateFiles(moduleDirComboBox.getSelectionModel().getSelectedItem());
        });

        if (moduleDirComboBox.getItems().size() > 0) {
            moduleDirComboBox.getSelectionModel().select(0);
        }
        moduleFileComboBox.setItems(moduleInfo.getModuleFileElements());
        moduleFileComboBox.setEditable(true);
        TextField editor = moduleFileComboBox.getEditor();
        editor.textProperty().addListener((observable, oldValue, newValue) -> validateModuleName());
    }

    errorMessageLabel.setGraphic(FXUIUtils.getIcon("error"));
    errorMessageLabel.setVisible(false);

    buttonBar.setId("ModuleButtonBar");
    okButton.setOnAction((e) -> onOK());
    okButton.setDisable(true);
    cancelButton.setOnAction((e) -> onCancel());
    buttonBar.getButtons().addAll(okButton, cancelButton);
}
 
Example 19
Project: shuffleboard   File: EditableLabel.java   Source Code and License 6 votes vote down vote up
/**
 * A text label that you can double click to edit.
 */
public EditableLabel() {
  setMaxWidth(USE_PREF_SIZE);

  Label label = new Label();
  label.textProperty().bind(text);
  label.visibleProperty().bind(Bindings.not(editing));
  getChildren().add(label);

  TextField editField = new AutoSizedTextField();
  editField.visibleProperty().bind(editing);
  editField.textProperty().bindBidirectional(text);
  getChildren().add(editField);

  setOnMouseClicked(mouseEvent -> {
    if (mouseEvent.getClickCount() == 2) {
      editing.set(true);
    }
  });

  editField.setOnAction(__ae -> editing.set(false));

  editField.focusedProperty().addListener((__, wasFocused, isFocused) -> {
    if (!isFocused) {
      editing.set(false);
    }
  });

  editing.addListener((__, wasEditing, isEditing) -> {
    if (isEditing) {
      editField.requestFocus();
    }
  });
}
 
Example 20
Project: Balda   File: SceneFormController.java   Source Code and License 6 votes vote down vote up
/**
 * Добавляем текстовые поля для ввода
 */
private void addLetterTextFields() {
    for (int row = 0; row < rows; row++) {
        for (int col = 0; col < cols; col++) {
            if (game[row][col] == ' ' && ((row > 0 && game[row - 1][col] != ' ')
                    || (col > 0 && game[row][col - 1] != ' ')
                    || (row < rows - 1 && game[row + 1][col] != ' ')
                    || (col < cols - 1 && game[row][col + 1] != ' '))) {
                if (gameCells[row][col] == null) {
                    TextField tf = new TextField();
                    tf.setFont(textPrototype.getFont());
                    gameField.add(tf, col, row);
                    gameCells[row][col] = tf;
                } else {
                    // Очищаем если уже есть
                    gameCells[row][col].setText("");
                }
            }
        }
    }
}
 
Example 21
Project: FX-Test   File: BaseTestFXComponentTest.java   Source Code and License 6 votes vote down vote up
public LoginComponent(BorderPane p) {
	GridPane g = new GridPane();

	{
		g.add(new Label("Username"), 0, 0);
		username = new TextField();
		g.add(username, 1, 0);
	}

	{
		g.add(new Label("Password"), 0, 1);
		password = new PasswordField();
		g.add(password, 1, 1);
	}

	Button button = new Button("Login");
	button.setOnAction(e -> {
		if( username.getText().equals("[email protected]") ) {
			if( password.getText().equals("test") ) {
				status = Status.ok();
			} else {
				status = Status.status(Status.State.ERROR, 2, "Invalid password for '"+username.getText()+"'", null);
			}
		} else {
			status = Status.status(Status.State.ERROR, 1, "Unknown username", null);
		}
	});
	g.add(button, 1, 2);
	g.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
	g.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
	p.setCenter(g);
}
 
Example 22
Project: marathonv5   File: JavaFXSpinnerElement.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked") @Override public boolean marathon_select(String value) {
    Spinner<?> spinner = (Spinner<?>) getComponent();
    if (!spinner.isEditable()) {
        @SuppressWarnings("rawtypes")
        SpinnerValueFactory factory = ((Spinner<?>) getComponent()).getValueFactory();
        Object convertedValue = factory.getConverter().fromString(value);
        factory.setValue(convertedValue);
        return true;
    }
    TextField spinnerEditor = spinner.getEditor();
    if (spinnerEditor == null) {
        throw new JavaAgentException("Null value returned by getEditor() on spinner", null);
    }
    IJavaFXElement ele = JavaFXElementFactory.createElement(spinnerEditor, driver, window);
    spinnerEditor.getProperties().put("marathon.celleditor", true);
    ele.marathon_select(value);
    return true;
}
 
Example 23
Project: stvs   File: WizardUneditableStringPage.java   Source Code and License 6 votes vote down vote up
public WizardUneditableStringPage(String title, String description,
    StringProperty uneditableText) {
  super(title);
  TextField uneditableTextField = new TextField();
  uneditableTextField.textProperty().bind(uneditableText);
  Label descriptionLabel = new Label(description);
  descriptionLabel.setWrapText(true);
  descriptionLabel.setTextAlignment(TextAlignment.JUSTIFY);
  this.getChildren().addAll(descriptionLabel, uneditableTextField);
  uneditableTextField.setDisable(true);
}
 
Example 24
Project: jmonkeybuilder   File: SaveAsEditorDialog.java   Source Code and License 6 votes vote down vote up
/**
 * Handle the new selected item.
 *
 * @param newValue the new selected item.
 */
@FXThread
protected void processSelection(@Nullable final TreeItem<ResourceElement> newValue) {

    if (newValue != null) {

        final TextField fileNameField = getFileNameField();

        final ResourceElement value = newValue.getValue();
        final Path file = value.getFile();

        if (!Files.isDirectory(file)) {
            fileNameField.setText(FileUtils.getNameWithoutExtension(file));
        }
    }

    validateFileName();
}
 
Example 25
Project: jmonkeybuilder   File: StringPropertyControl.java   Source Code and License 5 votes vote down vote up
/**
 * Update the value.
 */
@FXThread
private void updateValue(@NotNull final KeyEvent event) {
    if (isIgnoreListener() || event.getCode() != KeyCode.ENTER) return;

    final TextField valueField = getValueField();

    final String oldValue = getPropertyValue();
    final String newValue = valueField.getText();

    changed(newValue, oldValue);
}
 
Example 26
Project: jmonkeybuilder   File: SettingsDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create the classes folder control.
 */
@FXThread
private void createClassesFolderControl(@NotNull final VBox root) {

    final HBox container = new HBox();
    container.setAlignment(Pos.CENTER_LEFT);

    final Label label = new Label(Messages.SETTINGS_DIALOG_USER_CLASSES_FOLDER_LABEL + ":");
    final HBox fieldContainer = new HBox();

    classesFolderField = new TextField();
    classesFolderField.setEditable(false);
    classesFolderField.prefWidthProperty().bind(root.widthProperty());

    final Button addButton = new Button();
    addButton.setGraphic(new ImageView(Icons.ADD_12));
    addButton.setOnAction(event -> processAddClassesFolder());

    final Button removeButton = new Button();
    removeButton.setGraphic(new ImageView(Icons.REMOVE_12));
    removeButton.setOnAction(event -> processRemoveClassesFolder());
    removeButton.disableProperty().bind(classesFolderField.textProperty().isEmpty());

    FXUtils.addToPane(label, fieldContainer, container);
    FXUtils.addToPane(classesFolderField, addButton, removeButton, fieldContainer);
    FXUtils.addToPane(container, root);

    FXUtils.addClassTo(classesFolderField, CSSClasses.TRANSPARENT_TEXT_FIELD);
    FXUtils.addClassTo(fieldContainer, CSSClasses.TEXT_INPUT_CONTAINER);
    FXUtils.addClassTo(label, CSSClasses.SETTINGS_DIALOG_LABEL);
    FXUtils.addClassTo(classesFolderField, fieldContainer, CSSClasses.SETTINGS_DIALOG_FIELD);
    FXUtils.addClassesTo(addButton, removeButton, CSSClasses.FLAT_BUTTON,
            CSSClasses.INPUT_CONTROL_TOOLBAR_BUTTON);

    DynamicIconSupport.addSupport(addButton, removeButton);
}
 
Example 27
Project: jmonkeybuilder   File: FloatArrayPropertyControl.java   Source Code and License 5 votes vote down vote up
@Override
@FXThread
protected void createComponents(@NotNull final HBox container) {
    super.createComponents(container);

    valueField = new TextField();
    valueField.setOnKeyReleased(this::updateValue);
    valueField.prefWidthProperty()
            .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));

    FXUtils.addClassTo(valueField, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX);
    FXUtils.addToPane(valueField, container);
}
 
Example 28
Project: Lernkartei_2017   File: UserListView.java   Source Code and License 5 votes vote down vote up
@Override
public Parent constructContainer()
{
	
	bp.setId("loginviewbg");
	
	list = new ListView<String>();
	items = FXCollections.observableArrayList("Philippe Kr�ttli","Irina Deck","Javier Martinez Alvarez","Frithjof Hoppe");
	list.setItems(items);		
	
	AllFields = new VBox(50);
	AllFields.setAlignment(Pos.CENTER);
	AllFields.setMaxWidth(300);
	AllFields.setPadding(new Insets(20));
	
	SearchUser = new HBox();
	Bottom = new HBox();
	
	txtUserName = new TextField();
	txtUserName.setMinHeight(50);
	txtUserName.setMinWidth(700);
	txtUserName.setPromptText("Email-Adresse des Benutzers");
	
	btnSearch = new AppButton("Suchen");
	btnAdd = new AppButton("Hinzuf�gen");
	back = new BackButton(getFXController(),"Zur�ck");
	
	SearchUser.getChildren().addAll(txtUserName,btnSearch);
	Bottom.getChildren().addAll(back,btnAdd);
	AllFields.getChildren().addAll(SearchUser,list,Bottom);
	
	bp.setLeft(AllFields);
	
	//btnSearch.setOnAction(e -> getFXController().showView("userlist"));
	
	
	return bp;
}
 
Example 29
Project: drd   File: FormUtils.java   Source Code and License 5 votes vote down vote up
public static void initTextFormater(TextField textField, MaxActValue maxActValue) {
    textField.setTextFormatter(new TextFormatter<>(new NumberStringConverter()));
    textField.setTextFormatter(new TextFormatter<>(new NumberStringConverter(), null,
        FormUtils.integerFilter(
            maxActValue.getMinValue().intValue(),
            maxActValue.getMaxValue().intValue()
    )));
    textField.textProperty().bindBidirectional(maxActValue.actValueProperty(), new NumberStringConverter());
}
 
Example 30
Project: vars-annotation   File: AutoCompleteComboBoxListener.java   Source Code and License 5 votes vote down vote up
@Override
public void handle(KeyEvent event) {

    TextField editor = comboBox.getEditor();
    String text = editor.getText();

    if (event.getCode() == KeyCode.RIGHT
            || event.getCode() == KeyCode.LEFT
            || event.isControlDown()
            || event.getCode() == KeyCode.HOME
            || event.getCode() == KeyCode.END
            || event.getCode() == KeyCode.TAB) {
        return;
    }
    else if(event.getCode() == KeyCode.UP) {
        caretPos = -1;
        moveCaret(text.length());
        return;
    }
    else if(event.getCode() == KeyCode.DOWN) {
        if(!comboBox.isShowing()) {
            comboBox.show();
        }
        caretPos = -1;
        moveCaret(text.length());
        return;
    }
    else if(event.getCode() == KeyCode.BACK_SPACE) {
        moveCaretToPos = true;
        caretPos = editor.getCaretPosition();
    }
    else if(event.getCode() == KeyCode.DELETE) {
        moveCaretToPos = true;
        caretPos = editor.getCaretPosition();
    }

    String upperCaseText = text.toUpperCase();
    ObservableList<T> list = FXCollections.observableArrayList(data.stream()
            .filter(s -> transform.apply(s).toUpperCase().startsWith(upperCaseText))
            .collect(Collectors.toList()));

    comboBox.setItems(list);

    if (event.getCode() == KeyCode.ENTER
            || event.getCode() == KeyCode.ESCAPE) {
        if (!list.isEmpty()) {
            comboBox.getEditor().setText(transform.apply(list.get(0)));
            comboBox.getSelectionModel().select(0);
            comboBox.hide();
        }
        else {
            comboBox.getEditor().setText(text);
        }

    }
    else {
        comboBox.getEditor().setText(text);
        if(!moveCaretToPos) {
            caretPos = -1;
        }
        moveCaret(text.length());
        if(!list.isEmpty()) {
            comboBox.show();
        }
    }

}
 
Example 31
Project: fx-animation-editor   File: ColorPickerComponent.java   Source Code and License 5 votes vote down vote up
private void addWithLabelOverlaid(String labelText, TextField textField) {
    Label label = new Label(labelText);
    label.setMouseTransparent(true);
    StackPane.setAlignment(label, Pos.CENTER_LEFT);
    StackPane container = new StackPane(textField, label);
    rgbBox.getChildren().add(container);
}
 
Example 32
Project: phone-simulator   File: Impl.java   Source Code and License 5 votes vote down vote up
void showData(ComboBox<EnumeratedBase> cboChanel, ComboBox<String> cboRole, TextField txtLocalHost, TextField txtLocalPort, TextField txtRemoteHost, TextField txtRemotePort, TextField txtPhone) {
    addCboChanel(cboChanel);
    cboRole.getItems().addAll("Client", "Server");
    setCboRole(cboRole);
    txtLocalHost.setText(m3ua.getSctpLocalHost());
    txtLocalPort.setText(m3ua.getSctpLocalPort() + "");
    txtRemoteHost.setText(m3ua.getSctpRemoteHost());
    txtRemotePort.setText(m3ua.getSctpRemotePort() + "");
    txtPhone.setText(host.getMapMan().getOrigReference());
}
 
Example 33
Project: stvs   File: IoVariableDefinitionPane.java   Source Code and License 5 votes vote down vote up
/**
 * Creates an instance with given default values to display.
 * @param initialCategory Default category
 * @param initialName Default name
 * @param initialType Default type
 */
public IoVariableDefinitionPane(VariableCategory initialCategory, VariableRole initialRole, String initialName,
    String initialType) {
  super();

  setVgap(10);
  setHgap(10);

  this.categoryComboBox = new ComboBox<>(
      FXCollections.observableArrayList(VariableCategory.values()));
  this.variableRoleComboBox = new ComboBox<>(
      FXCollections.observableArrayList(VariableRole.values()));
  this.nameTextField = new TextField(initialName);
  this.typeTextField = new TextField(initialType);

  categoryComboBox.valueProperty().set(initialCategory);

  add(new Label("category: "), 0, 0);
  add(new Label("verification-role: "), 0, 1);
  add(new Label("name: "), 0, 2);
  add(new Label("type: "), 0, 3);
  add(categoryComboBox, 1, 0);
  add(variableRoleComboBox, 1, 1);
  add(nameTextField, 1, 2);
  add(typeTextField, 1, 3);
  ViewUtils.setupClass(this);
}
 
Example 34
Project: jmonkeybuilder   File: IntArrayPropertyControl.java   Source Code and License 5 votes vote down vote up
@Override
@FXThread
protected void createComponents(@NotNull final HBox container) {
    super.createComponents(container);

    valueField = new TextField();
    valueField.setOnKeyReleased(this::updateValue);
    valueField.prefWidthProperty()
            .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));

    FXUtils.addClassTo(valueField, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX);
    FXUtils.addToPane(valueField, container);
}
 
Example 35
Project: Notebook   File: CategoryFragment.java   Source Code and License 5 votes vote down vote up
private void createDialog(Category listItem) {
	List<Category> categories = CategoryDao.getInstance().findAll();

	AlertDialog.Builder builder = new AlertDialog.Builder();
	builder.title("���༭");
	builder.view("dialog_category_edit")
	.build();
	alertDialog = builder.build();
	Button btn_confirm = alertDialog.findView("#btn_confirm", Button.class);
	Button btn_cancel = alertDialog.findView("#btn_cancel", Button.class);

	TextField et_title = alertDialog.findView("#et_title", TextField.class);

	if(listItem.getName() != null) et_title.setText(listItem.getName());

	btn_confirm.setOnAction(ee ->{
		String name = et_title.getText();
		if(name.equals("")){
			DialogHelper.alert("Error", "���ݲ���Ϊ�գ�");
			return;
		}
		// update ListView items & database
		listItem.setName(name);
		CategoryDao.getInstance().saveOrUpdate(listItem);

		// �Զ�ˢ��
		loadData();
		alertDialog.close();
	});

	btn_cancel.setOnAction(eee->{
		alertDialog.close();
	});

	alertDialog.show();
}
 
Example 36
Project: UDE   File: TabView.java   Source Code and License 5 votes vote down vote up
protected void setTabView(String path, TilePane tP, TextField tF) {
    this.tilePane = tP;
    this.txtDirPath = tF;
    tilePane.getChildren().clear();
    txtDirPath.setText(path);
    generateIcons();
}
 
Example 37
Project: creacoinj   File: BitcoinAddressValidator.java   Source Code and License 5 votes vote down vote up
public BitcoinAddressValidator(NetworkParameters params, TextField field, Node... nodes) {
    this.params = params;
    this.nodes = nodes;

    // Handle the red highlighting, but don't highlight in red just when the field is empty because that makes
    // the example/prompt address hard to read.
    new TextFieldValidator(field, text -> text.isEmpty() || testAddr(text));
    // However we do want the buttons to be disabled when empty so we apply a different test there.
    field.textProperty().addListener((observableValue, prev, current) -> {
        toggleButtons(current);
    });
    toggleButtons(field.getText());
}
 
Example 38
Project: legendary-guide   File: BitcoinAddressValidator.java   Source Code and License 5 votes vote down vote up
public BitcoinAddressValidator(NetworkParameters params, TextField field, Node... nodes) {
    this.params = params;
    this.nodes = nodes;

    // Handle the red highlighting, but don't highlight in red just when the field is empty because that makes
    // the example/prompt address hard to read.
    new TextFieldValidator(field, text -> text.isEmpty() || testAddr(text));
    // However we do want the buttons to be disabled when empty so we apply a different test there.
    field.textProperty().addListener((observableValue, prev, current) -> {
        toggleButtons(current);
    });
    toggleButtons(field.getText());
}
 
Example 39
Project: Conan   File: ViewUtil.java   Source Code and License 5 votes vote down vote up
public static void addFocusListener(TextField tf, ProofView pv) {
    tf.focusedProperty().addListener((observable, oldValue, newValue) -> {
        pv.lastFocusedTf = tf;
        pv.caretPosition = tf.getCaretPosition();
        pv.updateStatus();
    });
}
 
Example 40
Project: file-transfer   File: SendNetPane.java   Source Code and License 5 votes vote down vote up
private void createIPTextField() {
    id = new TextField();
    addTextFieldCharLimit(id, 4);
    id.setPrefColumnCount(4);
}
 
Example 41
Project: jmonkeybuilder   File: CreateSceneFilterDialog.java   Source Code and License 5 votes vote down vote up
@Override
@FXThread
protected void createContent(@NotNull final GridPane root) {
    super.createContent(root);

    final Label customBoxLabel = new Label(Messages.CREATE_SCENE_FILTER_DIALOG_CUSTOM_BOX + ":");
    customBoxLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    customCheckBox = new CheckBox();
    customCheckBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    final Label builtInLabel = new Label(Messages.CREATE_SCENE_FILTER_DIALOG_BUILT_IN + ":");
    builtInLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    builtInBox = new ComboBox<>();
    builtInBox.disableProperty().bind(customCheckBox.selectedProperty());
    builtInBox.getItems().addAll(BUILT_IN_NAMES);
    builtInBox.getSelectionModel().select(BUILT_IN_NAMES.first());
    builtInBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    final Label customNameLabel = new Label(Messages.CREATE_SCENE_FILTER_DIALOG_CUSTOM_FIELD + ":");
    customNameLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    filterNameField = new TextField();
    filterNameField.disableProperty().bind(customCheckBox.selectedProperty().not());
    filterNameField.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    root.add(builtInLabel, 0, 0);
    root.add(builtInBox, 1, 0);
    root.add(customBoxLabel, 0, 1);
    root.add(customCheckBox, 1, 1);
    root.add(customNameLabel, 0, 2);
    root.add(filterNameField, 1, 2);

    FXUtils.addClassTo(builtInLabel, customBoxLabel, customNameLabel, CSSClasses.DIALOG_DYNAMIC_LABEL);
    FXUtils.addClassTo(builtInBox, customCheckBox, filterNameField, CSSClasses.DIALOG_FIELD);
}
 
Example 42
Project: marathonv5   File: JavaFXTextFieldElementTest.java   Source Code and License 5 votes vote down vote up
@Test public void clear() {
    TextField textFieldNode = (TextField) getPrimaryStage().getScene().getRoot().lookup(".text-field");
    textField.marathon_select("Hello World");
    new Wait("Waiting for the text field value to be set") {
        @Override public boolean until() {
            return "Hello World".equals(textFieldNode.getText());
        }
    };
    textField.clear();
    new Wait("Waiting for the text field value to be cleared") {
        @Override public boolean until() {
            return "".equals(textFieldNode.getText());
        }
    };
}
 
Example 43
Project: marathonv5   File: JavaFXTextFieldElementTest.java   Source Code and License 5 votes vote down vote up
@Test public void getText() {
    TextField textFieldNode = (TextField) getPrimaryStage().getScene().getRoot().lookup(".text-field");
    AssertJUnit.assertEquals("Text", textField.getText());
    textField.marathon_select("Hello World");
    new Wait("Waiting for the text field value to be set") {
        @Override public boolean until() {
            return "Hello World".equals(textFieldNode.getText());
        }
    };
    AssertJUnit.assertEquals("Hello World", textField.getText());
}
 
Example 44
Project: Projeto-IP2   File: RemoverDisciplina.java   Source Code and License 5 votes vote down vote up
public void start (Stage primaryStage) throws Exception{
	window = primaryStage;
	window.setTitle("Remover Disciplina");
	pane = FXMLLoader.load(this.getClass().getResource("removerDisciplinaFXML.fxml"));
	TextArea texto = (TextArea) pane.getChildren().get(4);
	menu2 = (MenuButton) pane.getChildren().get(9);
	nome = (TextField) pane.getChildren().get(2);
	id = (TextField) pane.getChildren().get(7);
	adiciona();
	texto.setEditable(false);
	window.setScene(new Scene(pane));
	window.setResizable(false);
	window.show();

}
 
Example 45
Project: stvs   File: FileSelectionField.java   Source Code and License 5 votes vote down vote up
/**
 * Constructor.
 */
public FileSelectionField() {
  super();
  setSpacing(10);
  ViewUtils.setupClass(this);
  textField = new TextField();
  Button fileSelectButton = GlyphsDude.createIconButton(FontAwesomeIcon.FOLDER_OPEN);
  getChildren().add(textField);
  getChildren().add(fileSelectButton);
  fileSelectButton.setOnAction(this::onFileSelectButtonClicked);
  this.setHgrow(textField, Priority.ALWAYS);
}
 
Example 46
Project: jmonkeybuilder   File: FloatArrayPropertyControl.java   Source Code and License 5 votes vote down vote up
@Override
@FXThread
public void changeControlWidthPercent(final double controlWidthPercent) {
    super.changeControlWidthPercent(controlWidthPercent);

    final TextField valueField = getValueField();
    valueField.prefWidthProperty().unbind();
    valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent));
}
 
Example 47
Project: voogasalad-ltub   File: ImageParameterInput.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a image parameter input with the given variable name
 * @param varName
 */
public ImageParameterInput(String varName){
	super();
	imagePath = new TextField();
	this.varName = varName;
	createBox();
}
 
Example 48
Project: Planchester   File: RequestEntry.java   Source Code and License 4 votes vote down vote up
public void setRequestDescription(TextField requestDescription) {
    this.requestDescription = requestDescription;
}
 
Example 49
Project: EistReturns   File: Utils.java   Source Code and License 4 votes vote down vote up
private void displayLogInDialog() {

        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("Player login");
        dialog.setHeaderText("Login to the Hall Of Fame");
        dialog.initOwner(mGameStage);

        dialog.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/login.png").toExternalForm()));

        ButtonType newButtonType = new ButtonType("New player", ButtonData.OTHER);
        ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().addAll(newButtonType, loginButtonType, ButtonType.CANCEL);

        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField username = new TextField();
        username.setPromptText("Name");
        PasswordField password = new PasswordField();
        password.setPromptText("Password");

        grid.add(new Label("Player name:"), 0, 0);
        grid.add(username, 1, 0);
        grid.add(new Label("Password:"), 0, 1);
        grid.add(password, 1, 1);

        Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);

        Node newButton = dialog.getDialogPane().lookupButton(newButtonType);
        newButton.setDisable(true);

        username.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().isEmpty() || password.getText().isEmpty());
            newButton.setDisable(newValue.trim().isEmpty() || password.getText().isEmpty());
        });

        password.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().length() < 6 || username.getText().isEmpty());
            newButton.setDisable(newValue.trim().length() < 6 || username.getText().isEmpty());
        });

        dialog.getDialogPane().setContent(grid);

        Platform.runLater(username::requestFocus);

        mNewPlayer = false;

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(username.getText(), password.getText());
            }
            if (dialogButton == newButtonType) {
                mNewPlayer = true;
                return new Pair<>(username.getText(), password.getText());
            }
            return null;
        });

        Optional<Pair<String, String>> result = dialog.showAndWait();

        result.ifPresent(usernamePassword -> {

            if (!mNewPlayer) {
                playerLogin(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
            } else {
                playerNew(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
            }

        });
    }
 
Example 50
Project: ClusterDeviceControlPlatform   File: ViewUtil.java   Source Code and License 4 votes vote down vote up
public static Optional<TcpMsgResponseDeviceStatus> ResponseDeviceStatusResult() throws NumberFormatException {
    Dialog<TcpMsgResponseDeviceStatus> dialog = new Dialog<>();
    dialog.setTitle("发送状态信息");
    dialog.setHeaderText("请设置单个设备的状态");


    ButtonType loginButtonType = new ButtonType("发送", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

    // Create the username and password labels and fields.
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));

    TextField textFieldGroupId = new TextField();
    textFieldGroupId.setPromptText("1 - 120");

    TextField textFieldDeviceId = new TextField();
    textFieldDeviceId.setPromptText("1 - 100");

    TextField textFieldStatus = new TextField();
    textFieldStatus.setPromptText("1 - 6");


    grid.add(new Label("组号: "), 0, 0);
    grid.add(textFieldGroupId, 1, 0);
    grid.add(new Label("设备号: "), 0, 1);
    grid.add(textFieldDeviceId, 1, 1);
    grid.addRow(2, new Label("状态码: "));
    //      grid.add(, 0, 2);
    grid.add(textFieldStatus, 1, 2);

    // Enable/Disable login button depending on whether a username was entered.
    Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
    loginButton.setDisable(true);

    // Do some validation (using the Java 8 lambda syntax).
    textFieldGroupId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
    textFieldDeviceId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
    textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));

    dialog.getDialogPane().setContent(grid);

    // Request focus on the username field by default.
    Platform.runLater(textFieldGroupId::requestFocus);

    dialog.setResultConverter(dialogButton -> {

        if (dialogButton == loginButtonType) {
            try {
                TcpMsgResponseDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseDeviceStatus(Integer.parseInt(
                        textFieldGroupId.getText().trim()),
                        Integer.parseInt(textFieldDeviceId.getText().trim()),
                        Integer.parseInt(textFieldStatus.getText().trim()));
                return tcpMsgResponseDeviceStatus;
            } catch (NumberFormatException e) {
                System.out.println("空");
                return new TcpMsgResponseDeviceStatus(-1, -1, -1);
            }
        }
        return null;
    });
    return dialog.showAndWait();
}
 
Example 51
Project: qiniu   File: Dialogs.java   Source Code and License 4 votes vote down vote up
public void showBucketAddableDialog() {
	ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);
	Dialog<String[]> dialog = getDialog(ok);

	TextField bucket = new TextField();
	bucket.setPromptText(Values.BUCKET_NAME);
	TextField url = new TextField();
	url.setPromptText(Values.BUCKET_URL);
	// TextField zone = new TextField();
	ComboBox<String> zone = new ComboBox<String>();
	zone.getItems().addAll(Values.BUCKET_NAME_ARRAY);
	zone.setValue(Values.BUCKET_NAME_ARRAY[0]);

	GridPane grid = getGridPane();
	grid.add(new Label(Values.BUCKET_NAME), 0, 0);
	grid.add(bucket, 1, 0);
	grid.add(new Label(Values.BUCKET_URL), 0, 1);
	grid.add(url, 1, 1);
	grid.add(new Label(Values.BUCKET_ZONE_NAME), 0, 2);
	grid.add(zone, 1, 2);

	Node okButton = dialog.getDialogPane().lookupButton(ok);
	okButton.setDisable(true);

	// 监听文本框的输入状态
	bucket.textProperty().addListener((observable, oldValue, newValue) -> {
		okButton.setDisable(newValue.trim().isEmpty() || url.getText().isEmpty());
	});
	url.textProperty().addListener((observable, oldValue, newValue) -> {
		okButton.setDisable(newValue.trim().isEmpty() || bucket.getText().isEmpty());
	});

	dialog.getDialogPane().setContent(grid);

	Platform.runLater(() -> bucket.requestFocus());

	dialog.setResultConverter(dialogButton -> {
		if (dialogButton == ok) {
			return new String[] { bucket.getText(),
					zone.getValue() + " " + (Checker.isHyperLink(url.getText()) ? url.getText() : "example.com") };
		}
		return null;
	});

	Optional<String[]> result = dialog.showAndWait();
	result.ifPresent(res -> {
		logger.info("bucket name: " + res[0] + ", zone name: " + res[1]);
		Platform.runLater(() -> MainWindowController.getInstance().addItem(res[0]));
		QiniuApplication.buckets.put(res[0], res[1]);
		ConfigLoader.writeConfig();
	});
}
 
Example 52
Project: karate   File: HeaderPanel.java   Source Code and License 4 votes vote down vote up
public HeaderPanel(AppSession session) {
    this.session = session;
    content = new HBox(5);
    content.setPadding(new Insets(5));
    setCenter(content);
    textContent = new TextArea();
    textContent.setPrefRowCount(16);
    textContent.setVisible(false);
    setBottom(textContent);
    textContent.setManaged(false);
    textContent.setFont(App.getDefaultFont());
    textContent.focusedProperty().addListener((val, before, after) -> {
        if (!after) { // if we lost focus
            rebuildFeatureIfTextChanged();
        }
    });        
    MenuBar menuBar = new MenuBar();
    Menu fileMenu = new Menu("File");
    openFileMenuItem = new MenuItem("Open");
    fileMenu.getItems().addAll(openFileMenuItem);

    Menu importMenu = new Menu("Import");
    openImportMenuItem = new MenuItem("Open");
    importMenu.getItems().addAll(openImportMenuItem);

    menuBar.getMenus().addAll(fileMenu, importMenu);
    setTop(menuBar);

    if (session != null) {
        Label envLabel = new Label("karate.env");
        envLabel.setPadding(new Insets(5, 0, 0, 0));
        TextField envTextField = new TextField();
        envTextField.setText(session.getEnv().env);
        Button envButton = new Button("Reset");
        envButton.setOnAction(e -> session.resetAll(envTextField.getText()));
        Button runAllButton = new Button("Run ►►");
        runAllButton.setOnAction(e -> session.runAll());            
        Button showContentButton = new Button(getContentButtonText(false));
        initTextContent();
        showContentButton.setOnAction(e -> { 
            boolean visible = !textContent.isVisible();
            textContent.setVisible(visible);
            textContent.setManaged(visible);
            showContentButton.setText(getContentButtonText(visible));
        });
        content.getChildren().addAll(envLabel, envTextField, envButton, runAllButton, showContentButton);            
    }
}
 
Example 53
Project: KNOBS   File: Knob.java   Source Code and License 4 votes vote down vote up
private void openEditor() {

        final PopOver popOver = new PopOver();
        final TextField textEditor = new TextField(targetText.getText());
        BorderPane editorPane = new BorderPane(textEditor);

        BorderPane.setMargin(textEditor, new Insets(12));
        textEditor.setOnKeyReleased(e -> {
            if ( KeyCode.ESCAPE.equals(e.getCode()) ) {
                popOver.hide();
            }
        });
        textEditor.setOnAction(e -> {
            try {
                setTargetValue(Double.parseDouble(textEditor.getText()));
                fireTargeValueSet();
            } catch ( NumberFormatException nfex ) {
                Toolkit.getDefaultToolkit().beep();
            } finally {
                popOver.hide();
            }
        });

        popOver.setContentNode(editorPane);
        popOver.setDetachable(false);
        popOver.setDetached(false);
        popOver.setArrowLocation(PopOver.ArrowLocation.TOP_CENTER);
        popOver.setHeaderAlwaysVisible(true);
        popOver.setHideOnEscape(true);
        popOver.setTitle("Set Target Value");
        popOver.setAnimated(true);
        popOver.setAutoHide(true);
        popOver.setCloseButtonEnabled(true);

        text.getScene().getStylesheets().stream().forEach(s -> popOver.getRoot().getStylesheets().add(s));

        Bounds bounds = getBoundsInLocal();
        Bounds screenBounds = localToScreen(bounds);
        int x = (int) screenBounds.getMinX();
        int y = (int) screenBounds.getMinY();
        int w = (int) screenBounds.getWidth();
        int h = (int) screenBounds.getHeight();

        popOver.show(this, x + w / 2, y + h / 2);
        
    }
 
Example 54
Project: Lernkartei_2017   File: LoginView.java   Source Code and License 4 votes vote down vote up
@Override
public Parent constructContainer()
{
	bp.setId("loginviewbg");

	Errorbox = new HBox(50);
	Errorbox.setAlignment(Pos.CENTER);
	Errorbox.setPadding(new Insets(20));

	AllFields = new VBox(50);
	AllFields.setAlignment(Pos.CENTER);
	AllFields.setMaxWidth(300);
	AllFields.setPadding(new Insets(20));

	Controls = new HBox(50);
	Controls.setAlignment(Pos.CENTER);
	Controls.setPadding(new Insets(20));

	txtName = new TextField();
	txtName.setPromptText("Username");

	pwPassword = new PasswordField();
	pwPassword.setPromptText("Passwort");
	;

	home = new HomeButton(getFXController());
	reg = new AppButton("Noch kein Profil?");
	log = new AppButton("Login");

	errorText = new Label("");
	Errorbox.getChildren().addAll(errorText);

	Controls.getChildren().addAll(home, reg);

	AllFields.getChildren().addAll(txtName, pwPassword, log);

	bp.setTop(Errorbox);
	bp.setCenter(AllFields);
	bp.setBottom(Controls);

	reg.setOnAction(e -> getFXController().showView("registerview"));
	log.setOnAction(e ->
	{

		// So that you can always check again who was logged in last,
		// but if user logged in, it should be set as ""
		Globals.lastRegisteredUser = "";

		String name = txtName.getText();
		String password = pwPassword.getText();

		// So that entries don't exist after leaving the view
		txtName.clear();
		pwPassword.clear();

		if (name.equals("[email protected]") && BCrypt.checkpw(password, "$2a$12$8hcwdnkJ7uO3FvDEG/1fv.vaSNI/FfZqEzfUZFUYRUHLzRjkV/Z5.")/*plaintext-password: "gibb"*/)
		{
			Globals.username = name;
			getFXController().showView("managementselectionview");
		} else
		{
			Alert alert = new Alert(AlertType.ERROR);
			alert.setTitle("Fehler 0x0001");
			alert.setHeaderText("Login-Daten inkorrekt.");
			alert.setContentText(
					"Benutzername und Passwort stimmen nicht �berein oder existieren nicht.\nStellen Sie sicher, dass Ihre Eingaben korrekt sind.");
			pwPassword.clear();
			txtName.clear();
			alert.showAndWait();
		}
	});

	return bp;
}
 
Example 55
Project: Lernkartei_2017   File: SaveDownloadstackLocalView.java   Source Code and License 4 votes vote down vote up
@Override
public Parent constructContainer()
{
	bp = new BorderPane();
	bp.setId("userviewbg");
	
	back = new BackButton(getFXController(),"Zur�ck");
	
	tabPane = new TabPane();
	tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
	tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() {
		   @Override
		   public void changed(ObservableValue<? extends Tab> ov, Tab tabOld, Tab tabNew) {
		      refreshView();
		   }
		});
	 
    	    
    Center = new VBox();
    Search = new HBox();
    Top = new VBox();
    
    
    txtSearch = new TextField();
    txtSearch.setPromptText("Suche nach Doors");
    txtSearch.setMinWidth(740);
    txtSearch.setMinHeight(50);;
    btnSearch = new AppButton("Suchen");
    btnCreate = new AppButton("++Erstellen++");
    btnCreate.setMinWidth(590);
    btnCreate.setOnAction(e -> getFXController().showView("createdoorview"));
    
    StackShowList.setSpacing(20);
    Center.setSpacing(20);
    
    
    sMain = new ScrollPane();
    sMain.setContent(Center);
    
    Search.getChildren().addAll(txtSearch,btnSearch);
    Center.getChildren().addAll(StackShowList,btnCreate);
    
	back = new AppButton("Zur�ck");
	back.setOnAction(e-> getFXController().showView("doorsavepathselectionview"));
	
	
	Bottom = new VBox();

	Bottom.getChildren().addAll(back);
	Top.getChildren().addAll(Search,tabPane);
	
	bp.setTop(Top);
	bp.setCenter(sMain);
	bp.setBottom(Bottom);
	
	getFXController().getModel("serverstack").registerView(this);
	
	return bp;
}
 
Example 56
Project: Lernkartei_2017   File: DMOModifyStackView.java   Source Code and License 4 votes vote down vote up
@Override
public Parent constructContainer()
{
	bp.setId("loginviewbg");
	
	AllFields = new HBox(50);
	AllFields.setAlignment(Pos.CENTER);
	AllFields.setMaxWidth(300);
	AllFields.setPadding(new Insets(20));
	AllFields.setPadding(new Insets(200,0,0,0));
	//AllFields.setMinWidth(740);
	
	Value = new VBox();
	Value.setMinWidth(400);
	Value.setSpacing(35);
	Buttons = new VBox();
	Buttons.setSpacing(5);
	Name = new HBox();
	
	inputName = new TextField();
	inputName.setPromptText("Names der Door");
	inputName.setAlignment(Pos.CENTER_LEFT);
	inputName.setMinWidth(50);
	
	name = new Label("Name");
	removeDoor = new Label("Stack l�schen");
	titel = new Label("Bearbeiten");

	btnRemoveDoor = new AppButton("Entfernen");
	btnRemoveStack = new AppButton("Entfernen");
	btnModify = new AppButton("�ndern");
	back = new BackButton(getFXController(),"Abbrechen");
	
	//Buttons.getChildren().addAll(,,btnRemoveStack,back);
	Name.getChildren().addAll(name,inputName);
	Value.getChildren().addAll(Name,removeDoor);
	Buttons.getChildren().addAll(btnModify,btnRemoveDoor,back);
	AllFields.getChildren().addAll(Value,Buttons);
	
	/*inside.setLeft(AllFields); 
	inside.setRight(Buttons);*/
	
	bp.setCenter(AllFields);
	
	/*
	btnCreate.setOnAction(e -> getFXController().showView("serverdoorview"));
	--Listenter to crete a door
	*/
	
	
	return bp;
}
 
Example 57
Project: stvs   File: ConfigDialogPane.java   Source Code and License 4 votes vote down vote up
/**
 * <p>
 * Creates the view for a config dialog.
 * </p>
 *
 * <p>
 * Text fields and checkboxes have to be initialized from a
 * {@link edu.kit.iti.formal.stvs.model.config.GlobalConfig} model. For that, use the
 * {@link ConfigDialogManager}.
 * </p>
 */
public ConfigDialogPane() {
  verificationTimeout = new PositiveIntegerInputField();
  simulationTimeout = new PositiveIntegerInputField();
  editorFontSize = new PositiveIntegerInputField();
  editorFontFamily = new TextField();
  showLineNumbers = new CheckBox();
  uiLanguage = new ComboBox<>();
  nuxmvFilename = new FileSelectionField();
  z3Path = new FileSelectionField();
  getetaCommand = new TextField();
  maxLineRollout = new PositiveIntegerInputField();
  okButtonType = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);


  this.getButtonTypes().addAll(okButtonType, ButtonType.CANCEL);


  GridPane grid = new GridPane();
  grid.setHgap(10);
  grid.setVgap(10);
  grid.setPadding(new Insets(20, 10, 10, 10));

  grid.add(new Label("Verification Timeout"), 0, 0);
  grid.add(verificationTimeout, 1, 0);

  grid.add(new Label("Simulation Timeout"), 0, 1);
  grid.add(simulationTimeout, 1, 1);

  grid.add(new Label("Editor Fontsize"), 0, 2);
  grid.add(editorFontSize, 1, 2);

  grid.add(new Label("Editor Font Family"), 0, 3);
  grid.add(editorFontFamily, 1, 3);

  grid.add(new Label("Show Line Numbers"), 0, 4);
  grid.add(showLineNumbers, 1, 4);

  grid.add(new Label("User Interface Language"), 0, 5);
  grid.add(uiLanguage, 1, 5);


  grid.add(new Label("Path to NuXmv Executable"), 0, 6);
  grid.add(nuxmvFilename, 1, 6);


  grid.add(new Label("Path to Z3"), 0, 7);
  grid.add(z3Path, 1, 7);

  grid.add(new Label("GeTeTa Command"), 0, 9);
  grid.add(getetaCommand, 1, 9);
  Text getetaCommandDescription =
      new Text("Use ${code} and ${spec} for code and specification" + " filename substitution.");
  getetaCommandDescription.setStyle("-fx-font-style: italic");
  grid.add(getetaCommandDescription, 0, 10, 2, 1);

  grid.add(new Label("Maximum Number of Rollouts per Line"), 0, 11);
  grid.add(maxLineRollout, 1, 11);
  this.setContent(grid);
  ViewUtils.setupClass(this);

}
 
Example 58
Project: Lernkartei_2017   File: LabelOption.java   Source Code and License 4 votes vote down vote up
private void LabelOptionInit (String configKey, String description, String def, FXController controller)
{
	this.description = new Label(description);
	this.description.setWrapText(true);
	
	textField = new TextField();
	oldValue = "";
	
	boolean noEntry = false;
	
	String dataValue = controller.getModel("config").getString(configKey);
	if (dataValue != null)
	{
		oldValue = dataValue;
	}
	else { noEntry = true; }
	
	if (noEntry)
	{
		Model m = controller.getModel("config");
		if (m != null) 
		{
			if (def == null)
			{
				m.doAction(Command.SET, configKey, "");
			}
			else
			{
				m.doAction(Command.SET, configKey, def);
				oldValue = def;
			}
		}
		else
		{
			debug.Debugger.out("Model config not found!");
		}
	}
	
	textField.setText(oldValue);
	listener = new InvalidationListener()
	{
		@Override
		public void invalidated (Observable observable)
		{
			String value = textField.getText();
			debug.Debugger.out(configKey + " property has changed to " + value);
			controller.getModel("config").doAction(Command.SET, configKey, value);
		}
	};
	textField.textProperty().addListener(listener);
}
 
Example 59
Project: FlashLib   File: PropertyViewer.java   Source Code and License 4 votes vote down vote up
private void loadPropertyViewer(){
	keysBox = new ComboBox<String>();
	keysBox.setPrefWidth(150);
	valField = new TextField();
	valField.setPrefWidth(150);
	final Button save = new Button("Save"), newProp = new Button("New"), 
			delete = new Button("Delete");
	save.setDisable(true);
	delete.setDisable(true);
	
	keysBox.getItems().add("");
	String[] keys = getKeys();
	keysBox.getItems().addAll(keys);
	keysBox.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue)->{
		local = true;
		if(newValue.intValue() != 0){
			cProp = props.get(newValue.intValue() - 1);
			valField.setText(cProp.getValue());
			delete.setDisable(false);
		}else {
			valField.setText("");
			delete.setDisable(true);
		}
		local = false;
		save.setDisable(true);
	});
	valField.textProperty().addListener((observable, oldValue, newValue)->{
		if(!local && keysBox.getSelectionModel().getSelectedIndex() > 0)
			save.setDisable(false);
	});
	
	delete.setOnAction((e)->{
		int i = keysBox.getSelectionModel().getSelectedIndex();
		if(i != 0){
			keysBox.getItems().remove(i);
			props.get(i - 1).remove();
			props.remove(i - 1);
		}
		keysBox.getSelectionModel().select(i - 1);
	});
	save.setOnAction((e)->{
		String newVal = valField.getText();
		if(!newProp(cProp, newVal))
			FlashFXUtils.showErrorDialog(this, "Error", "Value is incompatible with property type");
		save.setDisable(true);
	});
	newProp.setOnAction((e)->{
		Property prop = PropertyViewer.showPropertyCreator(this);
		if(prop != null){
			props.add(prop);
			keysBox.getItems().add(prop.getName());
		}
	});
	VBox viewerNode = new VBox();
	viewerNode.getChildren().addAll(keysBox, valField);
	viewerNode.setSpacing(10);
	viewerNode.setAlignment(Pos.CENTER);
	viewerNode.setPadding(new Insets(10, 10, 10, 10));
	HBox buttonNode = new HBox();
	buttonNode.getChildren().addAll(save, newProp, delete);
	buttonNode.setSpacing(10);
	buttonNode.setAlignment(Pos.CENTER_RIGHT);
	buttonNode.setPadding(new Insets(0, 5, 5, 0));
	BorderPane pane = new BorderPane();
	pane.setBottom(buttonNode);
	pane.setCenter(viewerNode);
	setScene(new Scene(pane, 200, 200));
}
 
Example 60
Project: fwm   File: InteractionController.java   Source Code and License 4 votes vote down vote up
public TextField getPartyMember(){
	return partyMember;
}