当前位置: 首页>>代码示例>>Java>>正文


Java Text.setFont方法代码示例

本文整理汇总了Java中javafx.scene.text.Text.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java Text.setFont方法的具体用法?Java Text.setFont怎么用?Java Text.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.text.Text的用法示例。


在下文中一共展示了Text.setFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javafx.scene.text.Text; //导入方法依赖的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();
}
 
开发者ID:GwtDomino,项目名称:domino-todolist,代码行数:51,代码来源:DesktopLayoutView.java

示例2: 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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:26,代码来源:ColorPickerSample.java

示例3: createElement

import javafx.scene.text.Text; //导入方法依赖的package包/类
/**
 * @param s
 * @param i
 * add an Element in the scroll
 */
private void createElement(Supplier s, int i){
    HBox suppliersBox = new HBox();

    suppliersBox.setOnMouseClicked(event -> {
        for (int j=0; j<suppliers.getChildren().size(); j++) {
            if(j % 2 == 1)
                suppliers.getChildren().get(j).setStyle("-fx-background-color: #336699;");
            else
                suppliers.getChildren().get(j).setStyle("-fx-background-color: #0F355C;");
        }

        lastClickedValue = s;
        updateDetail(s);
        suppliersBox.setStyle("-fx-background-color: #ff6600;");
    });
    suppliersBox.setMinWidth(HomeView.TAB_CONTENT_W / 4);
    suppliersBox.setPadding(new Insets(20));

    Text supplierText = new Text(s.getName());
    supplierText.setFont(new Font(20));
    supplierText.setFill(Color.WHITE);
    suppliersBox.getChildren().add(supplierText);

    if (i % 2 == 1)
        suppliersBox.setStyle("-fx-background-color: #336699;");
    else
        suppliersBox.setStyle("-fx-background-color: #0F355C;");

    suppliers.getChildren().add(suppliersBox);
}
 
开发者ID:Moccko,项目名称:campingsimulator2017,代码行数:36,代码来源:SupplierManagerView.java

示例4: drawSquare

import javafx.scene.text.Text; //导入方法依赖的package包/类
/**
 * Draw square on canvas with given message.
 *
 * @param message    text to display in middle of square
 * @param x          upper left x of square
 * @param y          upper left y of square
 * @param squareFill {@link Color} fill of background of square
 * @param textFill   {@link Color} fill of text in square
 */
