當前位置: 首頁>>代碼示例>>Java>>正文


Java FontWeight.BOLD屬性代碼示例

本文整理匯總了Java中javafx.scene.text.FontWeight.BOLD屬性的典型用法代碼示例。如果您正苦於以下問題:Java FontWeight.BOLD屬性的具體用法?Java FontWeight.BOLD怎麽用?Java FontWeight.BOLD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javafx.scene.text.FontWeight的用法示例。


在下文中一共展示了FontWeight.BOLD屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: changeFont

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);
    }
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:17,代碼來源:FontPickerController.java

示例2: setFont

/**
 * Sets the font to be used for drawing text.
 * 
 * @param font  the font ({@code null} is permitted but ignored).
 * 
 * @see #getFont() 
 */
@Override
public void setFont(Font font) {
    if (font == null) {
        return;
    }
    this.font = font;
    FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    FontPosture posture = font.isItalic() 
            ? FontPosture.ITALIC : FontPosture.REGULAR;
    this.gc.setFont(javafx.scene.text.Font.font(font.getFamily(), 
            weight, posture, font.getSize()));
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:19,代碼來源:FXGraphics2D.java

示例3: convert

/** Convert font
 *  @param font AWT font
 *  @return JFX font
 */
public static Font convert(final java.awt.Font font)
{
    final FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    final FontPosture posture = font.isItalic() ? FontPosture.ITALIC : FontPosture.REGULAR;
    return Font.font(font.getFamily(), weight, posture, font.getSize());
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:10,代碼來源:GraphicsUtils.java

示例4: applyFont

private void applyFont(Font font) {
    this.font = font;
    FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    FontPosture posture = font.isItalic() 
            ? FontPosture.ITALIC : FontPosture.REGULAR;
    javafx.scene.text.Font jfxfont = javafx.scene.text.Font.font(
            font.getFamily(), weight, posture, font.getSize());
    this.gc.setFont(jfxfont);
}
 
開發者ID:jfree,項目名稱:fxgraphics2d,代碼行數:9,代碼來源:FXGraphics2D.java

示例5: getStringBounds

@Override
public Rectangle2D getStringBounds(String str, Graphics context) {
    Text text = new Text(str);
    FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    FontPosture posture = font.isItalic() 
            ? FontPosture.ITALIC : FontPosture.REGULAR;
    javafx.scene.text.Font jfxfont = javafx.scene.text.Font.font(
            font.getFamily(), weight, posture, font.getSize());
    text.setFont(jfxfont);
    Bounds b = text.getLayoutBounds();
    return new Rectangle2D.Double(b.getMinX(), b.getMinY(), b.getWidth(), 
            b.getHeight());
}
 
開發者ID:jfree,項目名稱:fxgraphics2d,代碼行數:13,代碼來源:FXFontMetrics.java

示例6: setFont

/**
 * Sets the font to be used for drawing text.
 *
 * @param font the font ({@code null} is permitted but ignored).
 * @see #getFont()
 */
@Override
public void setFont(Font font) {
    if (font == null) {
        return;
    }
    this.font = font;
    FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    FontPosture posture = font.isItalic()
            ? FontPosture.ITALIC : FontPosture.REGULAR;
    this.gc.setFont(javafx.scene.text.Font.font(font.getFamily(),
            weight, posture, font.getSize()));
}
 
開發者ID:informatik-mannheim,項目名稱:Moduro-Toolbox,代碼行數:18,代碼來源:FXGraphics2D.java

示例7: findFont

/**
 * Find a {@link Font} that best matches the given specs.
 * 
 * @param names
 *            the list of acceptable font families
 * @param size
 *            the requested size in pt.
 * @param bold
 *            whether the font should be bold
 * @param italic
 *            whether the font should be italic
 * @return a suitable {@link Font}, never <code>null</code>, might not be a perfect match
 */
public static Font findFont(List<String> names, double size, boolean bold, boolean italic) {
    FontWeight weight = (bold ? FontWeight.BOLD : FontWeight.NORMAL);
    FontPosture posture = (italic ? FontPosture.ITALIC : FontPosture.REGULAR);
    for (String name : names) {
        for (String font : allFonts) {
            if (font.toLowerCase().equals(name.toLowerCase())) {
                return Font.font(font, weight, posture, size);
            }
        }
    }

    // let JavaFX choose an appropriate alternative for the first font.
    return Font.font(names.get(0), weight, posture, size);
}
 
開發者ID:mduft,項目名稱:rapfx,代碼行數:27,代碼來源:JfxTypeHelper.java

示例8: getWegiht

private FontWeight getWegiht() {
	return chkBold.isSelected() ? FontWeight.BOLD : FontWeight.NORMAL;
}
 
開發者ID:jsquared21,項目名稱:Intro-to-Java-Programming,代碼行數:3,代碼來源:Exercise_16_14.java


注:本文中的javafx.scene.text.FontWeight.BOLD屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。