本文整理汇总了Java中javafx.scene.text.Font类的典型用法代码示例。如果您正苦于以下问题:Java Font类的具体用法?Java Font怎么用?Java Font使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Font类属于javafx.scene.text包,在下文中一共展示了Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.scene.text.Font; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setOnShowing(event -> uiHandlers.onShow());
BorderPane border = new BorderPane();
hbox = new HBox();
border.setTop(hbox);
hbox.setMinHeight(60);
hbox.setAlignment(Pos.CENTER_LEFT);
hbox.setBackground(new Background(new BackgroundFill(Color.web("#2196f3"), CornerRadii.EMPTY, Insets.EMPTY)));
hbox.setPadding(new Insets(10));
menu = new VBox();
menu.setPadding(new Insets(20, 0, 0, 0));
BorderStroke borderStroke = new BorderStroke(Color.GRAY, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(0,1,0,0));
menu.setBorder(new Border(borderStroke));
menu.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
menu.setMinWidth(50);
menu.setSpacing(20);
border.setLeft(menu);
primaryStage.setTitle("Todo list");
Text text = new Text("Todo List");
text.setFill(Color.WHITE);
text.setFont(Font.font("Verdana", FontWeight.BOLD, 25));
center = new VBox();
center.setPadding(new Insets(20));
center.setSpacing(10);
Image image = new Image(getClass().getResourceAsStream("/add.png"));
Button add = new Button("", new ImageView(image));
add.setCursor(Cursor.HAND);
add.setBackground(Background.EMPTY);
add.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);
add.setOnAction(event -> uiHandlers.onCreate());
border.setCenter(center);
hbox.setPadding(new Insets(10, 10, 10, 10));
final Pane spacer = new Pane();
HBox.setHgrow(spacer, Priority.ALWAYS);
spacer.setMinSize(10, 1);
hbox.getChildren().addAll(text, spacer, add);
primaryStage.setScene(new Scene(border, 500, 500));
primaryStage.show();
}
示例2: Exe
import javafx.scene.text.Font; //导入依赖的package包/类
void Exe(int i) {
if(i==1) {
warnmesse="プレイ開始から5分経過しました\n混雑している場合は次の人に\n交代してください";
fontsize=25;
}else if(i==2) {
warnmesse="プレイ開始から10分経過しました\n混雑している場合は次の人に\n交代してください";
fontsize=25;
}else if(i==-1) {
warnmesse="user timer is reset";
fontsize=35;
}
final Stage primaryStage = new Stage(StageStyle.TRANSPARENT);
primaryStage.initModality(Modality.NONE);
final StackPane root = new StackPane();
final Scene scene = new Scene(root, 350, 140);
scene.setFill(null);
final Label label = new Label(warnmesse);
label.setFont(new Font("Arial", fontsize));
BorderPane borderPane = new BorderPane();
borderPane.setCenter(label);
borderPane.setStyle("-fx-background-radius: 10;-fx-background-color: rgba(0,0,0,0.3);");
root.getChildren().add(borderPane);
final Rectangle2D d = Screen.getPrimary().getVisualBounds();
primaryStage.setScene(scene);
primaryStage.setAlwaysOnTop(true);
primaryStage.setX(d.getWidth()-350);
primaryStage.setY(d.getHeight()-300);
primaryStage.show();
final Timeline timer = new Timeline(new KeyFrame(Duration.seconds(CLOSE_SECONDS), (ActionEvent event) -> primaryStage.close()));
timer.setCycleCount(Timeline.INDEFINITE);
timer.play();
}
示例3: setLabel
import javafx.scene.text.Font; //导入依赖的package包/类
private void setLabel() {
String text;
if (failuresList == null) {
text = "";
} else if (failuresList.size() > 0) {
String errorString = failuresList.size() == 1 ? " error" : " errors";
text = failuresList.size() + errorString;
tableLabel.setTextFill(Color.RED);
} else {
text = "No Errors";
tableLabel.setTextFill(Color.GREEN);
}
tableLabel.setText(text);
tableLabel.setFont(Font.font(tableLabel.getFont().toString(), FontWeight.BOLD, 12));
tableLabel.setLabelFor(resultTable);
}
示例4: updatePointer
import javafx.scene.text.Font; //导入依赖的package包/类
private void updatePointer() {
currentValueText.setText(formatCurrentValue(getSkinnable().getCurrentValue(), getSkinnable().getDecimals()));
currentValueText.setFont(Font.font("Digital-7", width * CURRENT_VALUE_FONT_SIZE_FACTOR));
currentValueText.setTextOrigin(VPos.TOP);
currentValueText.setTextAlignment(TextAlignment.RIGHT);
currentValuePointer.getStyleClass().clear();
currentValuePointer.getStyleClass().setAll("normal-current-value-pointer");
currentValuePointer.setPrefSize(currentValueText.getLayoutBounds().getWidth()*1.10, currentValueText.getLayoutBounds().getHeight()*1.10);
currentValuePointerGroup.setTranslateX((width/2 + barWidth/2) - currentValuePointerGroup.getLayoutBounds().getWidth());
final double newPosition = getSkinnable().getCurrentValue() < getSkinnable().getMinValue() ? height - (currentValuePointerGroup.getLayoutBounds().getHeight() * 0.5) :
getSkinnable().getCurrentValue() > getSkinnable().getMaxValue() ? height - barHeight - (currentValuePointerGroup.getLayoutBounds().getHeight() * 0.5) :
height - (currentValuePointerGroup.getLayoutBounds().getHeight() * 0.5) - (barHeight * (getSkinnable().getCurrentValue()-getSkinnable().getMinValue()) / (getSkinnable().getMaxValue()-getSkinnable().getMinValue()));
if(getSkinnable().getAnimated()){
timeline.stop();
final KeyValue KEY_VALUE = new KeyValue(currentValuePointerGroup.translateYProperty(), newPosition, Interpolator.EASE_BOTH);
final KeyFrame KEY_FRAME = new KeyFrame(Duration.millis(getSkinnable().getAnimationDuration()), KEY_VALUE);
timeline.getKeyFrames().setAll(KEY_FRAME);
timeline.play();
}else {
currentValuePointerGroup.setTranslateY(newPosition);
}
}
示例5: buildBoxHorario
import javafx.scene.text.Font; //导入依赖的package包/类
private List<StackPane> buildBoxHorario() {
List<StackPane> boxHorarios = new ArrayList<>();
for (ReservaEntity reservaEntity : novasReservas) {
VBox vbox = new VBox(7);
vbox.setAlignment(Pos.CENTER);
Rectangle rect = new Rectangle(100, 150);
rect.setStroke(Color.BLACK);
rect.setStrokeWidth(2);
rect.setFill(Color.TRANSPARENT);
Text data = new Text(new SimpleDateFormat("dd/MM/yyyy").format(reservaEntity.getDataInicio()));
data.setFont(Font.font("Verdana", FontWeight.BOLD, 12.0));
vbox.getChildren().add(data);
for (Horario horario : reservaEntity.getHorarios()) {
vbox.getChildren().add(new Text(horario.getEstampa()));
}
boxHorarios.add(new StackPane(rect, vbox));
}
return boxHorarios;
}
示例6: setNodeHeight
import javafx.scene.text.Font; //导入依赖的package包/类
/**
* Sets the node height used for drawing.
* <p>
* Also updates the font size used for drawing sequences within nodes.
*
* @param nodeHeight the node height
*/
public final void setNodeHeight(final double nodeHeight) {
this.nodeHeight = nodeHeight;
this.snpHeight = nodeHeight * SNP_HEIGHT_FACTOR;
final Text text = new Text("X");
text.setFont(new Font(DEFAULT_NODE_FONT, 1));
final double font1PHeight = text.getLayoutBounds().getHeight();
final String font;
if (SystemUtils.IS_OS_MAC) {
font = DEFAULT_MAC_NODE_FONT;
} else {
font = DEFAULT_NODE_FONT;
}
final double fontSize = DEFAULT_NODE_FONT_HEIGHT_SCALAR * nodeHeight / font1PHeight;
this.nodeFont = new Font(font, fontSize);
text.setFont(nodeFont);
this.charWidth = text.getLayoutBounds().getWidth();
this.charHeight = text.getLayoutBounds().getHeight();
}
示例7: resize
import javafx.scene.text.Font; //导入依赖的package包/类
private void resize() {
width = getWidth() - getInsets().getLeft() - getInsets().getRight();
height = getHeight() - getInsets().getTop() - getInsets().getBottom();
reducedHeight = height - height * 0.05;
size = width < height ? width : height;
if (width > 0 && height > 0) {
canvas.setWidth(width);
canvas.setHeight(height);
canvas.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);
ctx.setTextBaseline(VPos.CENTER);
ctx.setFont(Font.font(Helper.clamp(8, 24, size * 0.025)));
groupBy(getCategory());
}
}
示例8: resize
import javafx.scene.text.Font; //导入依赖的package包/类
private void resize() {
width = getWidth() - getInsets().getLeft() - getInsets().getRight();
height = getHeight() - getInsets().getTop() - getInsets().getBottom();
size = width < height ? width : height;
if (width > 0 && height > 0) {
canvas.setWidth(width);
canvas.setHeight(height);
canvas.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);
ctx.setTextBaseline(VPos.CENTER);
ctx.setFont(Font.font(Helper.clamp(8, 24, size * 0.025)));
prepareData();
}
}
示例9: changeFont
import javafx.scene.text.Font; //导入依赖的package包/类
private void changeFont() {
try {
double size = numberFormat.parse(sizeComboBox.getValue()).doubleValue();
FontWeight weight = styleChoiceBox.getSelectionModel().isSelected(0) ||
styleChoiceBox.getSelectionModel().isSelected(1)
? FontWeight.BOLD : FontWeight.NORMAL;
FontPosture posture = styleChoiceBox.getSelectionModel().isSelected(1) ||
styleChoiceBox.getSelectionModel().isSelected(2)
? FontPosture.ITALIC : FontPosture.REGULAR;
String family = familyComboBox.getValue();
font.setValue(Font.font(family, weight, posture, size));
sampleFontText.setFont(font.get());
} catch (java.text.ParseException ex) {
Logger.getLogger(FontPickerController.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例10: createTopBar
import javafx.scene.text.Font; //导入依赖的package包/类
private HBox createTopBar()
{
HBox counterHBox = new HBox();
counterHBox.setPadding(new Insets(15, 15, 15, 15));
counterHBox.setSpacing(10);
Label programCounterLabel = new Label("Program Count");
programCounterLabel.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
TextField programCounterText = new TextField();
programCounterText.setPrefWidth(50);
Label nextInstructionLabel = new Label("Next Instruction");
nextInstructionLabel.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
TextField nextInstructionText = new TextField();
nextInstructionText.setPrefWidth(200);
counterHBox.getChildren().addAll(programCounterLabel, programCounterText,
nextInstructionLabel, nextInstructionText);
return counterHBox;
}
示例11: HelpTooltip
import javafx.scene.text.Font; //导入依赖的package包/类
public HelpTooltip(String tooltipText) {
// Set text as question mark and general style
this.setText("?");
this.setPrefSize(35, 35);
this.setMinSize(35, 35);
this.setFont(Font.font("System", FontWeight.BOLD, 20));
this.setAlignment(Pos.CENTER);
this.setStyle("-fx-background-color: #9098ff; -fx-background-radius: 30px");
// Create and add tooltip (need to set its font because otherwise it's inherited from the Label)
Tooltip descriptionTooltip = new Tooltip(tooltipText);
descriptionTooltip.setPrefWidth(250);
descriptionTooltip.setWrapText(true);
descriptionTooltip.setFont(new Font("System", 12));
this.setTooltip(descriptionTooltip);
}
示例12: setToolTip
import javafx.scene.text.Font; //导入依赖的package包/类
public void setToolTip(ImageView imageView, Image image) {
String msg = "";
msg += "image: " + image.getImageName() + "\n";
if(image.getPosition() != -1)
msg += "position: " + image.getPosition() + "\n";
if(image.getScore() != -1)
msg += "score: " + image.getScore() + "\n";
Tooltip tooltip = new Tooltip(msg);
tooltip.setFont(new Font("Arial", 16));
tooltip.setStyle("-fx-background-color: aquamarine; -fx-text-fill: black");
Tooltip.install(imageView, tooltip);
}
示例13: initialize
import javafx.scene.text.Font; //导入依赖的package包/类
@FXML
public void initialize() {
Image icon = new Image("com/kaanburaksener/octoUML/src/icons/classDiagram.PNG");
classDiagramButton.setGraphic(new ImageView(icon));
classDiagramButton.setContentDisplay(ContentDisplay.BOTTOM);
titleLabel.setFont(Font.font("Verdana", FontWeight.BOLD, 60));
titleLabel.setTextFill(Color.web("#3F4144"));
}
示例14: computePrefWidth
import javafx.scene.text.Font; //导入依赖的package包/类
@Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
final String labelText = label.getText();
final Font font = label.getFont();
double textWidth = Utils.computeTextWidth(font, labelText, 0);
return leftInset + textWidth + 20 + thumbArea.prefWidth(-1) + rightInset;
}
示例15: computePrefHeight
import javafx.scene.text.Font; //导入依赖的package包/类
@Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
{
final Font font = label.getFont();
final String labelText = label.getText();
final double textHeight = Utils.computeTextHeight(font, labelText, 0, label.getLineSpacing(), label.getBoundsType());
return topInset + Math.max(thumb.prefHeight(-1), textHeight) + bottomInset;
}