Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. package sample;
  2.  
  3. import javafx.application.Application;
  4. import javafx.geometry.Insets;
  5. import javafx.geometry.Pos;
  6. import javafx.scene.Scene;
  7. import javafx.scene.control.*;
  8. import javafx.scene.image.ImageView;
  9. import javafx.scene.layout.FlowPane;
  10. import javafx.scene.layout.HBox;
  11. import javafx.scene.layout.TilePane;
  12. import javafx.scene.text.Font;
  13. import javafx.stage.Stage;
  14.  
  15. public class Main extends Application {
  16.  
  17. static double maxWidth = Double.MAX_VALUE;
  18.  
  19. @Override
  20. public void start(Stage stage) throws Exception{
  21. //Elements
  22. FlowPane rootPane = new FlowPane();
  23. rootPane.setPadding(new Insets(20));
  24.  
  25. TilePane labelAndImgBox = new TilePane();
  26. labelAndImgBox.setMaxWidth(maxWidth);
  27. //labelAndImgBox.setAlignment(Pos.CENTER);
  28.  
  29. ComboBox comboBoxBox = new ComboBox();
  30. comboBoxBox.getItems().addAll("Serif", "SansSerif", "Monospace");
  31. comboBoxBox.setMaxWidth(maxWidth);
  32.  
  33. HBox checkBoxBox = new HBox(20);
  34. checkBoxBox.setMaxWidth(maxWidth);
  35. checkBoxBox.setAlignment(Pos.CENTER);
  36.  
  37. HBox radioBox = new HBox(20);
  38. radioBox.setMaxWidth(maxWidth);
  39. radioBox.setAlignment(Pos.CENTER);
  40.  
  41. rootPane.getChildren().addAll(labelAndImgBox, comboBoxBox, checkBoxBox, radioBox);
  42.  
  43. //labelAndImgBox
  44. Label fontLabel = new Label("Big Java");
  45. fontLabel.setStyle("-fx-font-size: 50px");
  46. ImageView image = new ImageView(getClass().getResource("BigJava.jpg").toExternalForm());
  47.  
  48. labelAndImgBox.getChildren().addAll(fontLabel, image);
  49.  
  50. CheckBox italicCheck = new CheckBox("Italic");
  51. CheckBox boldCheck = new CheckBox("Bold");
  52. //ToggleGroup checkGroup = new ToggleGroup();
  53. checkBoxBox.getChildren().addAll(italicCheck, boldCheck);
  54.  
  55. //Radio buttons + ToggleGroup
  56. RadioButton smallButton = new RadioButton("Small");
  57. RadioButton mediumButton = new RadioButton("Medium");
  58. RadioButton largeButton = new RadioButton("Large");
  59. ToggleGroup radioGroup = new ToggleGroup();
  60. smallButton.setToggleGroup(radioGroup);
  61. mediumButton.setToggleGroup(radioGroup);
  62. largeButton.setToggleGroup(radioGroup);
  63. radioBox.setPadding(new Insets(0, 10, 0, 10));
  64. radioBox.getChildren().addAll(smallButton, mediumButton, largeButton);
  65.  
  66. smallButton.setOnAction(e -> {
  67. fontLabel.setFont(Font.font("Monospace"));
  68. });
  69.  
  70. Scene scene = new Scene(rootPane, 500, 600);
  71. stage.setScene(scene);
  72. stage.setResizable(false);
  73. stage.show();
  74. }
  75.  
  76.  
  77. public static void main(String[] args) {
  78. launch(args);
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement