Java 类javafx.scene.control.TextAreaBuilder 实例源码

项目:openjfx-8u-dev-tests    文件:ColorHelper.java   
@Override
public void start(final Stage stage) throws Exception {
    final TextField xField = TextFieldBuilder.create().promptText("x").build();
    final TextField yField = TextFieldBuilder.create().promptText("y").build();

    final TextArea awtField = TextAreaBuilder.create().promptText("awt").build();
    final TextArea glassField = TextAreaBuilder.create().promptText("glass").build();

    Button act = new Button("Get colors");
    act.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            try {
                int x = Integer.parseInt(xField.getText());
                int y = Integer.parseInt(yField.getText());

                stage.setX(x + 1);
                stage.setY(y + 1);

                java.awt.Robot robotAwt = new java.awt.Robot();
                com.sun.glass.ui.Robot robotGlass = new GetAction<com.sun.glass.ui.Robot>() {
                    @Override
                    public void run(Object... os) throws Exception {
                        setResult(com.sun.glass.ui.Application.GetApplication().createRobot());
                    }
                }.dispatch(Root.ROOT.getEnvironment());

                java.awt.Color glassColor = new java.awt.Color(robotGlass.getPixelColor((int) Math.round(x), (int) Math.round(y)));
                java.awt.Color awtColor = robotAwt.getPixelColor((int) Math.round(x), (int) Math.round(y));

                awtField.setText("AWT robot " + getColorDescription(awtColor));
                glassField.setText("Glass robot " + getColorDescription(glassColor));
            } catch (Throwable ex) {
                ex.printStackTrace();
            }
        }
    });

    stage.initStyle(StageStyle.UNDECORATED);
    stage.setScene(new Scene(new VBox(5, xField, yField, act, awtField, glassField)));
    stage.show();
}
项目:openjfx-8u-dev-tests    文件:AnimationLCDTextTestApp.java   
@Override
public void start(Stage primaryStage) {


    final TextArea testText = TextAreaBuilder.create()
            .text("Test")
            .prefHeight(50)
            .prefWidth(500)
            .build();

    final ChoiceBox<Interpolator> interpolatorChoiceBox = new ChoiceBox<Interpolator>();
    interpolatorChoiceBox.getItems().addAll(FXCollections.observableArrayList(
                Interpolator.LINEAR,
                Interpolator.DISCRETE,
                Interpolator.EASE_BOTH,
                Interpolator.EASE_IN,
                Interpolator.EASE_OUT
                ));
    interpolatorChoiceBox.setPrefHeight(25);
    interpolatorChoiceBox.setPrefWidth(500);

    interpolatorChoiceBox.getSelectionModel().selectFirst();


    final Text lcdText = TextBuilder.create()
            .x(100)
            .y(100)
            .fontSmoothingType(FontSmoothingType.LCD)
            .build();

    lcdText.textProperty().bind(testText.textProperty());

    final Circle point = CircleBuilder.create()
            .centerX(100)
            .centerY(100)
            .radius(2)
            .fill(Color.RED)
            .build();

    Pane root = VBoxBuilder.create()
            .children(
                PaneBuilder.create()
                .minWidth(500)
                .minHeight(500)
                .children(
                    lcdText,
                    point)
                .onMouseClicked(new EventHandler<MouseEvent>() {

                    @Override
                    public void handle(MouseEvent event) {
                        point.setCenterX(event.getX());
                        point.setCenterY(event.getY());

                        TimelineBuilder.create()
                            .keyFrames(
                                new KeyFrame(Duration.seconds(5),
                                    new KeyValue(lcdText.xProperty(), event.getX(),
                                        interpolatorChoiceBox.getSelectionModel().getSelectedItem())),
                                new KeyFrame(Duration.seconds(5),
                                    new KeyValue(lcdText.yProperty(), event.getY(),
                                        interpolatorChoiceBox.getSelectionModel().getSelectedItem()))
                                )
                            .build()
                            .play();
                    }
                })
                .build(),
                testText,
                interpolatorChoiceBox)
            .build();



    Scene scene = new Scene(root, 500, 575);

    primaryStage.setTitle("Test Animnation LCD Text");
    primaryStage.setResizable(false);
    primaryStage.setScene(scene);
    primaryStage.show();
}
项目:gobs-program    文件:JavaFx.java   
@Override
public void start(Stage stage) throws Exception {

  final TextArea textArea = TextAreaBuilder.create()
      .prefWidth(WIDTH)
      .prefHeight(HEIGHT)
      .wrapText(true) 
      .id("terminal")
      .text("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nGob's Program: Y/N?\n? ")        
      .build();


  textArea.positionCaret(999);

  textArea.setOnKeyReleased(new EventHandler<KeyEvent>() {
    @Override 
    public void handle(KeyEvent keyEvent) {                

      textArea.setText(textArea.getText(0, textArea.getText().length() - 1));
      textArea.positionCaret(999);

      String input = keyEvent.getCode().getName().toUpperCase();

      if("Y".equals(input) ||
         "N".equals(input)) {

        // Trying to replace lower case input with upper case.
        textArea.appendText(input + "\n");

        new Thread(new Runnable() {

          @Override public void run() {
            while(true) {             

              // This little delay helps create the scrolling effect.                
              try { Thread.sleep(50); } catch(InterruptedException e) {}

              textArea.appendText(PENUS + "\n");
            }
          }

        }).start();

      }
      else {          
        textArea.positionCaret(999);
      }

    }
  });

  StackPane root = new StackPane();

  root.getChildren().add(textArea);

  Scene scene = new Scene(root, WIDTH, HEIGHT);
  scene.getStylesheets().add(
      JavaFx.class.getResource("gobs-program.css").toExternalForm());

  stage.setTitle("Gob's Program");    
  stage.setScene(scene);    
  stage.show();

}
项目:Pruebas    文件:JavaFX_OpenFile.java   
@Override
public void start(final Stage primaryStage) {
    primaryStage.setTitle("java-buddy.blogspot.com");
    Group root = new Group();



    final TextArea textArea = TextAreaBuilder.create()
            .prefWidth(400)
            .wrapText(true)
            .build();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(textArea);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefWidth(400);
    scrollPane.setPrefHeight(180);

    Button buttonLoad = new Button("Load");
    buttonLoad.setOnAction(new EventHandler<ActionEvent>(){

        @Override
        public void handle(ActionEvent arg0) {
            FileChooser fileChooser = new FileChooser();

            //Set extension filter
            FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");
            fileChooser.getExtensionFilters().add(extFilter);

            //Show save file dialog
            File file = fileChooser.showOpenDialog(primaryStage);
            if(file != null){
                textArea.setText(readFile(file));
            }
        }

    });

    VBox vBox = VBoxBuilder.create()
            .children(buttonLoad, scrollPane)
            .build();

    root.getChildren().add(vBox);
    primaryStage.setScene(new Scene(root, 500, 400));
    primaryStage.show();
}