本文整理匯總了Java中javafx.scene.text.FontWeight類的典型用法代碼示例。如果您正苦於以下問題:Java FontWeight類的具體用法?Java FontWeight怎麽用?Java FontWeight使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FontWeight類屬於javafx.scene.text包,在下文中一共展示了FontWeight類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.scene.text.FontWeight; //導入依賴的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: setLabel
import javafx.scene.text.FontWeight; //導入依賴的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);
}
示例3: createIconContent
import javafx.scene.text.FontWeight; //導入依賴的package包/類
public static Node createIconContent() {
Text htmlStart = new Text("<html>");
Text htmlEnd = new Text("</html>");
htmlStart.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlStart.setStyle("-fx-font-size: 20px;");
htmlStart.setTextOrigin(VPos.TOP);
htmlStart.setLayoutY(11);
htmlStart.setLayoutX(20);
htmlEnd.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlEnd.setStyle("-fx-font-size: 20px;");
htmlEnd.setTextOrigin(VPos.TOP);
htmlEnd.setLayoutY(31);
htmlEnd.setLayoutX(20);
return new Group(htmlStart, htmlEnd);
}
示例4: createTimeLeftInfoBox
import javafx.scene.text.FontWeight; //導入依賴的package包/類
private HBox createTimeLeftInfoBox( final TileViewModel build ) {
final HBox lastBuildInfoPart = new HBox( );
lastBuildInfoPart.setAlignment( Pos.CENTER );
final ImageView lastBuildIcon = new ImageView( UIUtils.createImage( "icons/timeLeft.png" ) );
lastBuildIcon.setPreserveRatio( true );
lastBuildIcon.setFitWidth( 32 );
final Label timeLeftLabel = new Label( );
timeLeftLabel.setMinWidth( 110 );
timeLeftLabel.setTextAlignment( CENTER );
timeLeftLabel.setAlignment( Pos.CENTER );
timeLeftLabel.setFont( UIUtils.font( 32, FontWeight.BOLD ) );
timeLeftLabel.setTextFill( Color.WHITE );
timeLeftLabel.setWrapText( true );
timeLeftLabel.setEffect( UIUtils.shadowEffect( ) );
timeLeftLabel.textProperty( ).bind( createStringBinding( ( ) -> {
final java.time.Duration timeLeft = build.timeLeftProperty( ).get( );
return ( timeLeft.isNegative( ) ? "+ " : "" ) + ( abs( timeLeft.toMinutes( ) ) + 1 ) + "\nmin";
}, build.timeLeftProperty( ) ) );
lastBuildInfoPart.getChildren( ).addAll( lastBuildIcon, timeLeftLabel );
return lastBuildInfoPart;
}
示例5: MenuTitle
import javafx.scene.text.FontWeight; //導入依賴的package包/類
public MenuTitle(String name, int size, Color color, boolean useSpread) {
String spread = "";
if (useSpread) {
for (char c : name.toCharArray()) {
spread += c + " ";
}
text = new Text(spread);
text.setFont(Font.loadFont(MenuApp.class.getResource("/fonts/Penumbra-HalfSerif-Std_35114.ttf").toExternalForm(), size));
text.setEffect(new DropShadow(50, Color.BLACK));
}
else {
text = new Text(name);
text.setFont(Font.font(null, FontWeight.LIGHT, size));
}
text.setFill(color);
text.setTextAlignment(TextAlignment.CENTER);
getChildren().addAll(text);
}
示例6: createIconContent
import javafx.scene.text.FontWeight; //導入依賴的package包/類
public static Node createIconContent() {
Text text = new Text("abc");
text.setTextOrigin(VPos.TOP);
text.setLayoutX(10);
text.setLayoutY(11);
text.setFill(Color.BLACK);
text.setOpacity(0.5);
text.setFont(Font.font(null, FontWeight.BOLD, 20));
text.setStyle("-fx-font-size: 20px;");
Text text2 = new Text("abc");
text2.setTextOrigin(VPos.TOP);
text2.setLayoutX(28);
text2.setLayoutY(51);
text2.setFill(Color.BLACK);
text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
text2.setStyle("-fx-font-size: 20px;");
Line line = new Line(30, 32, 45, 57);
line.setStroke(Color.DARKMAGENTA);
return new javafx.scene.Group(text, line, text2);
}
示例7: createText
import javafx.scene.text.FontWeight; //導入依賴的package包/類
/**
* Creates the title and description text.
* @return Returns a VBox containing the data.
*/
public VBox createText(){
final VBox layout = new VBox(15.0f);
layout.setAlignment(Pos.CENTER_LEFT);
layout.setPadding(new Insets(10,10,10,10));
layout.setMaxWidth(300.0f);
lblTitle = new Label(this.title);
lblTitle.setTextFill(javafx.scene.paint.Paint.valueOf("#ff0000"));
lblTitle.setFont( javafx.scene.text.Font.font(FONT_NAME, FontWeight.EXTRA_BOLD,FONT_SIZE) );
txtDescription = new Text(this.description);
txtDescription.setFill(Paint.valueOf("#ffffff"));
txtDescription.setFont( javafx.scene.text.Font.font(FONT_NAME, FontWeight.BOLD,12.0f) );
txtDescription.setBoundsType(TextBoundsType.LOGICAL_VERTICAL_CENTER);
layout.getChildren().add(lblTitle);
layout.getChildren().add(txtDescription);
return layout;
}
示例8: HelpTooltip
import javafx.scene.text.FontWeight; //導入依賴的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);
}
示例9: displayAuxObjects
import javafx.scene.text.FontWeight; //導入依賴的package包/類
private void displayAuxObjects() {
// Format btnTitleScreen
btnTitleScreen.setPrefSize(WIDTH / 4, HEIGHT / 10);
btnTitleScreen.setAlignment(Pos.CENTER);
// Format txtSelectClass
txtSelectClass.setFill(Color.rgb(234, 234, 234));
txtSelectClass.setFont(Font.font("Verdana", FontWeight.BOLD, 50));
// Modify vbTopObjects
vbTopObjects = new VBox(WIDTH / 100);
vbTopObjects.getChildren().addAll(btnTitleScreen, txtSelectClass);
vbTopObjects.setAlignment(Pos.CENTER);
this.setTop(vbTopObjects);
}
示例10: createBuildInformation
import javafx.scene.text.FontWeight; //導入依賴的package包/類
private void createBuildInformation( ) {
final Label tileTitle = new Label( );
tileTitle.setFont( UIUtils.font( 50, FontWeight.BOLD ) );
tileTitle.setTextFill( Color.WHITE );
tileTitle.setPadding( new Insets( 5 ) );
tileTitle.setWrapText( true );
tileTitle.textProperty( ).bind( _model.displayedNameProperty( ) );
tileTitle.setEffect( UIUtils.shadowEffect( ) );
tileTitle.prefWidthProperty( ).bind( widthProperty( ) );
tileTitle.prefHeightProperty( ).bind( heightProperty( ) );
tileTitle.alignmentProperty( ).bind( createObjectBinding( ( ) -> _model.isLightMode( ) ? Pos.CENTER : CENTER_LEFT, _model.lightModeProperty( ) ) );
tileTitle.textAlignmentProperty( ).bind( createObjectBinding( ( ) -> _model.isLightMode( ) ? CENTER : LEFT, _model.lightModeProperty( ) ) );
HBox.setHgrow( tileTitle, Priority.SOMETIMES );
getChildren( ).add( tileTitle );
final VBox contextPart = createContextPart( );
contextPart.visibleProperty( ).bind( _model.lightModeProperty( ).not( ) );
contextPart.prefWidthProperty( ).bind( createIntegerBinding( ( ) -> contextPart.isVisible( ) ? 90 : 0, contextPart.visibleProperty( ) ) );
contextPart.prefHeightProperty( ).bind( heightProperty( ) );
contextPart.setMinSize( USE_PREF_SIZE, USE_PREF_SIZE );
contextPart.setMaxSize( USE_PREF_SIZE, USE_PREF_SIZE );
getChildren( ).add( contextPart );
}
示例11: createTopBar
import javafx.scene.text.FontWeight; //導入依賴的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;
}
示例12: buildBoxHorario
import javafx.scene.text.FontWeight; //導入依賴的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;
}
示例13: buildBoxHorario
import javafx.scene.text.FontWeight; //導入依賴的package包/類
/**
* Constroi a caixa de hor�rio exibida na tabPreencherDados
*
* @return
*/
private StackPane buildBoxHorario() {
VBox vbox = new VBox(7);
vbox.setAlignment(Pos.CENTER);
Rectangle rect = new Rectangle(200, 150);
rect.setStroke(Color.BLACK);
rect.setStrokeWidth(2);
rect.setFill(Color.TRANSPARENT);
Text data = new Text(new SimpleDateFormat("dd/MM/yyyy").format(dtSolicitacaoReserva));
data.setFont(Font.font("Verdana", FontWeight.BOLD, 12.0));
vbox.getChildren().add(data);
for (Horario horario : listaHorariosSelecionados) {
vbox.getChildren().add(new Text(horario.getEstampa()));
}
StackPane caixa = new StackPane(rect, vbox);
return caixa;
}
示例14: changeFont
import javafx.scene.text.FontWeight; //導入依賴的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);
}
}
示例15: read
import javafx.scene.text.FontWeight; //導入依賴的package包/類
@Override
public Font read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
String value = in.nextString();
String path = in.getPath();
String[] components = splitComponents(value, path);
String family = components[0];
String style = components[1];
String sizeStr = components[2];
FontWeight weight = extractWeight(style);
FontPosture posture = extractPosture(style);
double size = extractSize(sizeStr, path);
return Font.font(family, weight, posture, size);
}