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 8 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: 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 3
Project: CSS-Editor-FX   File: OptionsController.java   Source Code and License 6 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 4
Project: CDN-FX-2.2   File: TDATableFilter.java   Source Code and License 6 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 5
Project: SensorThingsManager   File: EntityGuiController.java   Source Code and License 6 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 6
Project: WholesomeChat   File: MainController.java   Source Code and License 6 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 7
Project: incubator-netbeans   File: WebViewBrowser.java   Source Code and License 6 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 8
Project: Conan   File: RulePane.java   Source Code and License 6 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 9
Project: SystemMonitorJFX   File: MainStage.java   Source Code and License 6 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 10
Project: GameAuthoringEnvironment   File: TestFacebook.java   Source Code and License 6 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 11
Project: marathonv5   File: SearchBoxSample.java   Source Code and License 6 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 12
Project: FlashLib   File: MainWindow.java   Source Code and License 6 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 13
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 14
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 15
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 16
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 17
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 18
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 19
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 20
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 21
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 22
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 23
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 24
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 25
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 26
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 27
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 28
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 29
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 30
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 31
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 32
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 33
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 34
Project: Elementary-Number-Theory   File: HelpingClass.java   Source Code and License 5 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 35
Project: Socket_Chat   File: ClientGUI.java   Source Code and License 5 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 36
Project: MasterHash   File: NewLogin.java   Source Code and License 5 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 37
Project: marathonv5   File: MarathonModuleStage.java   Source Code and License 5 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 38
Project: shuffleboard   File: EditableLabel.java   Source Code and License 5 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 39
Project: FX-Test   File: BaseTestFXComponentTest.java   Source Code and License 5 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 40
Project: stvs   File: WizardUneditableStringPage.java   Source Code and License 5 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);
}