javafx.scene.control.TextField#setPrefColumnCount ( )源码实例Demo

下面列出了javafx.scene.control.TextField#setPrefColumnCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mzmine3   文件: ListDoubleRangeComponent.java
public ListDoubleRangeComponent() {
  inputField = new TextField();
  inputField.setPrefColumnCount(16);
  /*
   * inputField.getDocument().addDocumentListener(new DocumentListener() {
   * 
   * @Override public void changedUpdate(DocumentEvent e) { update(); }
   * 
   * @Override public void removeUpdate(DocumentEvent e) { update(); }
   * 
   * @Override public void insertUpdate(DocumentEvent e) { update(); } });
   */

  textField = new Label();
  // textField.setColumns(8);

  add(inputField, 0, 0);
  add(textField, 0, 1);
}
 
源代码2 项目: mzmine3   文件: ListDoubleComponent.java
public ListDoubleComponent() {
  inputField = new TextField();
  inputField.setPrefColumnCount(16);

  /*
   * inputField.getDocument().addDocumentListener(new DocumentListener() {
   * 
   * @Override public void changedUpdate(DocumentEvent e) { update(); }
   * 
   * @Override public void removeUpdate(DocumentEvent e) { update(); }
   * 
   * @Override public void insertUpdate(DocumentEvent e) { update(); } });
   */

  textField = new Label();
  // textField.setColumns(8);

  add(inputField, 0, 0);
  add(textField, 0, 1);
}
 
源代码3 项目: Lipi   文件: TomlEntryEditor.java
private void initValueTextControl(String value) {

        if (value.length() > 30) {
            TextArea valueTextArea = new TextArea(value);
            valueTextArea.setPrefColumnCount(16);

            int cols = value.length() / 30;
            valueTextArea.setPrefRowCount(cols);
//            valueTextArea.prefHeight(20);
            valueTextArea.setWrapText(true);
            valueTextControl = valueTextArea;
        } else {
            TextField valueTextField = new TextField(value);
            valueTextField.setPrefColumnCount(18);
            valueTextControl = valueTextField;

        }

    }
 
源代码4 项目: FxDock   文件: DemoPane.java
private static void a(Pane p, int gap, double ... specs)
{
	HPane hp = new HPane(2);
	int ix = 0;
	for(double w: specs)
	{
		Color c = Color.gray(0.5 + 0.5 * ix / (specs.length - 1));
		String text = DemoTools.spec(w);
		TextField t = new TextField(text);
		t.setEditable(false);
		t.setPrefColumnCount(3);
		t.setBackground(FX.background(c));
		t.setPadding(Insets.EMPTY);
		hp.add(t, w);
		ix++;
	}
	p.getChildren().add(hp);
}
 
源代码5 项目: mzmine3   文件: DirectoryComponent.java
/**
 * Create the component.
 */
public DirectoryComponent() {

  // Create text field.
  txtDirectory = new TextField();
  txtDirectory.setPrefColumnCount(TEXT_FIELD_COLUMNS);
  txtDirectory.setFont(SMALL_FONT);

  // Chooser button.
  final Button btnFileBrowser = new Button("...");
  btnFileBrowser.setOnAction(e -> {
    // Create chooser.
    DirectoryChooser fileChooser = new DirectoryChooser();
    fileChooser.setTitle(TITLE);

    // Set current directory.
    final String currentPath = txtDirectory.getText();
    if (currentPath.length() > 0) {

      final File currentFile = new File(currentPath);
      final File currentDir = currentFile.getParentFile();
      if (currentDir != null && currentDir.exists()) {
        fileChooser.setInitialDirectory(currentDir);
      }
    }

    // Open chooser.
    File selectedFile = fileChooser.showDialog(null);
    if (selectedFile == null)
      return;
    txtDirectory.setText(selectedFile.getPath());

  });

  setCenter(txtDirectory);
  setRight(btnFileBrowser);
}
 
源代码6 项目: mzmine3   文件: MassListComponent.java
public MassListComponent() {

    setHgap(5.0);

    lookupMenu = new ContextMenu();

    nameField = new TextField();
    nameField.setPrefColumnCount(15);

    lookupButton = new Button("Choose...");
    lookupButton.setOnAction(e -> {
      List<String> currentNames = getMassListNames();

      lookupMenu.getItems().clear();
      for (String name : currentNames) {
        MenuItem item = new MenuItem(name);
        item.setOnAction(e2 -> {
          nameField.setText(name);
        });
        lookupMenu.getItems().add(item);
      }
      final Bounds boundsInScreen = lookupButton.localToScreen(lookupButton.getBoundsInLocal());
      lookupMenu.show(lookupButton, boundsInScreen.getCenterX(), boundsInScreen.getCenterY());
//      lookupMenu.show(lookupButton, 0, 0);
    });

    getChildren().addAll(nameField, lookupButton);

  }
 
源代码7 项目: mzmine3   文件: NeutralMassComponent.java
public NeutralMassComponent() {

    add(new Label("m/z:"), 0, 0);

    ionMassField = new TextField();
    ionMassField.textProperty().addListener((observable, oldValue, newValue) -> {
      updateNeutralMass();
    });
    ionMassField.setPrefColumnCount(8);
    add(ionMassField, 1, 0);

    add(new Label("Charge:"), 2, 0);

    chargeField = new TextField();
    chargeField.textProperty().addListener((observable, oldValue, newValue) -> {
      updateNeutralMass();
    });
    chargeField.setPrefColumnCount(2);
    add(chargeField, 3, 0);

    add(new Label("Ionization type:"), 0, 1, 2, 1);
    ionTypeCombo =
        new ComboBox<IonizationType>(FXCollections.observableArrayList(IonizationType.values()));
    ionTypeCombo.setOnAction(e -> {
      updateNeutralMass();
    });
    add(ionTypeCombo, 2, 1, 2, 1);

    add(new Label("Calculated mass:"), 0, 2, 2, 1);

    neutralMassField = new TextField();
    neutralMassField.setPrefColumnCount(8);
    neutralMassField.setStyle("-fx-background-color: rgb(192, 224, 240);");
    neutralMassField.setEditable(false);
    add(neutralMassField, 2, 2, 2, 1);

  }
 
源代码8 项目: mzmine3   文件: StringParameter.java
@Override
public TextField createEditingComponent() {
  TextField stringComponent = new TextField();
  stringComponent.setPrefColumnCount(inputsize);
  // stringComponent.setBorder(BorderFactory.createCompoundBorder(stringComponent.getBorder(),
  // BorderFactory.createEmptyBorder(0, 4, 0, 0)));
  return stringComponent;
}
 
源代码9 项目: HubTurbo   文件: PanelMenuBar.java
/**
 * Called in FilterPanel.java when the ShowRenamePanelEventHandler is invoked.
 * A renameableTextField is generated in which the user inputs the new panel name.
 */
public void initRenameableTextFieldAndEvents() {
    renameableTextField = new TextField();
    renameableTextField.setId(IdGenerator.getPanelRenameTextFieldId(panel.panelIndex));
    Platform.runLater(() -> {
        renameableTextField.requestFocus();
        renameableTextField.selectAll();
    });
    renameableTextField.setText(panelName);
    augmentRenameableTextField();
    buttonAndKeyboardEventHandler();
    renameableTextField.setPrefColumnCount(30);
}
 
源代码10 项目: Intro-to-Java-Programming   文件: Exercise_18_36.java
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	SierpinskiTrianglePane trianglePane = new SierpinskiTrianglePane();
	TextField tfOrder = new TextField();
	tfOrder.setOnAction(
		e -> trianglePane.setOrder(Integer.parseInt(tfOrder.getText())));
	tfOrder.setPrefColumnCount(4);
	tfOrder.setAlignment(Pos.BOTTOM_RIGHT);

	// Pane to hold label, text field, and a button
	HBox hBox = new HBox(10);
	hBox.getChildren().addAll(new Label("Enter an order: "), tfOrder);
	hBox.setAlignment(Pos.CENTER);

	BorderPane borderPane = new BorderPane();
	borderPane.setCenter(trianglePane);
	borderPane.setBottom(hBox);

	// Create a scene and place it in the stage
	Scene scene = new Scene(borderPane, 200, 210);
	primaryStage.setTitle("Exercise_18_36"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage

	scene.widthProperty().addListener(ov -> trianglePane.paint());
	scene.heightProperty().addListener(ov -> trianglePane.paint());
}
 
源代码11 项目: Intro-to-Java-Programming   文件: Exercise_14_07.java
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a GridPane and set its properties
	GridPane pane = new GridPane();
	pane.setPadding(new Insets(5, 5, 5, 5));
	pane.setHgap(5);
	pane.setVgap(5);

	// Place text fields containing a centered, 
	// randomly generated string of 0 or 1 in the pane
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			TextField text = new TextField();
			text.setPrefColumnCount(1);
			text.setText(String.valueOf((int)(Math.random() * 2)));
			pane.add(text, i, j);
			pane.setHalignment(text, HPos.CENTER);
			pane.setValignment(text, VPos.CENTER);
		}
	}

	// Create a scene and plane it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_14_07"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
源代码12 项目: mzmine3   文件: FileNameComponent.java
public FileNameComponent(int textfieldcolumns, List<File> lastFiles, FileSelectionType type) {
  // setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));

  this.type = type;

  txtFilename = new TextField();
  txtFilename.setPrefColumnCount(textfieldcolumns);
  txtFilename.setFont(smallFont);

  // last used files chooser button
  // on click - set file name to textField
  btnLastFiles = new LastFilesButton("last", file -> txtFilename.setText(file.getPath()));

  Button btnFileBrowser = new Button("...");
  btnFileBrowser.setOnAction(e -> {
    // Create chooser.
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select file");

    // Set current directory.
    final String currentPath = txtFilename.getText();
    if (currentPath.length() > 0) {

      final File currentFile = new File(currentPath);
      final File currentDir = currentFile.getParentFile();
      if (currentDir != null && currentDir.exists()) {
        fileChooser.setInitialDirectory(currentDir);
      }
    }

    // Open chooser.
    File selectedFile = null;
    if(type == FileSelectionType.OPEN)
      selectedFile = fileChooser.showOpenDialog(null);
    else
      selectedFile = fileChooser.showSaveDialog(null);
    
    if (selectedFile == null)
      return;
    txtFilename.setText(selectedFile.getPath());
  });

  getChildren().addAll(txtFilename, btnLastFiles, btnFileBrowser);

  setLastFiles(lastFiles);
}
 
源代码13 项目: mzmine3   文件: DoubleRangeComponent.java
public DoubleRangeComponent(NumberFormat format) {

    setSpacing(8.0);

    minTxtField = new TextField();
    minTxtField.setPrefColumnCount(8);
    // minTxtField.setMinWidth(100.0);

    maxTxtField = new TextField();
    maxTxtField.setPrefColumnCount(8);
    // maxTxtField.setMinWidth(100.0);

    minusLabel = new Label(" - ");
    minusLabel.setMinWidth(15.0);

    getChildren().addAll(minTxtField, minusLabel, maxTxtField);

    setMinWidth(600.0);
    // setStyle("-fx-border-color: red");

    setNumberFormat(format);
  }
 
源代码14 项目: WorkbenchFX   文件: WebModule.java
public WebModule(String name, MaterialDesignIcon icon, String url) {
  super(name, icon);
  this.url = url;

  // setup webview
  browser = new WebView();
  webEngine = browser.getEngine();

  // workaround since HTTP headers related to CORS, are restricted, see: https://bugs.openjdk.java.net/browse/JDK-8096797
  System.setProperty("sun.net.http.allowRestrictedHeaders", "true");

  // setup textfield for URL
  browserUrl = new TextField("Loading...");
  HBox.setHgrow(browserUrl, Priority.ALWAYS);
  browserUrl.setPrefColumnCount(Integer.MAX_VALUE); // make sure textfield takes up rest of space
  browserUrl.setEditable(false);

  // setup toolbar
  ToolbarItem back = new ToolbarItem(new MaterialDesignIconView(MaterialDesignIcon.CHEVRON_LEFT),
      event -> webEngine.executeScript("history.back()"));
  ToolbarItem forward = new ToolbarItem(new MaterialDesignIconView(MaterialDesignIcon.CHEVRON_RIGHT),
      event -> webEngine.executeScript("history.forward()"));
  ToolbarItem home = new ToolbarItem(new MaterialDesignIconView(MaterialDesignIcon.HOME),
      event -> webEngine.load(url));
  ToolbarItem reload = new ToolbarItem(new MaterialDesignIconView(MaterialDesignIcon.REFRESH),
      event -> webEngine.reload());
  getToolbarControlsLeft().addAll(back, forward, home, reload, new ToolbarItem(browserUrl));

  ToolbarItem increaseSize = new ToolbarItem(new Group(increaseFontIcon),
      event -> browser.setFontScale(browser.getFontScale() + FONT_SCALE_INCREMENT));
  ToolbarItem decreaseSize = new ToolbarItem(new Group(decreaseFontIcon),
      event -> browser.setFontScale(browser.getFontScale() - FONT_SCALE_INCREMENT));
  getToolbarControlsRight().addAll(increaseSize, decreaseSize);

  // update textfield with url every time the url of the webview changes
  webEngine.documentProperty().addListener(
      observable -> {
        Document document = webEngine.getDocument();
        if (!Objects.isNull(document) &&
            !Strings.isNullOrEmpty(document.getDocumentURI())) {
          browserUrl.setText(document.getDocumentURI());
        }
      });
}
 
源代码15 项目: phoebus   文件: Palette.java
/** Create UI elements
 *  @return Top-level Node of the UI
 */
@SuppressWarnings("unchecked")
public Node create()
{
    final VBox palette = new VBox();

    final Map<WidgetCategory, Pane> palette_groups = createWidgetCategoryPanes(palette);
    groups = palette_groups.values();
    createWidgetEntries(palette_groups);

    final ScrollPane palette_scroll = new ScrollPane(palette);
    palette_scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    palette_scroll.setFitToWidth(true);

    // TODO Determine the correct size for the main node
    // Using 2*PREFERRED_WIDTH was determined by trial and error
    palette_scroll.setMinWidth(PREFERRED_WIDTH + 12);
    palette_scroll.setPrefWidth(PREFERRED_WIDTH);

    // Copy the widgets, i.e. the children of each palette_group,
    // to the userData.
    // Actual children are now updated based on search by widget name
    palette_groups.values().forEach(group -> group.setUserData(new ArrayList<Node>(group.getChildren())));

    final TextField searchField = new ClearingTextField();
    searchField.setPromptText(Messages.SearchTextField);
    searchField.setTooltip(new Tooltip(Messages.WidgetFilterTT));
    searchField.setPrefColumnCount(9);
    searchField.textProperty().addListener( ( observable, oldValue, search_text ) ->
    {
        final String search = search_text.toLowerCase().trim();
        palette_groups.values().stream().forEach(group ->
        {
            group.getChildren().clear();
            final List<Node> all_widgets = (List<Node>)group.getUserData();
            if (search.isEmpty())
                group.getChildren().setAll(all_widgets);
            else
                group.getChildren().setAll(all_widgets.stream()
                                                      .filter(node ->
                                                      {
                                                         final String text = ((ToggleButton) node).getText().toLowerCase();
                                                         return text.contains(search);
                                                      })
                                                     .collect(Collectors.toList()));
        });
    });
    HBox.setHgrow(searchField, Priority.NEVER);

    final HBox toolsPane = new HBox(6);
    toolsPane.setAlignment(Pos.CENTER_RIGHT);
    toolsPane.setPadding(new Insets(6));
    toolsPane.getChildren().add(searchField);

    BorderPane paletteContainer = new BorderPane();
    paletteContainer.setTop(toolsPane);
    paletteContainer.setCenter(palette_scroll);

    return paletteContainer;
}
 
