本文整理汇总了Java中javafx.scene.control.TextField.setMaxWidth方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setMaxWidth方法的具体用法?Java TextField.setMaxWidth怎么用?Java TextField.setMaxWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TextField
的用法示例。
在下文中一共展示了TextField.setMaxWidth方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: StringBindingSample
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public StringBindingSample() {
final SimpleDateFormat format = new SimpleDateFormat("mm/dd/yyyy");
final TextField dateField = new TextField();
dateField.setPromptText("Enter a birth date");
dateField.setMaxHeight(TextField.USE_PREF_SIZE);
dateField.setMaxWidth(TextField.USE_PREF_SIZE);
Label label = new Label();
label.textProperty().bind(new StringBinding() {
{
bind(dateField.textProperty());
}
@Override protected String computeValue() {
try {
Date date = format.parse(dateField.getText());
Calendar c = Calendar.getInstance();
c.setTime(date);
Date today = new Date();
Calendar c2 = Calendar.getInstance();
c2.setTime(today);
if (c.get(Calendar.DAY_OF_YEAR) == c2.get(Calendar.DAY_OF_YEAR) - 1
&& c.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
return "You were born yesterday";
} else {
return "You were born " + format.format(date);
}
} catch (Exception e) {
return "Please enter a valid birth date (mm/dd/yyyy)";
}
}
});
VBox vBox = new VBox(7);
vBox.setPadding(new Insets(12));
vBox.getChildren().addAll(label, dateField);
getChildren().add(vBox);
}
示例3: renameInter
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public void renameInter(){
renameInterview.setDisable(true);
TextField textField = new TextField();
textField.setText(interview.getNom());
textField.setMaxWidth(100);
textField.requestFocus();
textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
{
if (!newPropertyValue)
{
nomEntretien.setText(textField.getText());
interview.setNom(textField.getText());
interviewPane.setLeft(nomEntretien);
renameInterview.setDisable(false);
}
}
});
textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if(event.getCode() == KeyCode.ENTER){
nomEntretien.setText(textField.getText());
interview.setNom(textField.getText());
interviewPane.setLeft(nomEntretien);
renameInterview.setDisable(true);
}
if(event.getCode() == KeyCode.ESCAPE){
interviewPane.setLeft(nomEntretien);
renameInterview.setDisable(true);
}
}
});
interviewPane.setLeft(textField);
Platform.runLater(()->textField.requestFocus());
Platform.runLater(()->textField.selectAll());
}
示例4: 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;
}
示例5: simpleString
import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
* Kleines Fenster, dass Input (String) vom User abfragt.
*
* @param title
* Der Titel des Fensters
* @param message
* Die Narchricht, die angezeigt wird. Text wird nicht von selbst
* gewrapt.
* @param fieldWidth
* Setzt die Breite des Textfeldes
* @return String mit dem Userinput
*/
public static String simpleString (String title, String message, String field, double fieldWidth)
{
Stage window = buildWindow(title);
Label l = new Label(message);
TextField tf = new TextField(field);
tf.setMaxWidth(fieldWidth);
tf.setOnKeyReleased(e -> {
if (e.getCode().equals(KeyCode.ENTER))
{
tempOutput = tf.getText();
window.close();
}
});
Button b = new Button("_OK");
b.setOnAction(e ->
{
tempOutput = tf.getText();
window.close();
});
VBox layout = new VBox(20);
layout.getChildren().addAll(l, tf, b);
layout.setAlignment(Pos.CENTER);
layout.setPadding(new Insets(20));
int width;
int x = 6;
int y = 150;
width = message.length() * x + y;
layout.setOnKeyReleased(e ->
{
if (e.getCode() == KeyCode.ESCAPE)
window.close();
});
window.setScene(new Scene(layout, width, 150));
window.showAndWait();
output = tempOutput;
tempOutput = null;
return output;
}
示例6: editNameMode
import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void editNameMode() {
TextField t = new TextField();
t.setMaxWidth(180);
t.setText(moment.getNom());
t.requestFocus();
ChangeListener<Boolean> listener = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
{
if (!newPropertyValue)
{
RenameMomentCommand cmd = new RenameMomentCommand(nameController,moment.getNom(),t.getText());
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
borderPaneLabel.setCenter(label);
t.focusedProperty().removeListener(this);
}
}
};
t.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if(event.getCode() == KeyCode.ENTER){
t.setText(t.getText());
borderPaneLabel.setCenter(label);
}
if(event.getCode() == KeyCode.ESCAPE){
borderPaneLabel.setCenter(label);
}
}
});
t.focusedProperty().addListener(listener);
Platform.runLater(()->t.requestFocus());
Platform.runLater(()->t.selectAll());
borderPaneLabel.setCenter(t);
}
示例7: getActionPane
import javafx.scene.control.TextField; //导入方法依赖的package包/类
private VBox getActionPane(){
progress= new Text("Office\nEntry Progress");
progress.setTextAlignment(TextAlignment.CENTER);
progress.setFont(Font.font("Times New Roman", 35));
lname= new Label("-Your Name here-");
Image iconf= new Image(Office_Entry.class.getResourceAsStream("/pic/finger.png"));
ImageView ivconf= new ImageView(iconf);
lpic= new Label();
lpic.setGraphic(ivconf);
Image img1= new Image(PersonalReports.class.getResourceAsStream("/pic/cross.png"));
ImageView imagvw= new ImageView(img1);
imagvw.setFitHeight(70);
imagvw.setFitWidth(70);
lnotexist= new Label("",imagvw);
lnotexist.setText("\n\n\n\n\nN/A");
lnotexist.setFont(Font.font("Cooper Black", 15));
lnotexist.setVisible(false);
txtfinger= new TextField();
txtfinger.setEditable(false);
txtfinger.setMaxWidth(160);
txtfinger.setStyle("-fx-background-radius:10; -fx-background-color:#9CD777;");
txtsearch= new TextField();
initFilter();
Button btnView= new Button("View Records");
Button btnCloseView= new Button("Hide Records");
Button btnadd= new Button("save");
btnadd.setOnAction(e -> {
setAddAttendance();
});
btnView.setOnAction(e -> {
timelineDown.play();
});
btnCloseView.setOnAction(e -> {
timelineUp.play();
});
VBox laywrong= new VBox();
laywrong.getChildren().addAll(lnotexist);
laywrong.setPadding(new Insets(0,0,0,0));
laywrong.setAlignment(Pos.CENTER);
HBox laytest= new HBox(5);
laytest.getChildren().addAll(txtfinger /* btnadd*/);
laytest.setAlignment(Pos.CENTER);
VBox laybtnsearch= new VBox();
laybtnsearch.getChildren().addAll(txtsearch);
laybtnsearch.setAlignment(Pos.CENTER);
laybtnsearch.setPadding(new Insets(20,0,0,0));
HBox laybtn= new HBox(5);
laybtn.getChildren().addAll(btnView, btnCloseView);
laybtn.setAlignment(Pos.CENTER);
VBox lay1= new VBox(10);
lay1.getChildren().addAll(progress, lpic, lname, laytest);
lay1.setAlignment(Pos.CENTER);
VBox layside= new VBox(25);
layside.getChildren().addAll(lay1, laybtn, laybtnsearch, laywrong);
layside.setAlignment(Pos.TOP_CENTER);
layside.setMinWidth(230);
layside.setPadding(new Insets(20,0,10,0));
return layside;
}
示例8: getKeyspaceField
import javafx.scene.control.TextField; //导入方法依赖的package包/类
private TextField getKeyspaceField(int width) {
TextField keyspace = new TextField();
keyspace.setPromptText(localeService.getMessage("ui.menu.file.connect.keyspace.text"));
keyspace.setAlignment(Pos.TOP_CENTER);
keyspace.setMinWidth(width - 10);
keyspace.setMaxWidth(width - 10);
keyspace.setOnAction(this::handleClick);
return keyspace;
}
示例9: getUrlField
import javafx.scene.control.TextField; //导入方法依赖的package包/类
private TextField getUrlField(int width) {
TextField url = new TextField();
url.setPromptText(localeService.getMessage("ui.menu.file.connect.url.text"));
url.setAlignment(Pos.CENTER);
url.setMinWidth(width - 10);
url.setMaxWidth(width - 10);
return url;
}
示例10: createTextField
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public TextField createTextField (double width) {
TextField text = new TextField();
text.setMaxWidth(width);
return text;
}
示例11: EntryHeaderView
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public EntryHeaderView(Entry<?> entry, List<Calendar> calendars) {
this.entry = requireNonNull(entry);
requireNonNull(calendars);
getStylesheets().add(CalendarView.class.getResource("calendar.css").toExternalForm());
TextField titleField = new TextField(entry.getTitle());
Bindings.bindBidirectional(titleField.textProperty(), entry.titleProperty());
titleField.disableProperty().bind(entry.getCalendar().readOnlyProperty());
TextField locationField = new TextField(entry.getLocation());
Bindings.bindBidirectional(locationField.textProperty(), entry.locationProperty());
locationField.getStyleClass().add("location"); //$NON-NLS-1$
locationField.setEditable(true);
locationField.setPromptText(Messages.getString("EntryHeaderView.PROMPT_LOCATION")); //$NON-NLS-1$
locationField.setMaxWidth(500);
locationField.disableProperty().bind(entry.getCalendar().readOnlyProperty());
calendarSelector = new CalendarSelector();
calendarSelector.disableProperty().bind(entry.getCalendar().readOnlyProperty());
calendarSelector.getCalendars().setAll(calendars);
calendarSelector.setCalendar(entry.getCalendar());
Bindings.bindBidirectional(calendarSelector.calendarProperty(), entry.calendarProperty());
titleField.getStyleClass().add("default-style-entry-popover-title"); //$NON-NLS-1$
add(titleField, 0, 0);
add(calendarSelector, 1, 0, 1, 2);
add(locationField, 0, 1);
RowConstraints row1 = new RowConstraints();
row1.setValignment(VPos.TOP);
row1.setFillHeight(true);
RowConstraints row2 = new RowConstraints();
row2.setValignment(VPos.TOP);
row2.setFillHeight(true);
getRowConstraints().addAll(row1, row2);
ColumnConstraints col1 = new ColumnConstraints();
col1.setFillWidth(true);
col1.setHgrow(Priority.ALWAYS);
ColumnConstraints col2 = new ColumnConstraints();
col2.setFillWidth(true);
col2.setHgrow(Priority.NEVER);
getColumnConstraints().addAll(col1, col2);
getStyleClass().add("popover-header"); //$NON-NLS-1$
titleField.getStyleClass().add("title"); //$NON-NLS-1$
titleField.setPromptText(Messages.getString("EntryHeaderView.PROMPT_TITLE")); //$NON-NLS-1$
titleField.setMaxWidth(500);
Calendar calendar = entry.getCalendar();
titleField.getStyleClass().add(calendar.getStyle() + "-entry-popover-title"); //$NON-NLS-1$
entry.calendarProperty()
.addListener((observable, oldCalendar, newCalendar) -> {
if (oldCalendar != null) {
titleField.getStyleClass().remove(oldCalendar.getStyle() + "-entry-popover-title"); //$NON-NLS-1$
}
if (newCalendar != null) {
titleField.getStyleClass().add(newCalendar.getStyle() + "-entry-popover-title"); //$NON-NLS-1$
}
});
}
示例12: getActionPane
import javafx.scene.control.TextField; //导入方法依赖的package包/类
private VBox getActionPane(){
progress= new Text("Gate\nEntry Progress");
progress.setTextAlignment(TextAlignment.CENTER);
progress.setFont(Font.font("Times New Roman", 35));
lname= new Label("-Your Name here-");
Image iconf= new Image(AllAttendance.class.getResourceAsStream("/pic/finger.png"));
ImageView ivconf= new ImageView(iconf);
lpic= new Label();
lpic.setGraphic(ivconf);
Image img1= new Image(PersonalReports.class.getResourceAsStream("/pic/cross.png"));
ImageView imagvw= new ImageView(img1);
imagvw.setFitHeight(70);
imagvw.setFitWidth(70);
lnotexist= new Label("",imagvw);
lnotexist.setText("\n\n\n\n\nN/A");
lnotexist.setFont(Font.font("Cooper Black", 15));
lnotexist.setVisible(false);
txtfinger= new TextField();
txtfinger.setEditable(false);
txtfinger.setMaxWidth(160);
txtfinger.setStyle("-fx-background-radius:10; -fx-background-color:#9CD777;");
txtsearch= new TextField();
initFilter();
Button btnadd= new Button("save");
btnadd.setOnAction(e -> {
setAddAttendance();
});
Button btnView= new Button("View Records");
Button btnCloseView= new Button("Hide Records");
btnView.setOnAction(e -> {
timelineDown.play();
});
btnCloseView.setOnAction(e -> {
timelineUp.play();
});
VBox laywrong= new VBox();
laywrong.getChildren().addAll(lnotexist);
laywrong.setPadding(new Insets(0,0,0,0));
laywrong.setAlignment(Pos.CENTER);
HBox laytest= new HBox(5);
laytest.getChildren().addAll(txtfinger /* btnadd*/);
laytest.setAlignment(Pos.CENTER);
//btnadd was beside txtfinger
VBox laybtnsearch= new VBox();
laybtnsearch.getChildren().addAll(txtsearch);
laybtnsearch.setAlignment(Pos.CENTER);
laybtnsearch.setPadding(new Insets(20,0,0,0));
HBox laybtn= new HBox(5);
laybtn.getChildren().addAll(btnView, btnCloseView);
laybtn.setAlignment(Pos.CENTER);
VBox lay1= new VBox(10);
lay1.getChildren().addAll(progress, lpic, lname, laytest);
lay1.setAlignment(Pos.CENTER);
VBox layside= new VBox(25);
layside.getChildren().addAll(lay1, laybtn, laybtnsearch, laywrong);
layside.setAlignment(Pos.TOP_CENTER);
layside.setMinWidth(230);
layside.setPadding(new Insets(20,0,10,0));
return layside;
}
示例13: styleTextField
import javafx.scene.control.TextField; //导入方法依赖的package包/类
/** Customizes text fields */
private void styleTextField(TextField textField, String name, Stage stage, boolean makeNumericOnly){
textField.setPromptText( name );
textField.setMaxWidth( stage.getWidth()/4 );
if(makeNumericOnly) makeNumericOnly(textField);
}