List of usage examples for javafx.scene.text Text Text
public Text(String text)
From source file:de.micromata.mgc.javafx.launcher.gui.AboutDialogController.java
@Override public void initializeWithModel() { MgcApplicationInfo ai = model.getApplicationInfo(); AnchorPane.setTopAnchor(aboutLogoPanel, 2.0); AnchorPane.setRightAnchor(aboutLogoPanel, 2.0); AnchorPane.setLeftAnchor(aboutLogoPanel, 2.0); AnchorPane.setTopAnchor(aboutLogoPanel, 2.0); AnchorPane.setRightAnchor(licensePanel, 2.0); AnchorPane.setLeftAnchor(licensePanel, 2.0); AnchorPane.setRightAnchor(licenceTextArea, 5.0); AnchorPane.setLeftAnchor(licenceTextArea, 2.0); // AnchorPane.setTopAnchor(licensePanel, 100.0); // AnchorPane.setBottomAnchor(configurationTabs, 5.0); AnchorPane.setRightAnchor(buttonPanel, 2.0); AnchorPane.setLeftAnchor(buttonPanel, 2.0); AnchorPane.setBottomAnchor(buttonPanel, 2.0); okButton.setOnAction(event -> getStage().close()); String name = ai.getName() + " " + ai.getVersion(); Text text1 = new Text(name); text1.setFont(Font.font("Verdana", FontWeight.BOLD, 20)); Text text2 = new Text("\n\n" + ai.getCopyright() + "\n"); TextFlow apptext = new TextFlow(text1, text2); appInfo.getChildren().add(apptext);//from ww w . j a v a 2 s.c o m if (ai.getLogoLargePath() != null) { logo.setImage(new Image(this.getClass().getResource(ai.getLogoLargePath()).toString())); } String sdetailText = ai.getDetailInfo(); if (StringUtils.isNotBlank(ai.getLicense()) == true) { sdetailText += "\n\nLicense: " + ai.getLicense(); } TextFlow detailText = new TextFlow(); detailText.getChildren().add(new Text(sdetailText)); if (StringUtils.isNotBlank(ai.getHomeUrl()) == true) { detailText.getChildren().add(new Text("\n\nHomepage: ")); Hyperlink hlink = new Hyperlink(ai.getHomeUrl()); hlink.setOnAction(event -> SystemService.get().openUrlInBrowser(ai.getHomeUrl())); detailText.getChildren().add(hlink); } appDetails.getChildren().add(detailText); initLicenseText(); }
From source file:Main.java
@Override public void start(Stage stage) { Group p = new Group(); Scene scene = new Scene(p); stage.setScene(scene);/*from ww w . j av a2 s .c om*/ stage.setWidth(500); stage.setHeight(500); p.setTranslateX(80); p.setTranslateY(80); //create a circle with effect final Circle circle = new Circle(20, Color.rgb(156, 216, 255)); circle.setEffect(new Lighting()); //create a text inside a circle final Text text = new Text(i.toString()); text.setStroke(Color.BLACK); //create a layout for circle with text inside final StackPane stack = new StackPane(); stack.getChildren().addAll(circle, text); stack.setLayoutX(30); stack.setLayoutY(30); p.getChildren().add(stack); stage.show(); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //You can add a specific action when each frame is started. timer = new AnimationTimer() { @Override public void handle(long l) { text.setText(i.toString()); i++; } }; //create a keyValue with factory: scaling the circle 2times KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2); KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2); //create a keyFrame, the keyValue is reached at time 2s Duration duration = Duration.millis(2000); //one can add a specific action when the keyframe is reached EventHandler onFinished = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { stack.setTranslateX(java.lang.Math.random() * 200 - 100); //reset counter i = 0; } }; KeyFrame keyFrame = new KeyFrame(duration, onFinished, keyValueX, keyValueY); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); timeline.play(); timer.start(); }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void openAccountManager() { //Window Crap Stage accountManagerStage = new Stage(); accountManagerStage.setTitle("Starbound Server Account Manager"); GridPane gp = new GridPane(); gp.setAlignment(Pos.CENTER);//from w w w .j ava 2 s. c om gp.setVgap(10); gp.setHgap(10); gp.setPadding(new Insets(25, 25, 25, 25)); Text title = new Text("Starbound Account Manager"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); ListView<String> user_list = new ListView<String>(); ObservableList<String> user_list_o = FXCollections.observableArrayList(users); user_list.setItems(user_list_o); user_list.setPrefHeight(50); ListView<String> banned_users_list = new ListView<String>(); ObservableList<String> banned_users_list_o = FXCollections.observableArrayList(banned_usernames); banned_users_list.setItems(banned_users_list_o); banned_users_list.setPrefHeight(50); ListView<String> banned_ips_list = new ListView<String>(); ObservableList<String> banned_ips_list_o = FXCollections.observableArrayList(banned_ips); banned_ips_list.setItems(banned_ips_list_o); banned_ips_list.setPrefHeight(50); ListView<String> banned_playernames_list = new ListView<String>(); ObservableList<String> banned_playernames_list_o = FXCollections.observableArrayList(banned_playernames); banned_playernames_list.setItems(banned_playernames_list_o); banned_playernames_list.setPrefHeight(50); Label user_list_l = new Label("Current Users"); Label banned_users_list_l = new Label("Banned Users"); Label banned_ips_list_l = new Label("Banned IP's"); Label banned_playernames_list_l = new Label("Banned Player Names"); Button add_user = new Button("Add User"); Button add_banned_user = new Button("Add Banned User"); Button add_banned_ip = new Button("Add Banned IP"); Button add_banned_playername = new Button("Add Banner Playername"); Button remove_user = new Button("Remove User"); Button remove_banned_user = new Button("Remove Banned User"); Button remove_banned_ip = new Button("Remove Banned IP"); Button remove_banned_playername = new Button("Remove Banner Playername"); HBox userbox = new HBox(); userbox.setAlignment(Pos.BOTTOM_LEFT); userbox.getChildren().addAll(add_user, remove_user); userbox.setSpacing(5); HBox b_userbox = new HBox(); b_userbox.setAlignment(Pos.BOTTOM_LEFT); b_userbox.getChildren().addAll(add_banned_user, remove_banned_user); b_userbox.setSpacing(5); HBox b_ipbox = new HBox(); b_ipbox.setAlignment(Pos.BOTTOM_LEFT); b_ipbox.getChildren().addAll(add_banned_ip, remove_banned_ip); b_ipbox.setSpacing(5); HBox b_playerbox = new HBox(); b_playerbox.setAlignment(Pos.BOTTOM_LEFT); b_playerbox.getChildren().addAll(add_banned_playername, remove_banned_playername); b_playerbox.setSpacing(5); Button save = new Button("Save Config"); save.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { save(); } }); add_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createAccount(user_list); } }); add_banned_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedUser(banned_users_list); } }); add_banned_ip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedIP(banned_ips_list); } }); add_banned_playername.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedPlayername(banned_playernames_list); } }); remove_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { users.remove(user_list.getSelectionModel().getSelectedItem()); user_list.setItems(FXCollections.observableArrayList(users)); } }); remove_banned_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_usernames.remove(banned_users_list.getSelectionModel().getSelectedItem()); banned_users_list.setItems(FXCollections.observableArrayList(banned_usernames)); } }); remove_banned_ip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_ips.remove(banned_ips_list.getSelectionModel().getSelectedItem()); banned_ips_list.setItems(FXCollections.observableArrayList(banned_ips)); } }); remove_banned_playername.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_playernames.remove(banned_playernames_list.getSelectionModel().getSelectedItem()); banned_playernames_list.setItems(FXCollections.observableArrayList(banned_playernames)); } }); gp.add(user_list_l, 0, 1); gp.add(user_list, 0, 2); gp.add(userbox, 0, 3); gp.add(banned_users_list_l, 0, 4); gp.add(banned_users_list, 0, 5); gp.add(b_userbox, 0, 6); gp.add(banned_ips_list_l, 0, 7); gp.add(banned_ips_list, 0, 8); gp.add(b_ipbox, 0, 9); gp.add(banned_playernames_list_l, 0, 10); gp.add(banned_playernames_list, 0, 11); gp.add(b_playerbox, 0, 12); gp.add(save, 0, 13); Scene sc = new Scene(gp, 800 / 2, 600); accountManagerStage.setScene(sc); accountManagerStage.show(); }
From source file:com.playonlinux.javafx.mainwindow.console.ConsoleTab.java
public ConsoleTab(CommandLineInterpreterFactory commandLineInterpreterFactory) { final VBox content = new VBox(); commandInterpreter = commandLineInterpreterFactory.createInstance(); this.setText(translate("Console")); this.setContent(content); final TextField command = new TextField(); command.getStyleClass().add("consoleCommandType"); final TextFlow console = new TextFlow(); final ScrollPane consolePane = new ScrollPane(console); content.getStyleClass().add("rightPane"); consolePane.getStyleClass().add("console"); consolePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); content.getChildren().addAll(consolePane, command); command.requestFocus();//from w ww. j ava 2 s .c o m command.setOnKeyPressed(event -> { if (event.getCode() == KeyCode.ENTER) { final String commandToSend = command.getText(); final int cursorPosition = command.getCaretPosition(); command.setDisable(true); commandHistory.add(new CommandHistory.Item(commandToSend, cursorPosition)); Text commandText = new Text(nextSymbol + commandToSend + "\n"); commandText.getStyleClass().add("commandText"); console.getChildren().add(commandText); command.setText(""); if (commandInterpreter.sendLine(commandToSend, message -> { Platform.runLater(() -> { if (!StringUtils.isBlank(message)) { Text resultText = new Text(message); resultText.getStyleClass().add("resultText"); console.getChildren().add(resultText); } command.setDisable(false); command.requestFocus(); consolePane.setVvalue(consolePane.getVmax()); }); })) { nextSymbol = NOT_INSIDE_BLOCK; } else { nextSymbol = INSIDE_BLOCK; } } }); command.setOnKeyReleased(event -> { if (event.getCode() == KeyCode.UP) { CommandHistory.Item historyItem = commandHistory.up(); command.setText(historyItem.getCommand()); command.positionCaret(historyItem.getCursorPosition()); } else if (event.getCode() == KeyCode.DOWN) { CommandHistory.Item historyItem = commandHistory.down(); command.setText(historyItem.getCommand()); command.positionCaret(historyItem.getCursorPosition()); } }); this.setOnCloseRequest(event -> commandInterpreter.close()); }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private static void addDates(final HBox content, final BookingBean be) { final TextFlow checkIn = LocalDates.getDateText(be.getCheckIn()); final TextFlow checkOut = LocalDates.getDateText(be.getCheckOut()); final TextFlow year = LocalDates.getYearText(be.getCheckOut()); final TextFlow tf = new TextFlow(); tf.getChildren().addAll(checkIn, new Text("\n"), checkOut, new Text("\n"), year); // tf.getChildren().addAll(checkIn, new Text(" "), checkOut); // HBox.setHgrow(tf, Priority.SOMETIMES); content.getChildren().add(tf);/*w w w.jav a2s .co m*/ }
From source file:com.respam.comniq.Controller.java
@FXML protected void handleLocalButtonAction() { progressBar.setVisible(true);// w w w . j av a 2 s.co m String exdMovies = excludeArea.getText(); excluded = new HashSet(Arrays.asList(exdMovies.split(";"))); localMovies = inputPath.getText(); File loc = new File(localMovies); if (loc.isDirectory() == false) { Text errorMsg = new Text(" Not a valid Movies Directory"); errorMsg.setFill(Color.WHITE); textFlow.getChildren().clear(); textFlow.getChildren().add(errorMsg); } if (progBarStatus == false) { progressBar.relocate(0, 100); progBarStatus = true; } if (progBarStatus == true) { progressBar.relocate(0, 100); } if (inputPath.getText().trim().isEmpty()) { Text errorMsg = new Text(" Enter a valid Movies Directory"); errorMsg.setFill(Color.WHITE); textFlow.getChildren().clear(); textFlow.getChildren().add(errorMsg); } else if (loc.isDirectory() == true && !(inputPath.getText().trim().isEmpty())) { textFlow.getChildren().clear(); parseWorker = createWorker(); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(parseWorker.progressProperty()); new Thread(parseWorker).start(); } }
From source file:com.cooksys.postmaster.PostmasterModelSingleton.java
public PostmasterModelSingleton() { //initialize properties requestList = new ArrayList<ParsedHttpRequest>(); responseList = new ArrayList<ParsedHttpResponse>(); this.createTransientPropertyInstances(); this.port = 8080; //encode the default response if (responseList.isEmpty()) { ParsedHttpResponse response = new ParsedHttpResponse(); response.setContentType("text/html"); response.getHeaders().add(new HeaderRow("My-Header", "my header value")); response.getHeaders().add(new HeaderRow("Another-Header", "another header value")); response.getCookies().add(new CookieRow("My-Cookie", "my cookie value")); response.setName("Postmaster Default Response"); response.setStatusCode("200 OK"); response.setMessageBody("<html><body><h1>PostMaster Default Response" + "</h1><p>Create your own auto-response message in the 'Saved Responses' tab</p></body></html>"); defaultResponseIndex = 0;// w w w . j a v a 2 s . com //add it to the lists responseList.add(response); Text defaultResponseText = new Text(response.getName()); defaultResponseText.setFont(Font.font(null, FontWeight.BOLD, 12)); savedResponsesList.add(defaultResponseText); } }
From source file:com.github.drbookings.ui.controller.UpcomingController.java
private static void addCheckOutNotes(final LocalDate date, final VBox box, final List<CheckInOutDetails> checkOutNotes) { if (checkOutNotes.size() > 0) { for (final CheckInOutDetails next : checkOutNotes) { final TextFlow tf = new TextFlow(); final Text t0 = new Text("Room " + next.room); t0.getStyleClass().add("emphasis"); final Text t1 = new Text(" (" + next.bookingOrigin + ")"); tf.getChildren().addAll(t0, t1); if (!StringUtils.isBlank(next.notes)) { final Text t2 = new Text(": " + next.notes); t2.getStyleClass().add("guest-message"); tf.getChildren().add(t2); }/* w w w . j ava 2s . c om*/ box.getChildren().add(tf); } box.getChildren().add(new Separator()); } }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private static void addNights(final HBox content, final BookingBean be) { final Text label = new Text(be.getNumberOfNights() + " nights"); content.getChildren().add(label);//from ww w. j av a 2s . c om // HBox.setHgrow(label, Priority.SOMETIMES); }
From source file:by.zuyeu.deyestracker.reader.ui.readpane.ReadPaneController.java
public void openFileButtonAction(ActionEvent event) { LOG.info("openFileButtonAction() - start;"); FileChooser fileChooser = new FileChooser(); //TODO extract text to bundle fileChooser.setTitle("Open Text File"); fileChooser.getExtensionFilters().addAll(new ExtensionFilter("Text Files", "*.txt")); File selectedFile = fileChooser.showOpenDialog(application.getStage()); if (selectedFile != null) { try {//from ww w .j a v a 2s . c o m final String text = FileUtils.readFileToString(selectedFile); textFlow.getChildren().clear(); textFlow.getChildren().add(new Text(text)); addScrollTracker(); } catch (IOException ex) { LOG.warn("openFileButtonAction", ex); DialogsFrame.showOKDialog(application.getStage(), bundle.getString(ERROR_READ_FILE)); } catch (DEyesTrackerException ex) { LOG.warn("openFileButtonAction", ex); DialogsFrame.showOKDialog(application.getStage(), "Unable to run tracker"); } } LOG.info("openFileButtonAction() - end;"); }