本文整理汇总了Java中javafx.scene.text.Text类的典型用法代码示例。如果您正苦于以下问题:Java Text类的具体用法?Java Text怎么用?Java Text使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Text类属于javafx.scene.text包,在下文中一共展示了Text类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import javafx.scene.text.Text; //导入依赖的package包/类
public void show() {
textArea = new JFXTextArea(bodyText);
JFXDialogLayout content = new JFXDialogLayout();
content.setHeading(new Text(headingText));
content.setBody(textArea);
content.setPrefSize(dialogWidth, dialogHeight);
StackPane stackPane = new StackPane();
stackPane.autosize();
JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true);
JFXButton button = new JFXButton("Okay");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
dialog.close();
}
});
button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
button.setPrefHeight(32);
button.setStyle(dialogBtnStyle);
content.setActions(button);
pane.getChildren().add(stackPane);
AnchorPane.setTopAnchor(stackPane, (pane.getHeight() - content.getPrefHeight()) / 2);
AnchorPane.setLeftAnchor(stackPane, (pane.getWidth() - content.getPrefWidth()) / 2);
dialog.show();
}
示例2: makeStatsPane
import javafx.scene.text.Text; //导入依赖的package包/类
private void makeStatsPane(Map<String, String> stats) {
myStats = new VBox(5);
for(String statName : stats.keySet()){
Text nameAndValue = new Text(statName + ": " + stats.get(statName));
//TODO: set text size
TextFlow wrapper = new TextFlow(nameAndValue);
wrapper.setTextAlignment(TextAlignment.LEFT);
wrapper.getStylesheets().add("resources/socialStyle.css");
wrapper.getStyleClass().add("textfill");
myStats.getChildren().add(wrapper);
}
myStats.getStylesheets().add("resources/socialStyle.css");
myStats.getStyleClass().add("statsbox");
}
示例3: createLetter
import javafx.scene.text.Text; //导入依赖的package包/类
private void createLetter(String c) {
final Text letter = new Text(c);
letter.setFill(Color.BLACK);
letter.setFont(FONT_DEFAULT);
letter.setTextOrigin(VPos.TOP);
letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
getChildren().add(letter);
// over 3 seconds move letter to random position and fade it out
final Timeline timeline = new Timeline();
timeline.getKeyFrames().add(
new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
// we are done remove us from scene
getChildren().remove(letter);
}
},
new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
new KeyValue(letter.opacityProperty(), 0f)
));
timeline.play();
}
示例4: displayText
import javafx.scene.text.Text; //导入依赖的package包/类
private void displayText(final String s, final String title) {
final Scene scene = new Scene(new Pane());
String text = s;
if (s == null || s.isEmpty()) { text = "Whoops! Nothing to see here"; }
final Text textItem = new Text(text);
final Button okButton = new Button("OK");
final GridPane grid = new GridPane();
grid.setVgap(4);
grid.setHgap(10);
grid.setPadding(new Insets(5, 5, 5, 5));
grid.add(textItem, 0, 0);
grid.add(okButton, 1, 0);
final Pane root = (Pane) scene.getRoot();
root.getChildren().add(grid);
if (rootModel.darkModeProperty().get()) {
scene.getStylesheets().add("root/darkMode.css");
textItem.getStyleClass().add("text");
}
final Stage stage = new Stage();
stage.setScene(scene);
stage.setTitle(title);
stage.show();
okButton.setOnAction(e -> {
stage.close();
});
}
示例5: makeAndAuditExpression
import javafx.scene.text.Text; //导入依赖的package包/类
public void makeAndAuditExpression() {
// make and audit expression
StringBuilder sb = new StringBuilder();
for (Node node : expressionTextFlow.getChildren()) {
if (node instanceof Text) {
sb.append(((Text) node).getText());
}
}
String fullText = makeStringFromTextFlow();
if (fullText.trim().length() > 0) {
Expression exp = squidProject.getTask().generateExpressionFromRawExcelStyleText(
"Editing Expression",
fullText.trim().replace("\n", ""),
false);
expressionAuditTextArea.setText(exp.produceExpressionTreeAudit());
} else {
expressionAuditTextArea.setText("");
}
}
示例6: wrappableTableCell
import javafx.scene.text.Text; //导入依赖的package包/类
/**
* Create a table cell that wraps the text inside.
*
* @param param the table column
* @return a table cell that wraps the text inside
*/
TableCell<Annotation, String> wrappableTableCell(final TableColumn<Annotation, String> param) {
return new TableCell<Annotation, String>() {
@Override
protected void updateItem(final String item, final boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
return;
}
final Text text = new Text(item);
text.setWrappingWidth(param.getWidth());
setPrefHeight(text.getLayoutBounds().getHeight());
setGraphic(text);
}
};
}
示例7: MonsterAdder
import javafx.scene.text.Text; //导入依赖的package包/类
public MonsterAdder(AllPossibleMonsters possibleMonsters) {
myPossibleMonsters = possibleMonsters;
loadMonster = new Button(LOAD_A_MONSTER_FROM_FILE);
loadMonster.setOnAction(click -> {
XStreamHandler xstream = new XStreamHandler();
SpriteMakerModel monster = (SpriteMakerModel) xstream.getAttributeFromFile();
myPossibleMonsters.loadFromFile(monster);
});
refresh = new Button("Refresh");
refresh.setOnAction(click -> {
myPossibleMonsters.getMonstersOnScreen();
});
this.getChildren().addAll(new Text(CREATE_A_SPAWNER), loadMonster, //refresh,
numberOfMonsters);
}
示例8: setRadarValuesLabels
import javafx.scene.text.Text; //导入依赖的package包/类
private void setRadarValuesLabels() {
Text startValueText = new Text(xCenter - 20, yCenter, String.valueOf(minValue));
startValueText.setFill(Color.RED);
startValueText.setFont(Font.font(15));
Text middleValueText = new Text(xCenter - 20, yCenter - radius / 2, String.valueOf(maxValue / 2));
middleValueText.setFill(Color.RED);
middleValueText.setFont(Font.font(15));
Text maxValueText = new Text(xCenter - 20, yCenter - radius, String.valueOf(maxValue));
maxValueText.setFill(Color.RED);
maxValueText.setFont(Font.font(15));
getChildren().addAll(startValueText, middleValueText, maxValueText);
}
示例9: createText
import javafx.scene.text.Text; //导入依赖的package包/类
private List<Text> createText(PlayerStatsModel playerStatsModel, Player player) {
List<Text> statsLabels = new ArrayList<Text>();
playerStatsModel.getWealth(player).ifPresent((wealthMap) -> {
for (WealthType type: wealthMap.keySet()) {
statsLabels.add(new Text(type + ": " + wealthMap.get(type)));
}
});
//TODO map to resource file
playerStatsModel.getLives(player).ifPresent((life) -> {
statsLabels.add(new Text(LIVES + life));
});
// playerStatsModel.getScore(player).ifPresent((score) -> {
// statsLabels.add(new Text("Scores:" + score));
// });
return statsLabels;
}
示例10: init
import javafx.scene.text.Text; //导入依赖的package包/类
public void init() {
button.setTooltip(new Tooltip(toolBox.getI18nBundle().getString("buttons.delete")));
MaterialIconFactory iconFactory = MaterialIconFactory.get();
Text deleteIcon = iconFactory.createIcon(MaterialIcon.DELETE, "30px");
button.setText(null);
button.setGraphic(deleteIcon);
button.setDisable(true);
toolBox.getEventBus()
.toObserverable()
.ofType(AnnotationsSelectedEvent.class)
.subscribe(e -> {
User user = toolBox.getData().getUser();
boolean enabled = (user != null) && e.get().size() > 0;
button.setDisable(!enabled);
});
toolBox.getEventBus()
.toObserverable()
.ofType(DeleteAnnotationsMsg.class)
.subscribe(m -> apply());
button.setOnAction(e -> apply());
}
示例11: createIconContent
import javafx.scene.text.Text; //导入依赖的package包/类
public static Node createIconContent() {
Text htmlStart = new Text("<html>");
Text htmlEnd = new Text("</html>");
htmlStart.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlStart.setStyle("-fx-font-size: 20px;");
htmlStart.setTextOrigin(VPos.TOP);
htmlStart.setLayoutY(11);
htmlStart.setLayoutX(20);
htmlEnd.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlEnd.setStyle("-fx-font-size: 20px;");
htmlEnd.setTextOrigin(VPos.TOP);
htmlEnd.setLayoutY(31);
htmlEnd.setLayoutX(20);
return new Group(htmlStart, htmlEnd);
}
示例12: InnerShadowSample
import javafx.scene.text.Text; //导入依赖的package包/类
public InnerShadowSample() {
Text sample = new Text(0,100,"Shadow");
sample.setFont(Font.font("Arial Black",80));
sample.setFill(Color.web("#BBBBBB"));
final InnerShadow innerShadow = new InnerShadow();
innerShadow.setRadius(5d);
innerShadow.setOffsetX(2);
innerShadow.setOffsetY(2);
sample.setEffect(innerShadow);
getChildren().add(sample);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Text Fill", sample.fillProperty()),
new SimplePropertySheet.PropDesc("Inner Shadow Radius", innerShadow.radiusProperty(), 0d,60d),
new SimplePropertySheet.PropDesc("Inner Shadow Offset X", innerShadow.offsetXProperty(), -10d, 10d),
new SimplePropertySheet.PropDesc("Inner Shadow Offset Y", innerShadow.offsetYProperty(), -10d, 10d),
new SimplePropertySheet.PropDesc("Inner Shadow Color", innerShadow.colorProperty())
);
// END REMOVE ME
}
示例13: configureDigits
import javafx.scene.text.Text; //导入依赖的package包/类
private void configureDigits() {
for (int i : numbers) {
digits[i] = new Text("0");
digits[i].setFont(FONT);
digits[i].setTextOrigin(VPos.TOP);
digits[i].setLayoutX(2.3);
digits[i].setLayoutY(-1);
Rectangle background;
if (i < 6) {
background = createBackground(Color.web("#a39f91"), Color.web("#FFFFFF"));
digits[i].setFill(Color.web("#000000"));
} else {
background = createBackground(Color.web("#bdbeb3"), Color.web("#FF0000"));
digits[i].setFill(Color.web("#FFFFFF"));
}
digitsGroup[i] = new Group(background, digits[i]);
}
}
示例14: initGraphics
import javafx.scene.text.Text; //导入依赖的package包/类
private void initGraphics() {
background = new Region();
background.getStyleClass().setAll("background");
upBar = new Region();
upBar.getStyleClass().setAll("up-bar");
downBar = new Region();
downBar.getStyleClass().setAll("down-bar");
barRotate = new Rotate(ANGLE_IN_CLOSED_POSITION);
mobileBar = new Region();
mobileBar.getStyleClass().setAll("mobile-bar");
mobileBar.getTransforms().add(barRotate);
name = new Text(getSkinnable().getName());
name.getStyleClass().setAll("name-text");
pane = new Pane(background, upBar, downBar, mobileBar, name);
getChildren().add(pane);
resize();
}
示例15: ColorPickerSample
import javafx.scene.text.Text; //导入依赖的package包/类
public ColorPickerSample() {
final ColorPicker colorPicker = new ColorPicker(Color.GRAY);
ToolBar standardToolbar = ToolBarBuilder.create().items(colorPicker).build();
final Text coloredText = new Text("Colors");
Font font = new Font(53);
coloredText.setFont(font);
final Button coloredButton = new Button("Colored Control");
Color c = colorPicker.getValue();
coloredText.setFill(c);
coloredButton.setStyle(createRGBString(c));
colorPicker.setOnAction(new EventHandler() {
public void handle(Event t) {
Color newColor = colorPicker.getValue();
coloredText.setFill(newColor);
coloredButton.setStyle(createRGBString(newColor));
}
});
VBox coloredObjectsVBox = VBoxBuilder.create().alignment(Pos.CENTER).spacing(20).children(coloredText, coloredButton).build();
VBox outerVBox = VBoxBuilder.create().alignment(Pos.CENTER).spacing(150).padding(new Insets(0, 0, 120, 0)).children(standardToolbar, coloredObjectsVBox).build();
getChildren().add(outerVBox);
}