Java Code Examples for javafx.scene.control.TextArea#setFont()

The following examples show how to use javafx.scene.control.TextArea#setFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleCloudCredentialsAlert.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public void show()
{
	final Hyperlink hyperlink = new Hyperlink("Google Cloud SDK");
	hyperlink.setOnAction(e -> Paintera.getApplication().getHostServices().showDocument(googleCloudSdkLink));

	final TextArea area = new TextArea(googleCloudAuthCmd);
	area.setFont(Font.font("monospace"));
	area.setEditable(false);
	area.setMaxHeight(24);

	final TextFlow textFlow = new TextFlow(
			new Text("Please install "),
			hyperlink,
			new Text(" and then run this command to initialize the credentials:"),
			new Text(System.lineSeparator() + System.lineSeparator()),
			area);

	final Alert alert = PainteraAlerts.alert(Alert.AlertType.INFORMATION);
	alert.setHeaderText("Could not find Google Cloud credentials.");
	alert.getDialogPane().contentProperty().set(textFlow);
	alert.show();
}
 
Example 2
Source File: FileNamesComponent.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public FileNamesComponent(List<ExtensionFilter> filters) {

    this.filters = ImmutableList.copyOf(filters);

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

    txtFilename = new TextArea();
    txtFilename.setPrefColumnCount(40);
    txtFilename.setPrefRowCount(6);
    txtFilename.setFont(smallFont);

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

      fileChooser.getExtensionFilters().addAll(this.filters);

      String currentPaths[] = txtFilename.getText().split("\n");
      if (currentPaths.length > 0) {
        File currentFile = new File(currentPaths[0].trim());
        File currentDir = currentFile.getParentFile();
        if (currentDir != null && currentDir.exists())
          fileChooser.setInitialDirectory(currentDir);
      }

      // Open chooser.
      List<File> selectedFiles = fileChooser.showOpenMultipleDialog(null);
      if (selectedFiles == null)
        return;
      setValue(selectedFiles.toArray(new File[0]));
    });
    getChildren().addAll(txtFilename, btnFileBrowser);

  }
 
Example 3
Source File: CommandPane.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
private TextArea getTextArea ()
{
  TextArea textArea = new TextArea ();
  textArea.setEditable (false);
  textArea.setFont (Font.font ("Monospaced", 12));
  textArea.setPrefWidth (TEXT_WIDTH);
  return textArea;
}
 
Example 4
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public TextArea getTextArea(int width)
{
  TextArea textArea = new TextArea();
  textArea.setEditable(false);
  textArea.setFont(javafx.scene.text.Font.font("Monospaced", 12.0D));
  textArea.setPrefWidth(width);
  return textArea;
}
 
Example 5
Source File: FoxEatsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 5 votes vote down vote up
public LabelledRadiusPane getDisplayPane() {
    LabelledRadiusPane left = new LabelledRadiusPane("Input Phrases");
    lArea = new TextArea();
    lArea.setWrapText(true);
    lArea.setFont(Font.font("Helvetica", FontWeight.MEDIUM, 16));
    lArea.layoutYProperty().bind(left.labelHeightProperty().add(10));
    left.layoutBoundsProperty().addListener((v, o, n) -> {
        lArea.setLayoutX(10);
        lArea.setPrefWidth(n.getWidth() - 20);
        lArea.setPrefHeight(n.getHeight() - left.labelHeightProperty().get() - 20);
    });
    lArea.textProperty().addListener((v, o, n) -> {
        lArea.setScrollTop(Double.MAX_VALUE);
        lArea.setScrollLeft(Double.MAX_VALUE);
    });
    left.getChildren().add(lArea);
    
    String smallTabs = "\t\t\t\t\t\t\t";
    String bigTabs = "\t\t\t\t\t\t\t\t";
    demo.getPhraseEntryProperty().addListener((v, o, n) -> {
        Platform.runLater(() -> {
            lArea.appendText("\n" + n[0] + (n[0].length() > 4 ? smallTabs : bigTabs) + n[1] + "\t\t\t\t\t\t\t\t" + n[2]);
        });
    });
    
    demo.getPhraseEndedProperty().addListener((v, o, n) -> {
        Platform.runLater(() -> {
            lArea.appendText("\n\nWhat does a fox eat?");
        });
    });
    
    return left;
}
 
Example 6
Source File: CommandPane.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private TextArea getTextArea ()
{
  TextArea textArea = new TextArea ();
  textArea.setEditable (false);
  textArea.setFont (Font.font ("Monospaced", 12));
  textArea.setPrefWidth (TEXT_WIDTH);
  return textArea;
}
 
