当前位置: 首页>>代码示例>>Java>>正文


Java TextField类代码示例

本文整理汇总了Java中javafx.scene.control.TextField的典型用法代码示例。如果您正苦于以下问题:Java TextField类的具体用法?Java TextField怎么用?Java TextField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextField类属于javafx.scene.control包,在下文中一共展示了TextField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SearchBox

import javafx.scene.control.TextField; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:24,代码来源:SearchBoxSample.java

示例2: addToolBar

import javafx.scene.control.TextField; //导入依赖的package包/类
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);
}
 
开发者ID:hendrikebbers,项目名称:ExtremeGuiMakeover,代码行数:40,代码来源:MovieViewSkin.java

示例3: createField

import javafx.scene.control.TextField; //导入依赖的package包/类
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();
  });
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:19,代码来源:OptionsController.java

示例4: createTableFilter

import javafx.scene.control.TextField; //导入依赖的package包/类
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);
    }
 
开发者ID:Ptrk25,项目名称:CDN-FX-2.2,代码行数:27,代码来源:TDATableFilter.java

示例5: init

import javafx.scene.control.TextField; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:hylkevds,项目名称:SensorThingsManager,代码行数:23,代码来源:EntityGuiController.java

示例6: initialize

import javafx.scene.control.TextField; //导入依赖的package包/类
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));
   	    	}
   		}
	};
}
 
开发者ID:Miic,项目名称:WholesomeChat,代码行数:17,代码来源:MainController.java

示例7: WebViewPane

import javafx.scene.control.TextField; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:WebViewBrowser.java

示例8: RulePane

import javafx.scene.control.TextField; //导入依赖的package包/类
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));
}
 
开发者ID:nonilole,项目名称:Conan,代码行数:18,代码来源:RulePane.java

示例9: initTableContextMenu

import javafx.scene.control.TextField; //导入依赖的package包/类
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);
  }
 
开发者ID:dhiogoboza,项目名称:SystemMonitorJFX,代码行数:23,代码来源:MainStage.java

示例10: makeMyHighScorePost

import javafx.scene.control.TextField; //导入依赖的package包/类
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;
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:20,代码来源:TestFacebook.java

示例11: VisionControl

import javafx.scene.control.TextField; //导入依赖的package包/类
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;
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:38,代码来源:MainWindow.java

示例12: getText

import javafx.scene.control.TextField; //导入依赖的package包/类
@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));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:RFXTextFieldTest.java

示例13: incOrDecFieldValue

import javafx.scene.control.TextField; //导入依赖的package包/类
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());
//            }
//        });
    }
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:21,代码来源:GradientSlider.java

示例14: addLetterTextFields

import javafx.scene.control.TextField; //导入依赖的package包/类
/**
 * Добавляем текстовые поля для ввода
 */
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("");
                }
            }
        }
    }
}
 
开发者ID:TMihis,项目名称:Balda,代码行数:24,代码来源:SceneFormController.java

示例15: marathon_select

import javafx.scene.control.TextField; //导入依赖的package包/类
@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;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:JavaFXSpinnerElement.java


注:本文中的javafx.scene.control.TextField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。