源代码16 项目: Intro-to-Java-Programming   文件: Exercise_16_15.java
@Override // Override the start method in the Appliction class
public void start(Stage primaryStage) {
	// Set properties for combobox
	cbo.getItems().addAll("TOP", "BOTTOM", "LEFT", "RIGHT");
	cbo.setStyle("-fx-color: green");
	cbo.setValue("LEFT");

	// Create a text field
	TextField tfGap = new TextField("0");
	tfGap.setPrefColumnCount(3);

	// Create a hox to hold labels a text field and combo box
	HBox paneForSettings = new HBox(10);
	paneForSettings.setAlignment(Pos.CENTER);
	paneForSettings.getChildren().addAll(new Label("contentDisplay:"),
		cbo, new Label("graphicTextGap:"), tfGap);

	// Create an imageview
	ImageView image = new ImageView(new Image("image/grapes.gif"));

	// Label the image
	Label lblGrapes = new Label("Grapes", image);
	lblGrapes.setGraphicTextGap(0);

	// Place the image and its label in a stack pane
	StackPane paneForImage = new StackPane(lblGrapes);

	// Create and register handlers
	cbo.setOnAction(e -> {
		lblGrapes.setContentDisplay(setDisplay());
	});

	tfGap.setOnAction(e -> {
		lblGrapes.setGraphicTextGap(Integer.parseInt(tfGap.getText()));
	});

	// Place nodes in a border pane
	BorderPane pane = new BorderPane();
	pane.setTop(paneForSettings);
	pane.setCenter(paneForImage);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 400, 200);
	primaryStage.setTitle("Exericse_16_15"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
源代码17 项目: mzmine3   文件: IntRangeComponent.java
public IntRangeComponent() {

    // setBorder(BorderFactory.createEmptyBorder(0, 9, 0, 0));

    minTxtField = new TextField();
    minTxtField.setPrefColumnCount(8);

    maxTxtField = new TextField();
    maxTxtField.setPrefColumnCount(8);


    add(minTxtField, 0, 0);
    add(new Label(" - "), 1, 0);
    add(maxTxtField, 2, 0);
  }
 
源代码18 项目: mzmine3   文件: PercentComponent.java
public PercentComponent() {

    // setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
    percentField = new TextField();
    percentField.setPrefColumnCount(4);

    getChildren().addAll(percentField, new Label("%"));

  }
 
源代码19 项目: mzmine3   文件: MZToleranceComponent.java
public MZToleranceComponent() {

    // setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));

    mzToleranceField = new TextField();
    mzToleranceField.setPrefColumnCount(12);


    ppmToleranceField = new TextField();
    ppmToleranceField.setPrefColumnCount(6);

    getChildren().addAll(mzToleranceField, new Label("m/z  or"), ppmToleranceField,
        new Label("ppm"));
  }
 
源代码20 项目: mzmine3   文件: RTToleranceComponent.java
public RTToleranceComponent() {



    // setBorder(BorderFactory.createEmptyBorder(0, 9, 0, 0));

    toleranceField = new TextField();
    toleranceField.setPrefColumnCount(6);

    toleranceType = new ComboBox<String>(toleranceTypes);

    setCenter(toleranceField);
    setRight(toleranceType);

  }