Java Code Examples for javafx.scene.control.TextField.setMaxWidth()

The following are Jave code examples for showing how to use setMaxWidth() of the javafx.scene.control.TextField class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Conan   File: RulePane.java   Source Code and License Vote up 6 votes
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 2
Project: marathonv5   File: StringBindingSample.java   Source Code and License Vote up 6 votes
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);
}
 
Example 3
Project: uPMT   File: InterviewTreeViewController.java   Source Code and License Vote up 6 votes
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());
	
}
 
Example 4
Project: FlashLib   File: MainWindow.java   Source Code and License Vote up 6 votes
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 5
Project: Lernkartei_2017   File: Alert.java   Source Code and License Vote up 5 votes
/**
 * 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;
}
 
Example 6
Project: marathonv5   File: StringBindingSample.java   Source Code and License Vote up 5 votes
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);
}
 
Example 7
Project: uPMT   File: MomentExpVBox.java   Source Code and License Vote up 5 votes
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);
}
 
Example 8
Project: gatepass   File: Office_Entry.java   Source Code and License Vote up 5 votes
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;
 }
 
Example 9
Project: cassandra-client   File: NewConnectionBox.java   Source Code and License Vote up 5 votes
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;
}
 
Example 10
Project: cassandra-client   File: NewConnectionBox.java   Source Code and License Vote up 5 votes
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;
}
 
Example 11
Project: GameAuthoringEnvironment   File: BasicUIFactory.java   Source Code and License Vote up 4 votes
@Override
public TextField createTextField (double width) {
    TextField text = new TextField();
    text.setMaxWidth(width);
    return text;
}
 
Example 12
Project: CalendarFX   File: EntryHeaderView.java   Source Code and License Vote up 4 votes
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$
                }
            });
}
 
Example 13
Project: gatepass   File: AllAttendance.java   Source Code and License Vote up 4 votes
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;
}
 
Example 14
Project: graphing-loan-analyzer   File: GUI.java   Source Code and License Vote up 4 votes
/** 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);
}