Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sample;
- import javafx.fxml.FXML;
- import javafx.fxml.FXMLLoader;
- import javafx.geometry.Insets;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.ColorPicker;
- import javafx.scene.layout.Background;
- import javafx.scene.layout.BackgroundFill;
- import javafx.scene.layout.CornerRadii;
- import javafx.stage.Stage;
- public class DokumentController {
- @FXML
- private Button coloredButton;
- @FXML
- public void openColorDialog(){
- try{
- Parent root = FXMLLoader.load(getClass().getResource("ColorDialog.fxml"));
- Stage stage = new Stage();
- stage.setTitle("SET BUTTON COLOR");
- Scene scene = new Scene(root);
- stage.setScene(scene);
- stage.show();
- } catch (Exception e){
- System.out.println("Can't load window");
- }
- }
- @FXML
- private ColorPicker colorPicker;
- @FXML
- public void setButtonColor() {
- coloredButton.setBackground(new Background(new BackgroundFill(colorPicker.getValue(), CornerRadii.EMPTY, Insets.EMPTY)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement