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

The following are Jave code examples for showing how to use setPrefWidth() 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: WebPLP   File: CpuWindow.java   Source Code and License Vote up 6 votes
private HBox createTopBar()
{
	HBox counterHBox = new HBox();
	counterHBox.setPadding(new Insets(15, 15, 15, 15));
	counterHBox.setSpacing(10);
	
	Label programCounterLabel = new Label("Program Count");
	programCounterLabel.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
	
	TextField programCounterText = new TextField();
	programCounterText.setPrefWidth(50);
	
	Label nextInstructionLabel = new Label("Next Instruction");
	nextInstructionLabel.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
	
	TextField nextInstructionText = new TextField();
	nextInstructionText.setPrefWidth(200);
	counterHBox.getChildren().addAll(programCounterLabel, programCounterText,
			nextInstructionLabel, nextInstructionText);
			
	return counterHBox;
}
 
Example 2
Project: WebPLP   File: UARTPanel.java   Source Code and License Vote up 5 votes
private HBox createControlPane()
{
	HBox hbox = new HBox();
	setAlignment(hbox, Pos.CENTER);
	hbox.setAlignment(Pos.CENTER_LEFT);
	hbox.setPadding(new Insets(10, 10, 10, 10));
	hbox.setSpacing(5);
	
	Label label = new Label("Send");
	label.setMinWidth(Label.USE_PREF_SIZE);
	hbox.getChildren().add(label);
	
	ComboBox<String> dropdown = createDisplayOptionsDropdown();
	dropdown.setMinWidth(ComboBox.USE_PREF_SIZE);
	hbox.getChildren().add(dropdown);
	
	TextField valueField = new TextField();
	valueField.setPrefWidth(Integer.MAX_VALUE);
	hbox.getChildren().add(valueField);
	
	Button send = new Button("Send");
	send.setMinWidth(Button.USE_PREF_SIZE);
	hbox.getChildren().add(send);
	
	Button clear = new Button("Clear");
	clear.setMinWidth(Button.USE_PREF_SIZE);
	clear.setOnAction((event) -> clear());
	hbox.getChildren().add(clear);
	
	return hbox;
}
 
Example 3
Project: TechnicalAnalysisTool   File: MarketDataTreeViewNode.java   Source Code and License Vote up 5 votes
private void initGUI() {
    //Search facility
    Label searchLabel = new Label();
    Image dirImage = new Image("icon/ZOOM_IN.png");
    searchLabel.setGraphic(new ImageView(dirImage));
    keywordInput = new TextField("Type in search keyword...");
    keywordInput.setPrefWidth(230);
    //Add actionlistener
    keywordInput.textProperty().addListener((observalbe, oldvalue, newvalue)->{           
       updateTreeView(newvalue.toUpperCase());
    });
    //Add focus listener
    keywordInput.focusedProperty().addListener((observalbe, oldvalue, newvalue)->{
        if (newvalue) {
           if (getNodeLayerCount(currentSelectedNode) >= 2) {
              keywordInput.setText("");
           }
        }
    });
    HBox hBox = new HBox();
    hBox.setSpacing(5);
    hBox.getChildren().addAll(searchLabel, keywordInput);
    setTop(hBox); 
    treeView = new TreeView();
    treeView.setMinWidth(200);;
    treeView.setEditable(false);
    treeView.setOnMouseClicked(onTreeItemClicked()); //<-Handle mouse click event
    setCenter(treeView);
}
 
Example 4
Project: marathonv5   File: HTMLEditorSample.java   Source Code and License Vote up 4 votes
public HTMLEditorSample() {
    final VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(10);

    final ChoiceBox sendTo = new ChoiceBox(FXCollections.observableArrayList("To:", "Cc:", "Bcc:"));

    sendTo.setPrefWidth(100);
    GridPane.setConstraints(sendTo, 0, 0);
    grid.getChildren().add(sendTo);

    final TextField tbTo = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbTo, 1, 0);
    grid.getChildren().add(tbTo);

    final Label subjectLabel = new Label("Subject:");
    GridPane.setConstraints(subjectLabel, 0, 1);
    grid.getChildren().add(subjectLabel);

    final TextField tbSubject = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbSubject, 1, 1);
    grid.getChildren().add(tbSubject);

    root.getChildren().add(grid);

    Platform.runLater(() -> {
        final HTMLEditor htmlEditor = new HTMLEditor();
        htmlEditor.setPrefHeight(370);
        root.getChildren().addAll(htmlEditor, new Button("Send"));
    });

    final Label htmlLabel = new Label();
    htmlLabel.setWrapText(true);
    getChildren().add(root);
}
 
Example 5
Project: qiniu   File: Dialogs.java   Source Code and License Vote up 4 votes
public Pair<FileAction, String[]> showFileMovableDialog(String bucket, String key, boolean setKey) {
	MainWindowController main = MainWindowController.getInstance();
	ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);
	Dialog<String[]> dialog = getDialog(ok);

	TextField keyTextField = new TextField();
	keyTextField.setPrefWidth(300);
	keyTextField.setPromptText(Values.FILE_NAME);
	keyTextField.setText(key);
	ComboBox<String> bucketCombo = new ComboBox<String>();
	bucketCombo.getItems().addAll(main.bucketChoiceCombo.getItems());
	bucketCombo.setValue(bucket);
	CheckBox copyasCheckBox = new CheckBox(Values.COPY_AS);
	copyasCheckBox.setSelected(true);

	GridPane grid = getGridPane();
	grid.add(copyasCheckBox, 0, 0, 2, 1);
	grid.add(new Label(Values.BUCKET_NAME), 0, 1);
	grid.add(bucketCombo, 1, 1);
	if (setKey) {
		grid.add(new Label(Values.FILE_NAME), 0, 2);
		grid.add(keyTextField, 1, 2);
		Platform.runLater(() -> keyTextField.requestFocus());
	}

	dialog.getDialogPane().setContent(grid);
	dialog.setResultConverter(dialogButton -> {
		if (dialogButton == ok) {
			return new String[] { bucketCombo.getValue(), keyTextField.getText() };
		}
		return null;
	});

	Optional<String[]> result = dialog.showAndWait();
	if (result.isPresent()) {
		bucket = bucketCombo.getValue();
		key = keyTextField.getText();
		FileAction action = copyasCheckBox.isSelected() ? FileAction.COPY : FileAction.MOVE;
		return new Pair<FileAction, String[]>(action, new String[] { bucket, key });
	} else {
		return null;
	}
}
 
Example 6
Project: WebPLP   File: WatcherWindow.java   Source Code and License Vote up 4 votes
private Node createMemoryControlPanel()
{
	BorderPane addressPanel = new BorderPane();
	
	Label watchAddressLabel = new Label("Watch Address: ");
	addressPanel.setLeft(watchAddressLabel);
	setAlignment(watchAddressLabel, Pos.CENTER);
	
	TextField addressField = new TextField();
	addressPanel.setCenter(addressField);
	setAlignment(addressField, Pos.CENTER);
	
	Button watchAddressButton = new Button("Add");
	watchAddressButton.setOnAction((event) -> watchMemoryAddress(addressField
			.getText()));
	addressPanel.setRight(watchAddressButton);
	setAlignment(watchAddressButton, Pos.CENTER);
	
	BorderPane rangePanel = new BorderPane();
	
	Label watchRangeFromLabel = new Label("Watch Range From ");
	rangePanel.setLeft(watchRangeFromLabel);
	setAlignment(watchRangeFromLabel, Pos.CENTER);
	
	HBox inputBox = new HBox();
	
	TextField fromField = new TextField();
	inputBox.getChildren().add(fromField);
	fromField.setPrefWidth(Integer.MAX_VALUE);
	
	Label toLabel = new Label(" To ");
	toLabel.setMinSize(Label.USE_PREF_SIZE, Label.USE_PREF_SIZE);
	inputBox.getChildren().add(toLabel);
	inputBox.setAlignment(Pos.CENTER);
	
	TextField toField = new TextField();
	toField.setPrefWidth(Integer.MAX_VALUE);
	inputBox.getChildren().add(toField);
	
	rangePanel.setCenter(inputBox);
	setAlignment(inputBox, Pos.CENTER);
	
	Button watchRangeButton = new Button("Add");
	watchRangeButton.setOnAction((event) -> watchMemoryRange(fromField.getText(),
			toField.getText()));
	rangePanel.setRight(watchRangeButton);
	setAlignment(watchRangeButton, Pos.CENTER);
	
	Pair<Node, ComboBox<String>> optionsRowPair = createDisplayOptionsRow();
	Node displayOptions = optionsRowPair.getKey();
	ComboBox<String> displayDropdown = optionsRowPair.getValue();
	displayDropdown.setOnAction((event) -> {
		String selection = displayDropdown.getSelectionModel().getSelectedItem();
		Function<Long, String> function = valueDisplayOptions.get(selection);
		memoryDisplayFunction.set(function);
	});
	
	VBox controlPanel = new VBox();
	controlPanel.getChildren().add(addressPanel);
	controlPanel.getChildren().add(rangePanel);
	controlPanel.getChildren().add(displayOptions);
	controlPanel.setAlignment(Pos.CENTER);
	setAlignment(controlPanel, Pos.CENTER);
	controlPanel.setPadding(new Insets(CP_PADDING));
	controlPanel.setSpacing(CP_SPACING);
	
	return controlPanel;
}
 
Example 7
Project: WebPLP   File: ASMCreationPanel.java   Source Code and License Vote up 4 votes
/**
 * @param onCreateASM
 *            Method to call when "create" is clicked. This parameter must be
 *            non-null.
 * 
 * @throws IllegalArgumentException
 *             if onCreateASM is null
 */
public ASMCreationPanel(Consumer<ASMCreationDetails> onCreateASM)
{
	if (onCreateASM == null)
		throw new IllegalArgumentException("onCreateASM must be non-null");
	
	this.onCreateASM = onCreateASM;
	this.setPadding(new Insets(20));
	GridPane grid = new GridPane();
	HBox buttons = new HBox(10);
	grid.setHgap(10);
	grid.setVgap(30);
	grid.setPadding(new Insets(10, 10, 10, 10));
	
	Label ASMFileName = new Label();
	ASMFileName.setText("File Name: ");
	ASMFileName.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
	
	nameText = new TextField();
	nameText.setText("");
	nameText.requestFocus();
	nameText.setPrefWidth(200);
	
	Label projectName = new Label();
	projectName.setText("Add to Project: ");
	projectName.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
	
	projectListDropdown = new ComboBox<>();
	
	Button create = new Button();
	create.setText("Create");
	create.setOnAction(this::onCreateASMClicked);
	
	grid.add(ASMFileName, 0, 0);
	grid.add(nameText, 1, 0);
	grid.add(projectName, 0, 1);
	grid.add(projectListDropdown, 1, 1);
	
	this.setCenter(grid);
	buttons.getChildren().add(create);
	buttons.setAlignment(Pos.BASELINE_RIGHT);
	this.setBottom(buttons);
}
 
Example 8
Project: CalendarFX   File: ICalWebSourcePane.java   Source Code and License Vote up 4 votes
public ICalWebSourcePane() {
    urlField = new TextField();
    urlField.setPrefWidth(300);
    nameField = new TextField();
    styleComboBox = new ComboBox<>();
    styleComboBox.getItems().setAll(Calendar.Style.values());
    styleComboBox.setButtonCell(new StyleCell());
    styleComboBox.setCellFactory(listView -> new StyleCell());

    acceptButton = new Button("Accept");
    cancelButton = new Button("Cancel");

    GridPane gridPane = new GridPane();
    gridPane.add(new Label("URL"), 0, 0);
    gridPane.add(urlField, 1, 0);
    gridPane.add(new Label("Name"), 0, 1);
    gridPane.add(nameField, 1, 1);
    gridPane.add(new Label("Color"), 0, 2);
    gridPane.add(styleComboBox, 1, 2);
    gridPane.getStyleClass().add("center");
    gridPane.setVgap(5);
    gridPane.setHgap(5);
    gridPane.setPadding(new Insets(10));

    GridPane.setHgrow(urlField, Priority.ALWAYS);
    GridPane.setHgrow(nameField, Priority.ALWAYS);
    GridPane.setHgrow(styleComboBox, Priority.ALWAYS);

    ButtonBar buttonBar = new ButtonBar();
    buttonBar.getButtons().addAll(acceptButton, cancelButton);

    VBox bottomPane = new VBox();
    bottomPane.getChildren().addAll(new Separator(), buttonBar);
    bottomPane.getStyleClass().add("bottom");
    bottomPane.setFillWidth(true);
    bottomPane.setSpacing(10);

    setCenter(gridPane);
    setBottom(bottomPane);
    getStyleClass().add("ical-web-source-pane");
    setPadding(new Insets(15));
}
 
Example 9
Project: FlashLib   File: PropertyViewer.java   Source Code and License Vote up 4 votes
private void loadPropertyViewer(){
	keysBox = new ComboBox<String>();
	keysBox.setPrefWidth(150);
	valField = new TextField();
	valField.setPrefWidth(150);
	final Button save = new Button("Save"), newProp = new Button("New"), 
			delete = new Button("Delete");
	save.setDisable(true);
	delete.setDisable(true);
	
	keysBox.getItems().add("");
	String[] keys = getKeys();
	keysBox.getItems().addAll(keys);
	keysBox.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue)->{
		local = true;
		if(newValue.intValue() != 0){
			cProp = props.get(newValue.intValue() - 1);
			valField.setText(cProp.getValue());
			delete.setDisable(false);
		}else {
			valField.setText("");
			delete.setDisable(true);
		}
		local = false;
		save.setDisable(true);
	});
	valField.textProperty().addListener((observable, oldValue, newValue)->{
		if(!local && keysBox.getSelectionModel().getSelectedIndex() > 0)
			save.setDisable(false);
	});
	
	delete.setOnAction((e)->{
		int i = keysBox.getSelectionModel().getSelectedIndex();
		if(i != 0){
			keysBox.getItems().remove(i);
			props.get(i - 1).remove();
			props.remove(i - 1);
		}
		keysBox.getSelectionModel().select(i - 1);
	});
	save.setOnAction((e)->{
		String newVal = valField.getText();
		if(!newProp(cProp, newVal))
			FlashFXUtils.showErrorDialog(this, "Error", "Value is incompatible with property type");
		save.setDisable(true);
	});
	newProp.setOnAction((e)->{
		Property prop = PropertyViewer.showPropertyCreator(this);
		if(prop != null){
			props.add(prop);
			keysBox.getItems().add(prop.getName());
		}
	});
	VBox viewerNode = new VBox();
	viewerNode.getChildren().addAll(keysBox, valField);
	viewerNode.setSpacing(10);
	viewerNode.setAlignment(Pos.CENTER);
	viewerNode.setPadding(new Insets(10, 10, 10, 10));
	HBox buttonNode = new HBox();
	buttonNode.getChildren().addAll(save, newProp, delete);
	buttonNode.setSpacing(10);
	buttonNode.setAlignment(Pos.CENTER_RIGHT);
	buttonNode.setPadding(new Insets(0, 5, 5, 0));
	BorderPane pane = new BorderPane();
	pane.setBottom(buttonNode);
	pane.setCenter(viewerNode);
	setScene(new Scene(pane, 200, 200));
}
 
Example 10
Project: FlashLib   File: PropertyViewer.java   Source Code and License Vote up 4 votes
private void loadPropertyCreator(){
	nameField = new TextField();
	nameField.setPrefWidth(150);
	valField = new TextField();
	valField.setPrefWidth(150);
	valField.setDisable(true);
	final ComboBox<Property.Type> typeBox = new ComboBox<Property.Type>();
	typeBox.setPrefWidth(150);
	typeBox.getItems().addAll(Property.Type.values());
	final Button save = new Button("Save"), cancel = new Button("Cancel");
	save.setDisable(true);
	
	nameField.textProperty().addListener((observable, oldValue, newValue)->{
		if(valField.isDisabled() && !newValue.equals(""))
			valField.setDisable(false);
	});
	valField.textProperty().addListener((observable, oldValue, newValue)->{
		if(!valField.getText().equals(""))
			save.setDisable(false);
		else save.setDisable(true);
	});
	
	save.setOnAction((e)->{
		String newVal = valField.getText();
		String keyName = nameField.getText();
		Property.Type t = typeBox.getValue();
		System.out.println(t);
		System.out.println(newVal);
		
		cProp = new Property(keyName, t);
		if(!newProp(cProp, newVal))
			FlashFXUtils.showErrorDialog(this, "Error", "Value is incompatible with property type");
		else close();
	});
	cancel.setOnAction((e)->{
		cProp = null;
		close();
	});
	
	VBox viewerNode = new VBox();
	viewerNode.getChildren().addAll(nameField, valField, typeBox);
	viewerNode.setSpacing(10);
	viewerNode.setAlignment(Pos.CENTER);
	viewerNode.setPadding(new Insets(10, 10, 10, 10));
	HBox buttonNode = new HBox();
	buttonNode.getChildren().addAll(save, cancel);
	buttonNode.setSpacing(10);
	buttonNode.setAlignment(Pos.CENTER_RIGHT);
	buttonNode.setPadding(new Insets(0, 5, 5, 0));
	BorderPane pane = new BorderPane();
	pane.setBottom(buttonNode);
	pane.setCenter(viewerNode);
	setScene(new Scene(pane, 200, 200));
}
 
Example 11
Project: file-transfer   File: NetPane.java   Source Code and License Vote up 4 votes
private void createPathTextField() {
    pathTextField = new TextField();
    pathTextField.setPrefWidth(250);
    pathTextField.setPromptText("File path...");
}
 
Example 12
Project: WebPLP   File: CpuWindow.java   Source Code and License Vote up 3 votes
private VBox createConsoleTabContent()
{
	//TODO: Connect to backend
	VBox vbox = new VBox(10);
	
	Label title = new Label();
	title.setText("Debug Console (PLPSimCL)");
	title.setFont(Font.font("Arial", FontWeight.NORMAL, 12));
	
	TextArea consoleTextArea = new TextArea();
	consoleTextArea.setMinHeight(400);
	
	HBox interactionLine = new HBox(15);
	
	TextField executeStatement = new TextField();
	executeStatement.setPrefWidth(750);
	
	Button executeButton = new Button("Execute");
	Button clearButton = new Button("Clear");
	
	interactionLine.getChildren().addAll(executeStatement, executeButton, clearButton);
	
	vbox.getChildren().addAll(title, consoleTextArea, interactionLine);
	
	return vbox;
	
	
	
	
}