Example 7
Source File: MainFm.java    From tools-ocr with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
    public void start(Stage primaryStage) {
        stage = primaryStage;
        stageInfo = new StageInfo();
        stage.xProperty().addListener((observable, oldValue, newValue) -> {
            if (stage.getX() > 0){
                stageInfo.setX(stage.getX());
            }
        });
        stage.yProperty().addListener((observable, oldValue, newValue) -> {
            if (stage.getY() > 0){
                stageInfo.setY(stage.getY());
            }
        });
        screenCapture = new ScreenCapture(stage);
        processController = new ProcessController();
        initKeyHook();

//        ToggleGroup segmentGrp = new ToggleGroup();
//        ToggleButton resetBtn = CommUtils.createToggleButton(segmentGrp, "resetBtn", this::resetText, "重置");
//        ToggleButton segmentBtn = CommUtils.createToggleButton(segmentGrp, "segmentBtn", this::segmentText, "智能分段");
//        resetBtn.setUserData("resetBtn");
//        segmentBtn.setUserData("segmentBtn");
//
//        segmentGrp.selectToggle(segmentBtn);
//        segmentGrp.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
//            isSegment = newValue.getUserData().toString().equals("segmentBtn");
//        });

        HBox topBar = new HBox(
                CommUtils.createButton("snapBtn", MainFm::doSnap, "截图"),
                CommUtils.createButton("openImageBtn", MainFm::recImage, "打开"),
                CommUtils.createButton("copyBtn", this::copyText, "复制"),
                CommUtils.createButton("pasteBtn", this::pasteText, "粘贴"),
                CommUtils.createButton("clearBtn", this::clearText, "清空"),
                CommUtils.createButton("wrapBtn", this::wrapText, "换行")
                //CommUtils.SEPARATOR, resetBtn, segmentBtn
        );
        topBar.setId("topBar");
        topBar.setMinHeight(40);
        topBar.setSpacing(8);
        topBar.setPadding(new Insets(6, 8, 6, 8));

        textArea = new TextArea();
        textArea.setId("ocrTextArea");
        textArea.setWrapText(true);
        textArea.setBorder(new Border(new BorderStroke(Color.DARKGRAY, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
        textArea.setFont(Font.font("Arial", FontPosture.REGULAR, 14));

        ToolBar footerBar = new ToolBar();
        footerBar.setId("statsToolbar");
        Label statsLabel = new Label();
        SimpleStringProperty statsProperty = new SimpleStringProperty("总字数:0");
        textArea.textProperty().addListener((observable, oldValue, newValue) -> statsProperty.set("总字数:" + newValue.replaceAll(CommUtils.SPECIAL_CHARS, "").length()));
        statsLabel.textProperty().bind(statsProperty);
        footerBar.getItems().add(statsLabel);
        BorderPane root = new BorderPane();
        root.setTop(topBar);
        root.setCenter(textArea);
        root.setBottom(footerBar);
        root.getStylesheets().addAll(
                getClass().getResource("/css/main.css").toExternalForm()
        );
        CommUtils.initStage(primaryStage);
        mainScene = new Scene(root, 670, 470);
        stage.setScene(mainScene);
        stage.show();
    }
 
Example 8
Source File: BreakingNewsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 4 votes vote down vote up
public DualPanel createInputPane() {
    DualPanel retVal = new DualPanel();
    
    LabelledRadiusPane left = new LabelledRadiusPane("Input Tweet");
    TextArea lArea = new TextArea();
    lArea.setWrapText(true);
    lArea.setFont(Font.font("Helvetica", FontWeight.MEDIUM, 16));
    lArea.layoutYProperty().bind(left.labelHeightProperty().add(10));
    left.layoutBoundsProperty().addListener((v, o, n) -> {
        lArea.setLayoutX(10);
        lArea.setPrefWidth(n.getWidth() - 20);
        lArea.setPrefHeight(n.getHeight() - left.labelHeightProperty().get() - 20);
    });
    
    Label queueLabel = new Label("Processing Queue Size:");
    queueLabel.layoutXProperty().bind(lArea.widthProperty().subtract(queueLabel.getLayoutBounds().getWidth() + 330));
    queueLabel.setLayoutY(lArea.getLayoutY() - queueLabel.getLayoutBounds().getHeight() - 35);
    queueLabel.setFont(Font.font("Helvetica", FontWeight.BOLD, 12));
    queueLabel.setTextFill(Color.rgb(00, 70, 107));
    queueDisplayProperty.set(queueLabel);
    
    Label curLabel = new Label("Current Tweet:");
    curLabel.layoutXProperty().bind(lArea.widthProperty().subtract(curLabel.getLayoutBounds().getWidth() + 110));
    curLabel.setLayoutY(lArea.getLayoutY() - curLabel.getLayoutBounds().getHeight() - 35);
    curLabel.setFont(Font.font("Helvetica", FontWeight.BOLD, 12));
    curLabel.setTextFill(Color.rgb(00, 70, 107));
    currentLabelProperty.set(curLabel.textProperty());
    
    left.getChildren().addAll(lArea, queueLabel, curLabel);
    
    LabelledRadiusPane right = new LabelledRadiusPane("Scrubbed Tweet");
    TextArea rArea = new TextArea();
    rArea.setWrapText(true);
    rArea.setFont(Font.font("Helvetica", FontWeight.MEDIUM, 16));
    rArea.layoutYProperty().bind(right.labelHeightProperty().add(10));
    right.layoutBoundsProperty().addListener((v, o, n) -> {
        rArea.setLayoutX(10);
        rArea.setPrefWidth(n.getWidth() - 20);
        rArea.setPrefHeight(n.getHeight() - right.labelHeightProperty().get() - 20);
    });
    right.getChildren().add(rArea);
    
    retVal.setLeftPane(left);
    retVal.setRightPane(right);
    
    inputPaneProperty.set(new Pair<>(lArea, rArea));
    
    return retVal;
}