private void drawSquare(final String message, final double x, final double y,
                        final Color squareFill, final Color textFill) {
    graphicsContext.setStroke(squareFill);
    graphicsContext.strokeRoundRect(x, y, SQUARE_WIDTH, SQUARE_HEIGHT, ARC_SIZE, ARC_SIZE);

    final Text messageText = new Text(message);
    messageText.setFont(graphicsContext.getFont());
    final double textWidth = messageText.getBoundsInLocal().getWidth();

    graphicsContext.setStroke(textFill);
    graphicsContext.fillText(
            message,
            x + SQUARE_WIDTH / 2 - textWidth / 2,
            y + SQUARE_HEIGHT * TEXT_HEIGHT_PORTION_OFFSET);
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:25,代码来源:SequenceVisualizer.java

示例5: createNumber

import javafx.scene.text.Text; //导入方法依赖的package包/类
private Text createNumber(String number, double layoutX, double layoutY) {
    Text text = new Text(number);
    text.setLayoutX(layoutX);
    text.setLayoutY(layoutY);
    text.setTextAlignment(TextAlignment.CENTER);
    text.setFill(FILL_COLOR);
    text.setFont(NUMBER_FONT);
    return text;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:StopWatch.java

示例6: Mesazhi

import javafx.scene.text.Text; //导入方法依赖的package包/类
public Mesazhi(String titulli, String titulli_msg, String mesazhi){
    stage.setTitle(titulli);
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setResizable(false);
    HBox root = new HBox(15);
    VBox sub_root = new VBox(10);
    HBox btn = new HBox();
    Text ttl = new Text(titulli_msg);
    ttl.setFont(Font.font(16));
    Button btnOk = new Button("Ne rregull");
    btn.getChildren().add(btnOk);
    btn.setAlignment(Pos.CENTER_RIGHT);

    btnOk.setOnAction(e -> stage.close());
    btnOk.setOnKeyPressed(e -> {
        if (e.getCode().equals(KeyCode.ENTER)) stage.close();
        else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close();
    });

    root.setPadding(new Insets(20));
    sub_root.getChildren().addAll(ttl, new Label(mesazhi), btn);
    if (titulli == "Gabim")
        root.getChildren().add(new ImageView(new Image("/sample/foto/error.png")));
    else if (titulli == "Sukses")
        root.getChildren().add(new ImageView(new Image("/sample/foto/success.png")));
    else if (titulli == "Informacion")
        root.getChildren().add(new ImageView(new Image("/sample/foto/question.png")));
    else if (titulli == "Info")
        root.getChildren().add(new ImageView(new Image("/sample/foto/info.png")));
    root.getChildren().add(sub_root);
    root.setAlignment(Pos.TOP_CENTER);
    Scene scene = new Scene(root, 450, 150);
    scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm());
    stage.setScene(scene);
    stage.show();
}
 
开发者ID:urankajtazaj,项目名称:Automekanik,代码行数:37,代码来源:Mesazhi.java

示例7: init

import javafx.scene.text.Text; //导入方法依赖的package包/类
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    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<ActionEvent>() {

        @Override
        public void handle(ActionEvent 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();
    root.getChildren().add(outerVBox);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ColorPickerDemo.java

示例8: createIconContent

import javafx.scene.text.Text; //导入方法依赖的package包/类
public static Node createIconContent() {
    Text sample = new Text("FX");
    sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,80));
    sample.setStyle("-fx-font-size: 80px;");
    sample.setFill(Color.web("#333333"));
    final DropShadow dropShadow = new DropShadow();
    dropShadow.setOffsetX(4);
    dropShadow.setOffsetY(6);
    dropShadow.setColor(Color.rgb(0,0,0,0.7));
    sample.setEffect(dropShadow);
    return sample;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:13,代码来源:DropShadowSample.java

示例9: draw

import javafx.scene.text.Text; //导入方法依赖的package包/类
public void draw() {
    // Draw elevator
    Rectangle rgB = new Rectangle(WIDTH, HEIGHT);
    rgB.setFill(Color.TRANSPARENT);
    this.getChildren().add(rgB);
    
    rgT = new Rectangle((WIDTH / 3) * 2 + (WIDTH / (WIDTH / 8)), HEIGHT / 1.5 + (HEIGHT / (HEIGHT / 4)));
    rgT.setFill(Color.web("bfbfbf"));
    rgT.setX(WIDTH / 2 - rgT.getWidth() / 2);
    rgT.setY(HEIGHT - rgT.getHeight());
    this.getChildren().add(rgT);

    //Left side elevator shaft door
    rgD1 = new Rectangle(WIDTH / 3, HEIGHT / 1.5);
    rgD1.setFill(Color.web("a5a5a5"));
    rgD1.setX(WIDTH / 2 - rgD1.getWidth());
    rgD1.setY(HEIGHT - rgD1.getHeight());
    this.getChildren().add(rgD1);

    //Right side elevator shaft door
    rgD2 = new Rectangle(WIDTH / 3, HEIGHT / 1.5);
    rgD2.setFill(Color.web("a5a5a5"));
    rgD2.setX(WIDTH / 2);
    rgD2.setY(HEIGHT - rgD2.getHeight());
    this.getChildren().add(rgD2);
    
    // Draw text
    tFloorNum = new Text(String.valueOf(FLOORNUM));
    tFloorNum.setFill(Color.web("bfbfbf"));
    tFloorNum.setFont(Font.font("Verdana", 20));
    tFloorNum.setX(WIDTH / 2 - tFloorNum.getBoundsInParent().getWidth() / 2);
    tFloorNum.setY(rgT.getY() - tFloorNum.getBoundsInParent().getHeight() / 2);
    this.getChildren().add(tFloorNum);
}
 
开发者ID:spencerhendon,项目名称:projectintern,代码行数:35,代码来源:Elevator.java

示例10: createPiece

import javafx.scene.text.Text; //导入方法依赖的package包/类
public Node createPiece(int piece, int column, int row) {
	StackPane pane = new StackPane();
	Rectangle background = new Rectangle(0, 0, 60, 60);
	background.setFill(((column + row) % 2) == 0 ? Color.WHITE : Color.GRAY);
	pane.getChildren().add(background);

	if (piece >=0 && piece < 8) {
		Circle circle = new Circle(30, 30, 25);
		if (piece / 4 == 1) {
			circle.setStrokeWidth(3);
		} else {
			circle.setStrokeWidth(0);
		}

		if ((piece % 4) / 2 == 0) {
			circle.setFill(Color.WHITE);
			circle.setStroke(Color.BLACK);
		} else {
			circle.setFill(Color.BLACK);
			circle.setStroke(Color.WHITE);
		}

		pane.getChildren().add(circle);

		if ((piece % 4) % 2 == 1) {
			Text text = new Text("♔");
			text.setFont(new Font(32));
			text.setFill(((piece % 4) / 2 == 0) ? Color.BLACK : Color.WHITE);
			text.setBoundsType(TextBoundsType.VISUAL);
			pane.getChildren().add(text);
		}
	}

	return pane;
}
 
开发者ID:edwardxia,项目名称:board-client,代码行数:36,代码来源:Checkers.java

示例11: PackageNodeView

import javafx.scene.text.Text; //导入方法依赖的package包/类
public PackageNodeView(PackageNode node) {
    super(node);
    refNode = node;
    title = new Text(node.getTitle());
    title.setFont(Font.font("Verdana", FontWeight.BOLD, 12));
    //TODO Ugly solution, hardcoded value.
    title.setWrappingWidth(node.getWidth() - 7);
    container = new VBox();
    bodyStackPane = new StackPane();

    container.setSpacing(0);

    createRectangles();


    container.getChildren().add(top);
    bodyStackPane.getChildren().addAll(body, title);
    container.getChildren().addAll(bodyStackPane);
    StackPane.setAlignment(title, Pos.TOP_CENTER);
    StackPane.setAlignment(top, Pos.CENTER_LEFT);
    setTitleSize();
    this.getChildren().add(container);
    this.setTranslateX(node.getTranslateX());
    this.setTranslateY(node.getTranslateY());

    createHandles();
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:28,代码来源:PackageNodeView.java

示例12: licencesp

import javafx.scene.text.Text; //导入方法依赖的package包/类
private ScrollPane licencesp(double width, double height) {

        ScrollPane sp = new ScrollPane();

        Text text = new Text();

        text.setX(width * 0.1);
        text.setY(height * 0.1);
        text.setFont(new Font(20));

        text.setFill(new Color(1, 1, 1, 1));

        StringBuilder licence = new StringBuilder(10000);
        String line;

        try {
            BufferedReader br = new BufferedReader(new FileReader("data/common/licence.txt"));

            while ((line = br.readLine()) != null) {
                licence.append('\n');
                licence.append(line);
            }
            br.close();
        } catch (IOException e) {
            log.error("Exception", e);
        }

        text.setText(licence.toString());

        sp.setContent(text);
        sp.setFitToHeight(true);
        sp.setFitToWidth(true);
        sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
        sp.setVmax(height);
        // sp.setPrefSize(width*0.8, height*0.8);

        return sp;

    }
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:40,代码来源:License.java

示例13: createIconContent

import javafx.scene.text.Text; //导入方法依赖的package包/类
public static Node createIconContent() {

        Text sample = new Text("FX");
        sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,80));
        sample.setStyle("-fx-font-size: 80px;");
        sample.setFill(Color.web("#333333"));
        final GaussianBlur GaussianBlur = new GaussianBlur();
        GaussianBlur.setRadius(15);
        sample.setEffect(GaussianBlur);
        return sample;
    }
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:GaussianBlurSample.java

示例14: prepareRatioGrid

import javafx.scene.text.Text; //导入方法依赖的package包/类
/**
 * Note that JavaFx GridPane uses (col, row) instead of (row, col)
 */
private void prepareRatioGrid() {

    squidSpeciesList = squidProject.getTask().getSquidSpeciesModelList();

    indexOfBackgroundSpecies = -1;

    ratiosGridPane.getRowConstraints().clear();
    RowConstraints rowCon = new RowConstraints();
    rowCon.setPrefHeight(BUTTON_HEIGHT);
    ratiosGridPane.getRowConstraints().add(rowCon);

    ratiosGridPane.getColumnConstraints().clear();
    ColumnConstraints colcon = new ColumnConstraints(BUTTON_WIDTH);
    colcon.setPrefWidth(BUTTON_WIDTH);
    colcon.setHalignment(HPos.CENTER);
    ratiosGridPane.getColumnConstraints().add(colcon);

    for (int i = 0; i < squidSpeciesList.size(); i++) {
        if (squidSpeciesList.get(i).getIsBackground()) {
            indexOfBackgroundSpecies = squidSpeciesList.get(i).getMassStationIndex();
            squidProject.getTask().setIndexOfBackgroundSpecies(indexOfBackgroundSpecies);

            Text colText = new Text(squidSpeciesList.get(i).getIsotopeName());
            colText.setFont(Font.font("Courier New", FontWeight.BOLD, 12));
            ratiosGridPane.add(colText, 0, i + 1);

            Text rowText = new Text(squidSpeciesList.get(i).getIsotopeName());
            rowText.setFont(Font.font("Courier New", FontWeight.BOLD, 12));
            ratiosGridPane.add(rowText, i + 1, 0);
        } else {
            Button colButton = new SquidRowColButton(i, -1, squidSpeciesList.get(i).getIsotopeName());
            ratiosGridPane.add(colButton, 0, i + 1);

            Button rowButton = new SquidRowColButton(-1, i, squidSpeciesList.get(i).getIsotopeName());
            ratiosGridPane.add(rowButton, i + 1, 0);
        }

        Label corLabel = new Label("ROW /\n COL");
        corLabel.setFont(Font.font("Courier New", FontWeight.BOLD, 2));
        corLabel.setStyle(
                "    -fx-font-family: \"Courier New\", \"Lucida Sans\", \"Segoe UI\", Helvetica, Arial, sans-serif;\n"
                + "    -fx-font-weight: bold;\n"
                + "    -fx-font-size: 7pt;\n"
        );
        corLabel.setWrapText(true);

        ratiosGridPane.add(corLabel, 0, 0);

        ratiosGridPane.getRowConstraints().add(rowCon);
        ratiosGridPane.getColumnConstraints().add(colcon);
    }

    populateRatioGrid();

    // center in window
    double width = primaryStageWindow.getScene().getWidth();
    ratiosGridPane.setLayoutX((width - (squidSpeciesList.size() + 1) * BUTTON_WIDTH) / 2.0);
    ratiosGridPane.setLayoutY(15);

}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:64,代码来源:RatiosManagerController.java

示例15: createTitle

import javafx.scene.text.Text; //导入方法依赖的package包/类
private void createTitle(){
	Text stepTitle = new Text(myResources.getString("CREATION_STEPS"));
	stepTitle.setFont(new Font(20));
	stepHolder = new VBox();
	this.getChildren().addAll(stepTitle, stepHolder);
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:7,代码来源:StepOrganizer.java


注:本文中的javafx.scene.text.Text.setFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。