Java 类javafx.scene.control.TextField 实例源码
项目:marathonv5
文件:SearchBoxSample.java
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);
}
});
}
项目:ExtremeGuiMakeover
文件:MovieViewSkin.java
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);
}
项目:CSS-Editor-FX
文件:OptionsController.java
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();
});
}
项目:CDN-FX-2.2
文件:TDATableFilter.java
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);
}
项目:SensorThingsManager
文件:EntityGuiController.java
@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);
}
}
}
项目:WholesomeChat
文件:MainController.java
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));
}
}
};
}
项目:Conan
文件:RulePane.java
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));
}
项目:SystemMonitorJFX
文件:MainStage.java
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);
}
项目:GameAuthoringEnvironment
文件:TestFacebook.java
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;
}
项目:marathonv5
文件:SearchBoxSample.java
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);
}
});
}
项目:marathonv5
文件:RFXTextFieldTest.java
@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));
}
项目:fxexperience2
文件:GradientSlider.java
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());
// }
// });
}
项目:Balda
文件:SceneFormController.java
/**
* Добавляем текстовые поля для ввода
*/
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("");
}
}
}
}
}
项目:marathonv5
文件:JavaFXSpinnerElement.java
@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;
}
项目:jmonkeybuilder
文件:SaveAsEditorDialog.java
/**
* 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();
}
项目:jmonkeybuilder
文件:StringPropertyControl.java
/**
* 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);
}
项目:jmonkeybuilder
文件:SettingsDialog.java
/**
* 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);
}
项目:jmonkeybuilder
文件:FloatArrayPropertyControl.java
@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);
}
项目:Lernkartei_2017
文件:UserListView.java
@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;
}
项目:drd
文件:FormUtils.java
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());
}
项目:fx-animation-editor
文件:ColorPickerComponent.java
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);
}
项目:phone-simulator
文件:Impl.java
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());
}
项目:stvs
文件:IoVariableDefinitionPane.java
/**
* 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);
}
项目:jmonkeybuilder
文件:IntArrayPropertyControl.java
@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);
}
项目:Notebook
文件:CategoryFragment.java
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();
}
项目:incubator-netbeans
文件:WebViewBrowser.java
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);
}
项目:UDE
文件:TabView.java
protected void setTabView(String path, TilePane tP, TextField tF) {
this.tilePane = tP;
this.txtDirPath = tF;
tilePane.getChildren().clear();
txtDirPath.setText(path);
generateIcons();
}
项目:creacoinj
文件:BitcoinAddressValidator.java
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());
}
项目:legendary-guide
文件:BitcoinAddressValidator.java
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());
}
项目:Conan
文件:ViewUtil.java
public static void addFocusListener(TextField tf, ProofView pv) {
tf.focusedProperty().addListener((observable, oldValue, newValue) -> {
pv.lastFocusedTf = tf;
pv.caretPosition = tf.getCaretPosition();
pv.updateStatus();
});
}
项目:jmonkeybuilder
文件:CreateSceneFilterDialog.java
@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);
}
项目:Elementary-Number-Theory
文件:HelpingClass.java
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;
}
项目:FlashLib
文件:MainWindow.java
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;
}
项目:Socket_Chat
文件:ClientGUI.java
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;
}
项目:MasterHash
文件:NewLogin.java
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();
}
项目:marathonv5
文件:MarathonModuleStage.java
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);
}
项目:shuffleboard
文件:EditableLabel.java
/**
* 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();
}
});
}
项目:stvs
文件:WizardUneditableStringPage.java
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);
}
项目:marathonv5
文件:JavaFXTextFieldElementTest.java
@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());
}
};
}