Package javafx.scene.control

Examples of javafx.scene.control.ColorPicker


    @Override public void start(Stage stage) throws Exception {
        AquaFx.styleStage(stage, StageStyle.UNIFIED);
        BorderPane pane = new BorderPane();

        ToolBar toolBar = new ToolBar();
        ColorPicker colorTB = new ColorPicker(Color.rgb(194, 222, 254));

        Separator seperateIt = new Separator();
        ToggleGroup toolbarGroup = new ToggleGroup();
        ToggleButton sampleButton4 = new ToggleButton("TG1");
        sampleButton4.setToggleGroup(toolbarGroup);
        sampleButton4.setSelected(true);
        AquaFx.createToggleButtonStyler().setType(ButtonType.LEFT_PILL).style(sampleButton4);
        ToggleButton sampleButton5 = new ToggleButton("TG2");
        sampleButton5.setToggleGroup(toolbarGroup);
        sampleButton5.setSelected(true);
        AquaFx.createToggleButtonStyler().setType(ButtonType.CENTER_PILL).style(sampleButton5);
        ToggleButton sampleButton6 = new ToggleButton("TG3");
        sampleButton6.setToggleGroup(toolbarGroup);
        sampleButton6.setSelected(true);
        AquaFx.createToggleButtonStyler().setType(ButtonType.RIGHT_PILL).style(sampleButton6);

        Separator seperateIt2 = new Separator();

        Button menuPillButton1 = new Button("PB 1");
        AquaFx.createButtonStyler().setType(ButtonType.LEFT_PILL).style(menuPillButton1);
        Button menuPillButton2 = new Button("PB 2");
        AquaFx.createButtonStyler().setType(ButtonType.CENTER_PILL).style(menuPillButton2);
        Button menuPillButton3 = new Button("PB 3");
        AquaFx.createButtonStyler().setType(ButtonType.RIGHT_PILL).style(menuPillButton3);

        Button sampleButton = new Button("Button");
        ToggleButton sampleButton1 = new ToggleButton("Toggle");
        sampleButton1.setDisable(true);
        ToggleButton sampleButton2 = new ToggleButton("Toggle");
        ToggleButton sampleButton3 = new ToggleButton("Toggle2");
        sampleButton3.setSelected(true);
        toolBar.getItems().addAll(colorTB, sampleButton, sampleButton1, sampleButton2, sampleButton3, seperateIt, sampleButton4,
                sampleButton5, sampleButton6, seperateIt2, menuPillButton1, menuPillButton2, menuPillButton3);

        pane.setTop(toolBar);

        /**
         * TabPane
         */
        TabPane buttonTabPane = new TabPane();

        // Create Tabs
        Tab tabD = new Tab();
        tabD.setText("Buttons");
        VBox buttonBox = new VBox();
        buttonBox.setSpacing(10);
        buttonBox.setPadding(new Insets(10));
        Button b1 = new Button();
        b1.setText("Default (push to enable Tab 'Progress')");
        b1.setDefaultButton(true);
        b1.setTooltip(new Tooltip("This is a ToolTip"));
        b1.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent event) {
                tabI.setDisable(false);
                tabH.setDisable(false);
            }
        });
        buttonBox.getChildren().add(b1);
        Button b2 = new Button();
        b2.setText("Default");
        b2.setDisable(true);
        b2.setDefaultButton(true);
        buttonBox.getChildren().add(b2);
        Button b3 = new Button();
        b3.setText("Normal (push to disable Tab 'Progress')");
        b3.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent event) {
                tabH.setDisable(true);
            }
        });
        buttonBox.getChildren().add(b3);
        Button b4 = new Button();
        b4.setText("Normal");
        b4.setDisable(true);
        buttonBox.getChildren().add(b4);

        Button helpButton = new Button("?");
        AquaFx.createButtonStyler().setType(ButtonType.HELP).style(helpButton);
        buttonBox.getChildren().add(helpButton);

        Hyperlink link = new Hyperlink("Hyperlink");
        Hyperlink link2 = new Hyperlink("disabled Hyperlink");
        link2.setDisable(true);
        buttonBox.getChildren().add(link);
        buttonBox.getChildren().add(link2);
        ScrollBar scBar = new ScrollBar();
        buttonBox.getChildren().add(scBar);

        tabD.setContent(buttonBox);
        buttonTabPane.getTabs().add(tabD);

        Tab tabE = new Tab();
        tabE.setText("RadioButtons");
        VBox radioButtonBox = new VBox();
        radioButtonBox.setSpacing(10);
        radioButtonBox.setPadding(new Insets(10));
        RadioButton raBu1 = new RadioButton("Normal");
        radioButtonBox.getChildren().add(raBu1);
        RadioButton raBu2 = new RadioButton("Normal");
        raBu2.setDisable(true);
        radioButtonBox.getChildren().add(raBu2);
        RadioButton raBu3 = new RadioButton("Selected");
        raBu3.setSelected(true);
        radioButtonBox.getChildren().add(raBu3);
        RadioButton raBu4 = new RadioButton("Selected");
        raBu4.setDisable(true);
        raBu4.setSelected(true);
        radioButtonBox.getChildren().add(raBu4);
        tabE.setContent(radioButtonBox);
        buttonTabPane.getTabs().add(tabE);

        Tab tabF = new Tab();
        tabF.setText("CheckBoxes");
        VBox checkBoxBox = new VBox();
        checkBoxBox.setSpacing(10);
        checkBoxBox.setPadding(new Insets(10));
        CheckBox box1 = new CheckBox("Normal");
        checkBoxBox.getChildren().add(box1);
        CheckBox box2 = new CheckBox("Normal");
        box2.setDisable(true);
        checkBoxBox.getChildren().add(box2);
        CheckBox box3 = new CheckBox("Selected");
        box3.setSelected(true);
        checkBoxBox.getChildren().add(box3);
        CheckBox box4 = new CheckBox("Selected");
        box4.setSelected(true);
        box4.setDisable(true);
        checkBoxBox.getChildren().add(box4);
        CheckBox box5 = new CheckBox("Indeterminate");
        box5.setIndeterminate(true);
        checkBoxBox.getChildren().add(box5);
        CheckBox box6 = new CheckBox("Indeterminate");
        box6.setIndeterminate(true);
        box6.setDisable(true);
        checkBoxBox.getChildren().add(box6);
        tabF.setContent(checkBoxBox);
        buttonTabPane.getTabs().add(tabF);

        Tab tabG = new Tab();
        tabG.setText("Toggles & Pills");
        VBox togglesBox = new VBox();
        togglesBox.setSpacing(10);
        togglesBox.setPadding(new Insets(10));
        HBox toggleGroupBox = new HBox();
        ToggleGroup group = new ToggleGroup();
        ToggleButton tb1 = new ToggleButton("First");
        tb1.setToggleGroup(group);
        tb1.setSelected(true);
        AquaFx.createToggleButtonStyler().setType(ButtonType.LEFT_PILL).style(tb1);
        toggleGroupBox.getChildren().add(tb1);
        ToggleButton tb2 = new ToggleButton("Second");
        tb2.setToggleGroup(group);
        AquaFx.createToggleButtonStyler().setType(ButtonType.CENTER_PILL).style(tb2);
        toggleGroupBox.getChildren().add(tb2);
        ToggleButton tb3 =  new ToggleButton("Third");
        tb3.setToggleGroup(group);
        AquaFx.createToggleButtonStyler().setType(ButtonType.RIGHT_PILL).style(tb3);
        toggleGroupBox.getChildren().add(tb3);
        togglesBox.getChildren().add(toggleGroupBox);
        ToggleButton tb4 = new ToggleButton("Alone");
        tb4.setSelected(true);
        togglesBox.getChildren().add(tb4);
        HBox pillButtonBox = new HBox();
        Button pb1 = new Button();
        pb1.setText("Button 1");
        pb1.setTooltip(new Tooltip("This is a ToolTip"));
        AquaFx.createButtonStyler().setType(ButtonType.LEFT_PILL).style(pb1);
        pillButtonBox.getChildren().add(pb1);
        Button pb2 = new Button();
        pb2.setText("Button 2");
        pb2.setDisable(true);
        AquaFx.createButtonStyler().setType(ButtonType.CENTER_PILL).style(pb2);
        pillButtonBox.getChildren().add(pb2);
        Button pb3 = new Button();
        pb3.setText("Button 3");
        AquaFx.createButtonStyler().setType(ButtonType.CENTER_PILL).style(pb3);
        pillButtonBox.getChildren().add(pb3);
        Button pb4 = new Button();
        pb4.setText("Button 4");
        AquaFx.createButtonStyler().setType(ButtonType.RIGHT_PILL).style(pb4);
        pillButtonBox.getChildren().add(pb4);
        togglesBox.getChildren().add(pillButtonBox);
        tabG.setContent(togglesBox);
        buttonTabPane.getTabs().add(tabG);

        // Tab tabH = new Tab();
        tabH.setText("Progress");
        final Float[] values = new Float[] { -1.0f, 0f, 0.6f, 1.0f };
        final ProgressBar[] pbs = new ProgressBar[values.length];
        final ProgressIndicator[] pins = new ProgressIndicator[values.length];
        final HBox hbs[] = new HBox[values.length];
        for (int i = 0; i < values.length; i++) {
            final Label label = new Label();
            label.setText("progress: " + values[i]);
            label.setPrefWidth(100d);

            final ProgressBar pb = pbs[i] = new ProgressBar();
            pb.setProgress(values[i]);

            final ProgressIndicator pin = pins[i] = new ProgressIndicator();
            pin.setProgress(values[i]);
            final HBox hb = hbs[i] = new HBox();
            hb.setSpacing(10);
            hb.setAlignment(Pos.CENTER_LEFT);
            hb.getChildren().addAll(label, pb, pin);
        }
        final VBox vb = new VBox();
        vb.setSpacing(5);
        vb.setPadding(new Insets(10));
        vb.getChildren().addAll(hbs);
        tabH.setContent(vb);
        buttonTabPane.getTabs().add(tabH);

        tabI.setText("Disabled Tab");
        tabI.setDisable(true);
        TabPane innerTabPane = new TabPane();
        Label label = new Label("Lipsum");
        Tab onlyTab = new Tab("single tab");
        onlyTab.setContent(label);
        innerTabPane.getTabs().add(onlyTab);
        tabI.setContent(innerTabPane);
        buttonTabPane.getTabs().add(tabI);

        Tab tabTexts = new Tab();
        tabTexts.setText("Texts");
        VBox txts = new VBox();
        HBox textfieldBox1 = new HBox();
        textfieldBox1.setSpacing(10);
        textfieldBox1.setPadding(new Insets(10));
        Menu item1 = new Menu("test submenu");
        MenuItem subMenuItem1 = new MenuItem("Sub Menu Item 1");
        MenuItem subMenuItem2 = new MenuItem("Sub Menu Item 2");
        MenuItem subMenuItem3 = new MenuItem("Sub Menu Item 3");
        item1.getItems().addAll(subMenuItem1, subMenuItem2, subMenuItem3);
        TextField tf1 = new TextField("Textfield");
        ContextMenu cm = new ContextMenu(new MenuItem("test"), item1, new MenuItem("test"));
        tf1.setContextMenu(cm);
        textfieldBox1.getChildren().add(tf1);
        TextField tf2 = new TextField();
        textfieldBox1.getChildren().add(tf2);
        HBox textfieldBox2 = new HBox();
        textfieldBox2.setSpacing(10);
        textfieldBox2.setPadding(new Insets(10));
        TextField tf3 = new TextField("disabled Textfield");
        tf3.setDisable(true);
        tf3.setEditable(false);
        textfieldBox2.getChildren().add(tf3);
        TextField tf4 = new TextField();
        tf4.setPromptText("prompt text");
        textfieldBox2.getChildren().add(tf4);
        txts.getChildren().add(textfieldBox2);
        HBox textfieldBox3 = new HBox();
        textfieldBox3.setSpacing(10);
        textfieldBox3.setPadding(new Insets(10));
        TextField tf5 = new TextField("non-editable textfield");
        tf5.setEditable(false);
        textfieldBox3.getChildren().add(tf5);
        PasswordField pw1 = new PasswordField();
        pw1.setText("password");
        textfieldBox3.getChildren().add(pw1);
        txts.getChildren().add(textfieldBox3);
        VBox textareaBox = new VBox();
        textareaBox.setSpacing(10);
        textareaBox.setPadding(new Insets(10));
        TextArea area = new TextArea();
        area.setPromptText("TextArea with promptText");
        area.setPrefWidth(290);
        area.setPrefHeight(50);
        area.setPrefColumnCount(80);
        textareaBox.getChildren().add(area);
        TextArea area2 = new TextArea();
        area2.setText("Disabled");
        area2.setDisable(true);
        area2.setPrefWidth(290);
        area2.setPrefHeight(50);
        textareaBox.getChildren().add(area2);
        txts.getChildren().add(textareaBox);
        tabTexts.setContent(txts);
        buttonTabPane.getTabs().add(tabTexts);

        pane.setCenter(buttonTabPane);

        TabPane tabPane = new TabPane();

        Tab tabChoiceBox = new Tab();
        tabChoiceBox.setText("Combo- etc");
        VBox collectorVBox = new VBox();
        HBox choiceBoxBox = new HBox();
        choiceBoxBox.setSpacing(10);
        choiceBoxBox.setPadding(new Insets(10));
        ChoiceBox<String> choices = new ChoiceBox<String>(FXCollections.observableArrayList("4", "10", "12"));
        choices.getSelectionModel().selectFirst();
        choiceBoxBox.getChildren().add(choices);
        ChoiceBox<String> choices2 = new ChoiceBox<String>(FXCollections.observableArrayList("A", "B", "C"));
        choices2.getSelectionModel().selectFirst();
        choices2.setDisable(true);
        choiceBoxBox.getChildren().add(choices2);
        collectorVBox.getChildren().add(choiceBoxBox);
        ObservableList<String> items = FXCollections.observableArrayList("A", "B", "C");
        HBox editableComboBoxBox =new HBox();
        editableComboBoxBox.setSpacing(10);
        editableComboBoxBox.setPadding(new Insets(10));
        ComboBox<String> combo1 = new ComboBox<String>(items);
        combo1.setEditable(true);
        editableComboBoxBox.getChildren().add(combo1);
        ComboBox<String> combo2 =  new ComboBox<String>(items);
        combo2.setDisable(true);
        combo2.setEditable(true);
        editableComboBoxBox.getChildren().add(combo2);
        collectorVBox.getChildren().add(editableComboBoxBox);
        HBox comboBoxBox = new HBox();
        comboBoxBox.setSpacing(10);
        comboBoxBox.setPadding(new Insets(10));
        ComboBox<String> combo3 =  new ComboBox<String>(items);
        combo3.setPromptText("test");
        combo3.setEditable(false);
        comboBoxBox.getChildren().add(combo3);
        ComboBox<String> combo4 = new ComboBox<String>(items);
        combo4.setPromptText("test");
        combo4.setEditable(false);
        combo4.setDisable(true);
        comboBoxBox.getChildren().add(combo4);
        collectorVBox.getChildren().add(comboBoxBox);

        HBox colorPickerBox = new HBox();
        colorPickerBox.setSpacing(10);
        colorPickerBox.setPadding(new Insets(10));
        ColorPicker color = new ColorPicker(Color.rgb(194, 222, 254));
        colorPickerBox.getChildren().add(color);
        ColorPicker color2 = new ColorPicker(Color.rgb(194, 222, 254));
        color2.getStyleClass().add("button");
        colorPickerBox.getChildren().add(color2);
        ColorPicker color3 = new ColorPicker(Color.rgb(194, 222, 254));
        color3.getStyleClass().add("split-button");
        colorPickerBox.getChildren().add(color3);
        collectorVBox.getChildren().add(colorPickerBox);
        tabChoiceBox.setContent(collectorVBox);
        tabPane.getTabs().add(tabChoiceBox);

