@Override public void start(Stage primaryStage) { Label inputLabel = new Label("Input"); TextArea input = new TextArea(); input.setFont(MONOSPACE_FONT); setSize(input, INPUT_WIDTH, INPUT_HEIGHT); Label outputLabel = new Label("Output"); TextArea output = new TextArea(); output.setEditable(false); output.setFont(MONOSPACE_FONT); setSize(output, OUTPUT_WIDTH, OUTPUT_HEIGHT); TextArea codeArea = new TextArea(); codeArea.setFont(MONOSPACE_FONT); setSize(codeArea, EDITOR_WIDTH, EDITOR_HEIGHT); Button runButton = new Button("Run"); runButton.setOnAction( e -> { try { output.setText(new A_RayCode(codeArea.getText(), input.getText()).runAndGetOutput()); } catch (RuntimeException exception) { output.setText("Error"); exception.printStackTrace(); } }); Button clearOutput = new Button("Clear Output"); clearOutput.setOnAction( e -> { output.setText(""); }); HBox buttonPane = new HBox(); buttonPane.setSpacing(PANE_SPACING); buttonPane.setAlignment(Pos.CENTER_RIGHT); buttonPane.getChildren().addAll(clearOutput, runButton); VBox mainPane = new VBox(); mainPane.setPadding(MAIN_PANE_INSETS); mainPane.setSpacing(PANE_SPACING); mainPane.getChildren().addAll(codeArea, buttonPane, inputLabel, input, outputLabel, output); BorderPane content = new BorderPane(mainPane); Scene scene = new Scene(content, WIDTH, HEIGHT); primaryStage.setScene(scene); primaryStage.setResizable(false); primaryStage.show(); }
@Override public void start(Stage primaryStage) { primaryStage.setTitle("CoAP Explorer"); Group root = new Group(); Scene scene = new Scene(root, 800, 600); TextArea hexArea = new TextArea(); TextArea binArea = new TextArea(); CoapPacket packet = new CoapPacket(); packet.setPayload("PAYLOAD"); packetProp.setValue(packet); binArea.textProperty().bindBidirectional(packetProp, new AsciiConverter()); hexArea.textProperty().bindBidirectional(packetProp, new HexConverter()); hexArea.setEditable(false); hexArea.setFont(javafx.scene.text.Font.font(Font.MONOSPACED)); VBox vbox = new VBox(); vbox.setPadding(new Insets(10)); vbox.setSpacing(8); VBox.setMargin(hexArea, new Insets(0, 0, 0, 8)); vbox.getChildren().add(hexArea); VBox.setMargin(binArea, new Insets(0, 0, 0, 8)); vbox.getChildren().add(binArea); root.getChildren().add(vbox); primaryStage.setScene(scene); primaryStage.show(); }
@FXML private void handleAction(ActionEvent event) { TextArea textarea = (TextArea) menuBar.getScene().lookup("#textarea"); if (event.getSource() == chmiWordWrap) { wordWrapOn = chmiWordWrap.isSelected(); textarea.setWrapText(wordWrapOn); } else if (event.getSource() == miChangeCase) { try { if (changeCaseDialog == null) { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ChangeCaseDialog.fxml")); Parent root = fxmlLoader.load(); controller = fxmlLoader.getController(); controller.setSelectedCase(prefs.get(strSelectedCase, "UPPERCASE")); changeCaseDialog = new Stage(); changeCaseDialog.setResizable(false); changeCaseDialog.initStyle(StageStyle.UTILITY); changeCaseDialog.setAlwaysOnTop(true); changeCaseDialog.setX(prefs.getDouble(strChangeCaseX, changeCaseDialog.getX())); changeCaseDialog.setY(prefs.getDouble(strChangeCaseY, changeCaseDialog.getY())); Scene scene = new Scene(root); changeCaseDialog.setScene(scene); changeCaseDialog.setTitle("Change Case"); } changeCaseDialog.toFront(); changeCaseDialog.show(); } catch (Exception e) { } } else if (event.getSource() == miRemoveLineBreaks) { if (textarea.getSelectedText().length() == 0) { textarea.selectAll(); if (textarea.getSelectedText().length() == 0) { return; } } String result = TextUtilities.removeLineBreaks(textarea.getSelectedText()); int start = textarea.getSelection().getStart(); textarea.replaceSelection(result); textarea.selectRange(start, start + result.length()); } else if (event.getSource() == miFont) { Font font = textarea.getFont(); FontSelectorDialog dialog = new FontSelectorDialog(font); Optional<Font> op = dialog.showAndWait(); if (op.isPresent()) { textarea.setFont(op.get()); } } }
public SaveDialog(final Stage stg, String text) { width = 300; height = 100; final Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(stg); stage.setTitle("提示框"); Group root = new Group(); AnchorPane anchorPane = new AnchorPane(); area = new TextArea(); area.setFont(new Font(30)); area.setEditable(false); area.setWrapText(true); area.setPrefWidth(width); area.setPrefHeight(height); System.out.println(area.getWidth()); System.out.println(area.getHeight()); Scene scene = new Scene(root, width, height); area.setText(text); anchorPane.getChildren().add(area); root.getChildren().add(anchorPane); stage.setScene(scene); stage.show(); }