本文整理匯總了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);
}
}
示例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()));
}
示例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());
}
示例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);
}
示例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());
}
示例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()));
}
示例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);
}
示例8: getWegiht
private FontWeight getWegiht() {
return chkBold.isSelected() ? FontWeight.BOLD : FontWeight.NORMAL;
}