Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. package sample;
  2.  
  3. import javafx.fxml.FXML;
  4. import javafx.fxml.FXMLLoader;
  5. import javafx.geometry.Insets;
  6. import javafx.scene.Parent;
  7. import javafx.scene.Scene;
  8. import javafx.scene.control.Button;
  9. import javafx.scene.control.ColorPicker;
  10. import javafx.scene.layout.Background;
  11. import javafx.scene.layout.BackgroundFill;
  12. import javafx.scene.layout.CornerRadii;
  13. import javafx.stage.Stage;
  14.  
  15. public class DokumentController {
  16.  
  17. @FXML
  18. private Button coloredButton;
  19.  
  20. @FXML
  21. public void openColorDialog(){
  22. try{
  23. Parent root = FXMLLoader.load(getClass().getResource("ColorDialog.fxml"));
  24. Stage stage = new Stage();
  25. stage.setTitle("SET BUTTON COLOR");
  26. Scene scene = new Scene(root);
  27. stage.setScene(scene);
  28. stage.show();
  29.  
  30. } catch (Exception e){
  31. System.out.println("Can't load window");
  32. }
  33. }
  34.  
  35. @FXML
  36. private ColorPicker colorPicker;
  37.  
  38. @FXML
  39. public void setButtonColor() {
  40.  
  41. coloredButton.setBackground(new Background(new BackgroundFill(colorPicker.getValue(), CornerRadii.EMPTY, Insets.EMPTY)));
  42.  
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement