import
javafx.application.Application;
import
javafx.scene.Scene;
import
javafx.scene.control.*;
import
javafx.scene.layout.*;
import
javafx.stage.Stage;
import
javafx.scene.layout.*;
import
javafx.scene.paint.*;
import
javafx.scene.text.*;
import
javafx.geometry.*;
import
javafx.scene.layout.*;
import
javafx.scene.shape.*;
import
javafx.collections.*;
import
javafx.event.ActionEvent;
import
javafx.event.EventHandler;
public
class
FontWeight_2
extends
Application {
public
void
start(Stage stage)
{
try
{
stage.setTitle(
"FontWeight"
);
TextFlow text_flow =
new
TextFlow();
Text text_1 =
new
Text(
"GeeksforGeeks\n"
);
text_1.setFill(Color.GREEN);
text_1.setFont(Font.font(Font.getFontNames().get(
0
),
FontWeight.EXTRA_BOLD,
50
));
String weight[] = {
"BLACK"
,
"BOLD"
,
"EXTRA_BOLD"
,
"EXTRA_LIGHT"
,
"LIGHT"
,
"MEDIUM"
,
"NORMAL"
,
"SEMI_BOLD"
,
"THIN"
};
ComboBox combo_box =
new
ComboBox(FXCollections.observableArrayList(weight));
EventHandler<ActionEvent> event =
new
EventHandler<ActionEvent>() {
public
void
handle(ActionEvent e)
{
text_1.setFont(Font.font(Font.getFontNames().get(
0
),
FontWeight.valueOf((String)combo_box.getValue()),
50
));
}
};
combo_box.setOnAction(event);
text_flow.getChildren().add(text_1);
text_flow.setTextAlignment(TextAlignment.CENTER);
text_flow.setLineSpacing(
20
.0f);
VBox vbox =
new
VBox(combo_box, text_flow);
vbox.setAlignment(Pos.CENTER);
Scene scene =
new
Scene(vbox,
400
,
300
);
stage.setScene(scene);
stage.show();
}
catch
(Exception e) {
System.out.println(e.getMessage());
}
}
public
static
void
main(String args[])
{
launch(args);
}
}