View Full Code Here


        SplitMenuButton m2 = new SplitMenuButton();
        m2.setText("Shutdown");
        m2.getItems().addAll(new MenuItem("Logout"), new MenuItem("Sleep"));
        m2.setPopupSide(Side.RIGHT);

        ColorPicker colorTB = new ColorPicker(Color.rgb(194, 222, 254));

        Separator seperateIt = new Separator();
        ToggleGroup toolbarGroup = new ToggleGroup();
        ToggleButton sampleButton4 = new ToggleButton("TG1");
        sampleButton4.setToggleGroup(toolbarGroup);
View Full Code Here

        Button strikeBtn = createButton("strikethrough", () -> toggleStrikethrough());
        ComboBox<Integer> sizeCombo = new ComboBox<>(FXCollections.observableArrayList(5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 48, 56, 64, 72));
        sizeCombo.getSelectionModel().select(Integer.valueOf(12));
        ComboBox<String> familyCombo = new ComboBox<>(FXCollections.observableList(Font.getFamilies()));
        familyCombo.getSelectionModel().select("Serif");
        ColorPicker textColorPicker = new ColorPicker(Color.BLACK);

        sizeCombo.setOnAction(evt -> updateFontSize(sizeCombo.getValue()));
        familyCombo.setOnAction(evt -> updateFontFamily(familyCombo.getValue()));
        textColorPicker.valueProperty().addListener((o, old, color) -> updateTextColor(color));

        undoBtn.disableProperty().bind(Bindings.not(area.undoAvailableProperty()));
        redoBtn.disableProperty().bind(Bindings.not(area.redoAvailableProperty()));

        BooleanBinding selectionEmpty = new BooleanBinding() {
            { bind(area.selectionProperty()); }

            @Override
            protected boolean computeValue() {
                return area.getSelection().getLength() == 0;
            }
        };

        cutBtn.disableProperty().bind(selectionEmpty);
        copyBtn.disableProperty().bind(selectionEmpty);

        area.beingUpdatedProperty().addListener((o, old, beingUpdated) -> {
            if(!beingUpdated) {
                boolean bold, italic, underline, strike;
                Integer fontSize;
                String fontFamily;
                Color textColor;

                IndexRange selection = area.getSelection();
                if(selection.getLength() != 0) {
                    StyleSpans<StyleInfo> styles = area.getStyleSpans(selection);
                    bold = styles.styleStream().anyMatch(s -> s.bold.orElse(false));
                    italic = styles.styleStream().anyMatch(s -> s.italic.orElse(false));
                    underline = styles.styleStream().anyMatch(s -> s.underline.orElse(false));
                    strike = styles.styleStream().anyMatch(s -> s.strikethrough.orElse(false));
                    int[] sizes = styles.styleStream().mapToInt(s -> s.fontSize.orElse(-1)).distinct().toArray();
                    fontSize = sizes.length == 1 ? sizes[0] : -1;
                    String[] families = styles.styleStream().map(s -> s.fontFamily.orElse(null)).distinct().toArray(i -> new String[i]);
                    fontFamily = families.length == 1 ? families[0] : null;
                    Color[] colors = styles.styleStream().map(s -> s.textColor.orElse(null)).distinct().toArray(i -> new Color[i]);
                    textColor = colors.length == 1 ? colors[0] : null;
                } else {
                    int p = area.getCurrentParagraph();
                    int col = area.getCaretColumn();
                    StyleInfo style = area.getStyleAtPosition(p, col);
                    bold = style.bold.orElse(false);
                    italic = style.italic.orElse(false);
                    underline = style.underline.orElse(false);
                    strike = style.strikethrough.orElse(false);
                    fontSize = style.fontSize.orElse(-1);
                    fontFamily = style.fontFamily.orElse(null);
                    textColor = style.textColor.orElse(null);
                }

                updatingToolbar.onWhile(() -> {
                    if(bold) {
                        if(!boldBtn.getStyleClass().contains("pressed")) {
                            boldBtn.getStyleClass().add("pressed");
                        }
                    } else {
                        boldBtn.getStyleClass().remove("pressed");
                    }

                    if(italic) {
                        if(!italicBtn.getStyleClass().contains("pressed")) {
                            italicBtn.getStyleClass().add("pressed");
                        }
                    } else {
                        italicBtn.getStyleClass().remove("pressed");
                    }

                    if(underline) {
                        if(!underlineBtn.getStyleClass().contains("pressed")) {
                            underlineBtn.getStyleClass().add("pressed");
                        }
                    } else {
                        underlineBtn.getStyleClass().remove("pressed");
                    }

                    if(strike) {
                        if(!strikeBtn.getStyleClass().contains("pressed")) {
                            strikeBtn.getStyleClass().add("pressed");
                        }
                    } else {
                        strikeBtn.getStyleClass().remove("pressed");
                    }

                    if(fontSize != -1) {
                        sizeCombo.getSelectionModel().select(fontSize);
                    } else {
                        sizeCombo.getSelectionModel().clearSelection();
                    }

                    if(fontFamily != null) {
                        familyCombo.getSelectionModel().select(fontFamily);
                    } else {
                        familyCombo.getSelectionModel().clearSelection();
                    }

                    if(textColor != null) {
                        textColorPicker.setValue(textColor);
                    }
                });
            }
        });
View Full Code Here

*/
public class ColorPickerFactory implements Callback<Void, FXFormNode> {

    @Override
    public FXFormNode call(Void aVoid) {
        ColorPicker colorPicker = new ColorPicker();
        return new FXFormNodeWrapper(colorPicker, colorPicker.valueProperty());
    }
View Full Code Here

TOP

Related Classes of javafx.scene.control.ColorPicker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.