Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sample;
- import javafx.application.Application;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.Scene;
- import javafx.scene.control.*;
- import javafx.scene.image.ImageView;
- import javafx.scene.layout.FlowPane;
- import javafx.scene.layout.HBox;
- import javafx.scene.layout.TilePane;
- import javafx.scene.text.Font;
- import javafx.stage.Stage;
- public class Main extends Application {
- static double maxWidth = Double.MAX_VALUE;
- @Override
- public void start(Stage stage) throws Exception{
- //Elements
- FlowPane rootPane = new FlowPane();
- rootPane.setPadding(new Insets(20));
- TilePane labelAndImgBox = new TilePane();
- labelAndImgBox.setMaxWidth(maxWidth);
- //labelAndImgBox.setAlignment(Pos.CENTER);
- ComboBox comboBoxBox = new ComboBox();
- comboBoxBox.getItems().addAll("Serif", "SansSerif", "Monospace");
- comboBoxBox.setMaxWidth(maxWidth);
- HBox checkBoxBox = new HBox(20);
- checkBoxBox.setMaxWidth(maxWidth);
- checkBoxBox.setAlignment(Pos.CENTER);
- HBox radioBox = new HBox(20);
- radioBox.setMaxWidth(maxWidth);
- radioBox.setAlignment(Pos.CENTER);
- rootPane.getChildren().addAll(labelAndImgBox, comboBoxBox, checkBoxBox, radioBox);
- //labelAndImgBox
- Label fontLabel = new Label("Big Java");
- fontLabel.setStyle("-fx-font-size: 50px");
- ImageView image = new ImageView(getClass().getResource("BigJava.jpg").toExternalForm());
- labelAndImgBox.getChildren().addAll(fontLabel, image);
- CheckBox italicCheck = new CheckBox("Italic");
- CheckBox boldCheck = new CheckBox("Bold");
- //ToggleGroup checkGroup = new ToggleGroup();
- checkBoxBox.getChildren().addAll(italicCheck, boldCheck);
- //Radio buttons + ToggleGroup
- RadioButton smallButton = new RadioButton("Small");
- RadioButton mediumButton = new RadioButton("Medium");
- RadioButton largeButton = new RadioButton("Large");
- ToggleGroup radioGroup = new ToggleGroup();
- smallButton.setToggleGroup(radioGroup);
- mediumButton.setToggleGroup(radioGroup);
- largeButton.setToggleGroup(radioGroup);
- radioBox.setPadding(new Insets(0, 10, 0, 10));
- radioBox.getChildren().addAll(smallButton, mediumButton, largeButton);
- smallButton.setOnAction(e -> {
- fontLabel.setFont(Font.font("Monospace"));
- });
- Scene scene = new Scene(rootPane, 500, 600);
- stage.setScene(scene);
- stage.setResizable(false);
- stage.show();
- }
- public static void main(String[] args) {
- launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement