當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。