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
Font_2
extends
Application {
public
void
start(Stage stage)
{
try
{
stage.setTitle(
"Font"
);
TextFlow text_flow =
new
TextFlow();
Text text_1 =
new
Text(
"GeeksforGeeks\n"
);
text_1.setFill(Color.GREEN);
Font font = Font.font(Font.getFontNames().get(
0
),
FontWeight.EXTRA_BOLD,
20
);
String weight[] = {
"BLACK"
,
"BOLD"
,
"EXTRA_BOLD"
,
"EXTRA_LIGHT"
,
"LIGHT"
,
"MEDIUM"
,
"NORMAL"
,
"SEMI_BOLD"
,
"THIN"
};
ComboBox combo_box =
new
ComboBox(FXCollections.observableArrayList(weight));
ComboBox combo_box1 =
new
ComboBox(FXCollections.observableArrayList(Font.getFontNames()));
EventHandler<ActionEvent> event =
new
EventHandler<ActionEvent>() {
public
void
handle(ActionEvent e)
{
text_1.setFont(Font.font((String)combo_box1.getValue(),
FontWeight.valueOf((String)combo_box.getValue()),
20
));
}
};
EventHandler<ActionEvent> event1 =
new
EventHandler<ActionEvent>() {
public
void
handle(ActionEvent e)
{
text_1.setFont(Font.font((String)combo_box1.getValue(),
FontWeight.valueOf((String)combo_box.getValue()),
20
));
}
};
combo_box.setOnAction(event);
combo_box1.setOnAction(event1);
text_1.setFont(font);
text_flow.getChildren().add(text_1);
text_flow.setLineSpacing(
20
.0f);
HBox hbox =
new
HBox(combo_box, combo_box1);
VBox vbox =
new
VBox(hbox, text_flow);
vbox.setSpacing(
30.0
);
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);
}
}