Java Code Examples for javafx.scene.control.Button#setStyle()
The following examples show how to use
javafx.scene.control.Button#setStyle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AwesomeFontDemo.java From bisq with GNU Affero General Public License v3.0 | 8 votes |
@Override public void start(Stage primaryStage) { FlowPane flowPane = new FlowPane(); flowPane.setStyle("-fx-background-color: #ddd;"); flowPane.setHgap(2); flowPane.setVgap(2); List<AwesomeIcon> values = new ArrayList<>(Arrays.asList(AwesomeIcon.values())); values.sort((o1, o2) -> o1.name().compareTo(o2.name())); for (AwesomeIcon icon : values) { Label label = new Label(); Button button = new Button(icon.name(), label); button.setStyle("-fx-background-color: #fff;"); AwesomeDude.setIcon(label, icon, "12"); flowPane.getChildren().add(button); } primaryStage.setScene(new Scene(flowPane, 1200, 950)); primaryStage.show(); }
Example 2
Source File: FxlDemo.java From fxldemo-gradle with Apache License 2.0 | 7 votes |
public void start(Stage stage) throws Exception { stage.setTitle("Hello World"); stage.initStyle(StageStyle.UNDECORATED); Label label = new Label(stage.getTitle()); label.setStyle("-fx-font-size: 25"); // Alibi for including ControlsFX Dependency :) SegmentedButton fxcontrol = new SegmentedButton(new ToggleButton("One"), new ToggleButton("Two"), new ToggleButton("Three")); Button exitButton = new Button("Exit"); exitButton.setStyle("-fx-font-weight: bold"); exitButton.setOnAction(event -> Platform.exit()); VBox root = new VBox(label, fxcontrol, exitButton); root.setAlignment(Pos.CENTER); root.setSpacing(20); root.setPadding(new Insets(25)); root.setStyle("-fx-border-color: lightblue"); stage.setScene(new Scene(root)); stage.show(); }
Example 3
Source File: HelloWorld.java From Learn-Java-12-Programming with MIT License | 7 votes |
public void start4(Stage primaryStage) { Text txt = new Text("Hello, world!"); txt.setId("text-hello"); txt.relocate(115, 40); Button btn = new Button("Exit"); btn.setStyle("-fx-text-fill: white; -fx-background-color: red;"); btn.relocate(155, 80); btn.setOnAction(e -> { System.out.println("Bye! See you later!"); Platform.exit(); }); Pane pane = new Pane(); pane.getChildren().addAll(txt, btn); Scene scene = new Scene(pane, 350, 150); scene.getStylesheets().add("/mystyle.css"); primaryStage.setTitle("The primary stage (top-level container)"); primaryStage.onCloseRequestProperty() .setValue(e -> System.out.println("\nBye! See you later!")); primaryStage.setScene(scene); primaryStage.show(); }
Example 4
Source File: CFileChooser.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
@Override public Node getNode( PageActionManager actionmanager, CPageData inputdata, Window parentwindow, TabPane[] parenttabpanes, CollapsibleNode nodetocollapsewhenactiontriggered) { FlowPane thispane = new FlowPane(); Label thislabel = new Label(title); thislabel.setFont(Font.font(thislabel.getFont().getName(), FontPosture.ITALIC, thislabel.getFont().getSize())); thislabel.setMinWidth(120); thislabel.setWrapText(true); thislabel.setMaxWidth(120); thispane.setRowValignment(VPos.TOP); thispane.getChildren().add(thislabel); filepathfield = new TextField(); Button loadfromfile = new Button("Select"); loadfromfile.setStyle("-fx-base: #ffffff; -fx-hover-base: #ddeeff;"); thispane.getChildren().add(filepathfield); thispane.getChildren().add(loadfromfile); loadfromfile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { FileChooser fileChooser = new FileChooser(); selectedfile = fileChooser.showOpenDialog(null); if (selectedfile != null) filepathfield.setText(selectedfile.getAbsolutePath()); } }); return thispane; }
Example 5
Source File: ShipTablePane.java From logbook-kai with MIT License | 6 votes |
@Override protected void updateItem(Set<String> labels, boolean empty) { super.updateItem(labels, empty); if (!empty) { FlowPane pane = new FlowPane(); for (String label : labels) { Button button = new Button(label); button.setStyle("-fx-color: " + this.colorCode(label.hashCode())); button.setOnAction(this::handle); pane.getChildren().add(button); } this.setGraphic(pane); this.setText(null); } else { this.setGraphic(null); this.setText(null); } }
Example 6
Source File: PageEditPane.java From PDF4Teachers with Apache License 2.0 | 6 votes |
private Button getCustomButton(Image image, String nonTranslatedToolTip){ Button button = new Button(); button.setStyle("-fx-background-color: white;"); Builders.setHBoxPosition(button, 30, 30, 0); button.setCursor(Cursor.HAND); button.setGraphic(Builders.buildImage(image, 30, 30)); button.setTooltip(Builders.genToolTip(TR.tr(nonTranslatedToolTip))); return button; }
Example 7
Source File: BreakingNewsDemoView.java From htm.java-examples with GNU Affero General Public License v3.0 | 6 votes |
public SegmentedButtonBar createShowLogButton(VBox vBox) { Button logButton = new Button("Show Activity"); logButton.getStyleClass().add("only"); logButton.setStyle("-fx-font-size: 10; -fx-padding: 4 12 4 12; -fx-height: 10;"); logButton.setPrefHeight(10); logButton.setPrefWidth(150); vBox.widthProperty().addListener((v, o, n) -> { logButton.setLayoutX(n.doubleValue() / 2.0 - 75); }); logButton.setOnAction(e -> { flipStateProperty.set(state = state == FlipState.ON_FRONT ? FlipState.ON_BACK : FlipState.ON_FRONT); logButton.setText(state == FlipState.ON_FRONT ? "Show Activity" : "Show Fingerprints"); }); SegmentedButtonBar buttonBar3 = new SegmentedButtonBar(); buttonBar3.getChildren().addAll(logButton); buttonBar3.setPrefHeight(10); return buttonBar3; }
Example 8
Source File: GameBoardView.java From metastone with GNU General Public License v2.0 | 5 votes |
private Button createSummonHelper() { ImageView icon = new ImageView(IconFactory.getSummonHelper()); icon.setFitWidth(32); icon.setFitHeight(32); Button helper = new Button("", icon); helper.setStyle("-fx-padding: 2 2 2 2;"); helper.setVisible(false); helper.setManaged(false); return helper; }
Example 9
Source File: FxlDemo.java From fxldemo with Apache License 2.0 | 5 votes |
public void start(Stage stage) throws Exception { stage.setTitle("Hello World"); stage.initStyle(StageStyle.UNDECORATED); Label label = new Label(stage.getTitle()); label.setStyle("-fx-font-size: 25"); // Alibi for including ControlsFX Dependency :) SegmentedButton fxcontrol = new SegmentedButton(new ToggleButton("One"), new ToggleButton("Two"), new ToggleButton("Three")); // Did we get any arguments? getParameters().getNamed().forEach((name, value) -> System.out.println(String.format("%s=%s", name, value))); Button fxmlButton = new Button("Open FXML View"); fxmlButton.setOnAction(this::openFxmlView); Button exitButton = new Button("Exit"); exitButton.setStyle("-fx-font-weight: bold"); exitButton.setOnAction(event -> Platform.exit()); HBox buttons = new HBox(10, fxmlButton, exitButton); VBox root = new VBox(label, fxcontrol, buttons); root.setAlignment(Pos.CENTER); root.setSpacing(20); root.setPadding(new Insets(25)); root.setStyle("-fx-border-color: lightblue"); stage.setScene(new Scene(root)); stage.show(); }
Example 10
Source File: OptionStage.java From xframium-java with GNU General Public License v3.0 | 5 votes |
private void buildComboBoxes () { spyFolder = prefs.get ("SpyFolder", ""); String fileText = prefs.get ("ReplayFile", ""); fileComboBox = new ComboBox<> (getSessionFiles (spyFolder)); fileComboBox.setPrefWidth (COMBO_BOX_WIDTH); fileComboBox.setVisibleRowCount (15); fileComboBox.getSelectionModel ().select (fileText); String serverSelected = prefs.get ("ServerName", ""); serverComboBox = serverSitesListStage.getComboBox (); serverComboBox.setPrefWidth (COMBO_BOX_WIDTH); serverComboBox.setVisibleRowCount (5); serverComboBox.getSelectionModel ().select (serverSelected); String clientSelected = prefs.get ("ClientName", ""); clientComboBox = clientSitesListStage.getComboBox (); clientComboBox.setPrefWidth (COMBO_BOX_WIDTH); clientComboBox.setVisibleRowCount (5); clientComboBox.getSelectionModel ().select (clientSelected); editServersButton = serverSitesListStage.getEditButton (); editServersButton.setStyle (EDIT_BUTTON_FONT_SIZE); editServersButton.setMinWidth (EDIT_BUTTON_WIDTH); editClientsButton = clientSitesListStage.getEditButton (); editClientsButton.setStyle (EDIT_BUTTON_FONT_SIZE); editClientsButton.setMinWidth (EDIT_BUTTON_WIDTH); editLocationButton = new Button ("Folder..."); editLocationButton.setStyle (EDIT_BUTTON_FONT_SIZE); editLocationButton.setMinWidth (EDIT_BUTTON_WIDTH); }
Example 11
Source File: ColorButtonSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ColorButtonSample() { HBox hBox = new HBox(); hBox.setSpacing(5); for(int i=0; i<7; i++) { Button b = new Button("Color"); b.setStyle("-fx-base: rgb("+(10*i)+","+(20*i)+","+(10*i)+");"); hBox.getChildren().add(b); } HBox hBox2 = new HBox(); hBox2.setSpacing(5); hBox2.setTranslateY(30); Button red = new Button("Red"); red.setStyle("-fx-base: red;"); Button orange = new Button("Orange"); orange.setStyle("-fx-base: orange;"); Button yellow = new Button("Yellow"); yellow.setStyle("-fx-base: yellow;"); Button green = new Button("Green"); green.setStyle("-fx-base: green;"); Button blue = new Button("Blue"); blue.setStyle("-fx-base: rgb(30,170,255);"); Button indigo = new Button("Indigo"); indigo.setStyle("-fx-base: blue;"); Button violet = new Button("Violet"); violet.setStyle("-fx-base: purple;"); hBox2.getChildren().add(red); hBox2.getChildren().add(orange); hBox2.getChildren().add(yellow); hBox2.getChildren().add(green); hBox2.getChildren().add(blue); hBox2.getChildren().add(indigo); hBox2.getChildren().add(violet); VBox vBox = new VBox(20); vBox.getChildren().addAll(hBox,hBox2); getChildren().add(vBox); }
Example 12
Source File: StageSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public StageSample() { //create a button for initializing our new stage Button button = new Button("Create a Stage"); button.setStyle("-fx-font-size: 24;"); button.setDefaultButton(true); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { final Stage stage = new Stage(); //create root node of scene, i.e. group Group rootGroup = new Group(); //create scene with set width, height and color Scene scene = new Scene(rootGroup, 200, 200, Color.WHITESMOKE); //set scene to stage stage.setScene(scene); //center stage on screen stage.centerOnScreen(); //show the stage stage.show(); //add some node to scene Text text = new Text(20, 110, "JavaFX"); text.setFill(Color.DODGERBLUE); text.setEffect(new Lighting()); text.setFont(Font.font(Font.getDefault().getFamily(), 50)); //add text to the main root group rootGroup.getChildren().add(text); } }); getChildren().add(button); }
Example 13
Source File: ColorButtonSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ColorButtonSample() { HBox hBox = new HBox(); hBox.setSpacing(5); for(int i=0; i<7; i++) { Button b = new Button("Color"); b.setStyle("-fx-base: rgb("+(10*i)+","+(20*i)+","+(10*i)+");"); hBox.getChildren().add(b); } HBox hBox2 = new HBox(); hBox2.setSpacing(5); hBox2.setTranslateY(30); Button red = new Button("Red"); red.setStyle("-fx-base: red;"); Button orange = new Button("Orange"); orange.setStyle("-fx-base: orange;"); Button yellow = new Button("Yellow"); yellow.setStyle("-fx-base: yellow;"); Button green = new Button("Green"); green.setStyle("-fx-base: green;"); Button blue = new Button("Blue"); blue.setStyle("-fx-base: rgb(30,170,255);"); Button indigo = new Button("Indigo"); indigo.setStyle("-fx-base: blue;"); Button violet = new Button("Violet"); violet.setStyle("-fx-base: purple;"); hBox2.getChildren().add(red); hBox2.getChildren().add(orange); hBox2.getChildren().add(yellow); hBox2.getChildren().add(green); hBox2.getChildren().add(blue); hBox2.getChildren().add(indigo); hBox2.getChildren().add(violet); VBox vBox = new VBox(20); vBox.getChildren().addAll(hBox,hBox2); getChildren().add(vBox); }
Example 14
Source File: OptionStage.java From dm3270 with Apache License 2.0 | 5 votes |
private void buildComboBoxes () { spyFolder = prefs.get ("SpyFolder", ""); String fileText = prefs.get ("ReplayFile", ""); fileComboBox = new ComboBox<> (getSessionFiles (spyFolder)); fileComboBox.setPrefWidth (COMBO_BOX_WIDTH); fileComboBox.setVisibleRowCount (15); fileComboBox.getSelectionModel ().select (fileText); String serverSelected = prefs.get ("ServerName", ""); serverComboBox = serverSitesListStage.getComboBox (); serverComboBox.setPrefWidth (COMBO_BOX_WIDTH); serverComboBox.setVisibleRowCount (5); serverComboBox.getSelectionModel ().select (serverSelected); String clientSelected = prefs.get ("ClientName", ""); clientComboBox = clientSitesListStage.getComboBox (); clientComboBox.setPrefWidth (COMBO_BOX_WIDTH); clientComboBox.setVisibleRowCount (5); clientComboBox.getSelectionModel ().select (clientSelected); editServersButton = serverSitesListStage.getEditButton (); editServersButton.setStyle (EDIT_BUTTON_FONT_SIZE); editServersButton.setMinWidth (EDIT_BUTTON_WIDTH); editClientsButton = clientSitesListStage.getEditButton (); editClientsButton.setStyle (EDIT_BUTTON_FONT_SIZE); editClientsButton.setMinWidth (EDIT_BUTTON_WIDTH); editLocationButton = new Button ("Folder..."); editLocationButton.setStyle (EDIT_BUTTON_FONT_SIZE); editLocationButton.setMinWidth (EDIT_BUTTON_WIDTH); }
Example 15
Source File: PluginParametersPane.java From constellation with Apache License 2.0 | 5 votes |
private static Button buildHelpButton(final String helpId, final String helpForLabel) { final Button helpButton = new Button("", new ImageView(UserInterfaceIconProvider.HELP.buildImage(16, ConstellationColor.BLUEBERRY.getJavaColor()))); helpButton.paddingProperty().set(HELP_INSETS); helpButton.setTooltip(new Tooltip(String.format("Display help for %s", helpForLabel))); helpButton.setOnAction(event -> { if (!new HelpCtx(helpId).display()) { StatusDisplayer.getDefault().setStatusText(String.format("Help for %s not found.", helpForLabel)); } }); // Get rid of the ugly button look so the icon stands alone. helpButton.setStyle("-fx-border-color: transparent;-fx-background-color: transparent;"); return helpButton; }
Example 16
Source File: HelloWebView.java From mars-sim with GNU General Public License v3.0 | 4 votes |
@Override public void start(Stage stage) { List<String> args = getParameters().getRaw(); final String initialURL = args.size() > 0 ? args.get(0) : DEFAULT_URL; final WebView webView = new WebView(); final WebEngine webEngine = webView.getEngine(); final TextField urlBox = new TextField(); urlBox.setMinHeight(NAVI_BAR_MIN_DIMENSION); urlBox.setText(initialURL); HBox.setHgrow(urlBox, Priority.ALWAYS); urlBox.setOnAction(e -> webEngine.load(urlBox.getText())); //- Button goButton = new Button("Go"); //- goButton.setOnAction(e -> webEngine.load(urlBox.getText())); final Label bottomTitle = new Label(); bottomTitle.textProperty().bind(urlBox.textProperty()); //- HBox naviBar = new HBox(); //- naviBar.getChildren().addAll(urlBox, goButton); final Button goStopButton = new Button(goButtonUnicodeSymbol); goStopButton.setStyle(buttonStyle); goStopButton.setOnAction(e -> webEngine.load(urlBox.getText())); //- BorderPane root = new BorderPane(); //- root.setTop(naviBar); //- root.setCenter(webView); final Button backButton = new Button(backButtonUnicodeSymbol); backButton.setStyle(buttonStyle); backButton.setDisable(true); backButton.setOnAction(e -> webEngine.getHistory().go(-1)); //- webEngine.locationProperty().addListener((obs, oVal, nVal) //- -> urlBox.setText(nVal)); final Button forwardButton = new Button(forwardButtonUnicodeSymbol); forwardButton.setStyle(buttonStyle); forwardButton.setDisable(true); forwardButton.setOnAction(e -> webEngine.getHistory().go(+1)); final Button reloadButton = new Button(reloadButtonUnicodeSymbol); reloadButton.setStyle(buttonStyle); reloadButton.setOnAction(e -> webEngine.reload()); final HBox naviBar = new HBox(); naviBar.getChildren().addAll(backButton, forwardButton, urlBox, reloadButton, goStopButton); naviBar.setPadding(new Insets(PADDING_VALUE)); // Small padding in the navigation Bar final VBox root = new VBox(); root.getChildren().addAll(naviBar, webView, bottomTitle); VBox.setVgrow(webView, Priority.ALWAYS); webEngine.locationProperty().addListener((observable, oldValue, newValue) -> urlBox.setText(newValue)); // If the Worker.State is in lower State than SUCCEEDED (i.e. in READY, SCHEDULED or RUNNING State), // then the goStopButton should be in 'Stop' configuration // else the goStopButton should be in 'Go' configuration webEngine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> { if (newValue.compareTo(Worker.State.SUCCEEDED) < 0) { bottomTitle.setVisible(true); goStopButton.setText(stopButtonUnicodeSymbol); goStopButton.setOnAction(e -> webEngine.getLoadWorker().cancel()); } else { bottomTitle.setVisible(false); goStopButton.setText(goButtonUnicodeSymbol); goStopButton.setOnAction(e -> webEngine.load(urlBox.getText())); } }); webEngine.getHistory().currentIndexProperty().addListener((observable, oldValue, newValue) -> { int length = webEngine.getHistory().getEntries().size(); backButton.setDisable((int)newValue == 0); forwardButton.setDisable((int)newValue >= length - 1); }); webEngine.load(initialURL); Scene scene = new Scene(root); stage.setScene(scene); //- SimpleStringProperty titleProp = new SimpleStringProperty("HelloWebView: "); SimpleStringProperty titleProp = new SimpleStringProperty("HelloWebView" + " (" + System.getProperty("java.version") + ") : "); stage.titleProperty().bind(titleProp.concat(urlBox.textProperty())); stage.show(); }
Example 17
Source File: UICodePluginItem.java From tcMenu with Apache License 2.0 | 4 votes |
public UICodePluginItem(CodePluginManager mgr, CodePluginItem item, UICodeAction action, Consumer<CodePluginItem> evt) { super(); this.eventHandler = evt; this.mgr = mgr; this.item = item; titleLabel = new Label(item.getDescription()); titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 110%;"); descriptionArea = new Label(item.getExtendedDescription()); descriptionArea.setWrapText(true); descriptionArea.setAlignment(Pos.TOP_LEFT); descriptionArea.setPrefWidth(1900); whichPlugin = new Label("Plugin loading"); whichPlugin.setStyle("-fx-font-size: 90%;"); whichPlugin.setPadding(new Insets(10, 5, 5, 5)); licenseLink = new Hyperlink("License unknown"); licenseLink.setDisable(true); licenseLink.setPadding(new Insets(10, 0, 5, 0)); licenseLink.setStyle("-fx-font-size: 90%;"); vendorLink = new Hyperlink("Vendor unknown"); vendorLink.setDisable(true); vendorLink.setPadding(new Insets(10, 0, 5, 0)); vendorLink.setStyle("-fx-font-size: 90%;"); docsLink = new Hyperlink("No Docs"); docsLink.setDisable(true); docsLink.setPadding(new Insets(10, 0, 5, 0)); docsLink.setStyle("-fx-font-size: 90%;"); infoContainer = new HBox(5); infoContainer.setAlignment(Pos.CENTER_LEFT); infoContainer.getChildren().add(whichPlugin); infoContainer.getChildren().add(docsLink); infoContainer.getChildren().add(licenseLink); infoContainer.getChildren().add(vendorLink); innerBorder = new BorderPane(); innerBorder.setPadding(new Insets(4)); innerBorder.setTop(titleLabel); innerBorder.setCenter(descriptionArea); innerBorder.setBottom(infoContainer); actionButton = new Button(action == UICodeAction.CHANGE ? "Change" : "Select"); actionButton.setStyle("-fx-font-size: 110%; -fx-font-weight: bold;"); actionButton.setMaxSize(2000, 2000); actionButton.setOnAction(event-> eventHandler.accept(item)); setRight(actionButton); setCenter(innerBorder); setItem(item); }
Example 18
Source File: SortManager.java From PDF4Teachers with Apache License 2.0 | 4 votes |
public void setup(GridPane parent, String selectedButtonName, String... buttonsName){ int row = 0; for(String buttonName : buttonsName){ if(buttonName.equals("\n")){ row++; continue; } Button button = new Button(buttonName); button.setGraphic(Builders.buildImage(getClass().getResource("/img/Sort/up.png")+"", 0, 0)); button.setAlignment(Pos.CENTER_LEFT); button.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(button, Priority.ALWAYS); BooleanProperty order = new SimpleBooleanProperty(true); buttons.put(button, order); parent.addRow(row, button); if(selectedButtonName.equals(buttonName)){ selectedButton.set(button); button.setStyle("-fx-background-color: " + selectedColor + ";"); }else button.setStyle("-fx-background-color: " + StyleManager.getHexAccentColor() + ";"); // Image de l'ordre order.addListener(new ChangeListener<>() { @Override public void changed(ObservableValue<? extends Boolean> observableValue, Boolean lastOrder, Boolean newOrder) { button.setGraphic(Builders.buildImage(getClass().getResource(newOrder ? "/img/Sort/up.png" : "/img/Sort/down.png") + "", 0, 0)); } }); // Change selectedButton lors du clic ET update l'ordre button.setOnAction(actionEvent -> { if(selectedButton.get() == button){ order.set(!order.get()); updateSort.call(button.getText(), order.get()); }else selectedButton.set(button); }); } if(selectedButton.get() == null){ selectedButton.set(buttons.keySet().iterator().next()); buttons.keySet().iterator().next().setStyle("-fx-background-color: " + selectedColor); } // Couleurs des boutons selectedButton.addListener((observableValue, lastSelected, newSelected) -> { lastSelected.setStyle("-fx-background-color: " + StyleManager.getHexAccentColor() + ";"); newSelected.setStyle("-fx-background-color: " + selectedColor + ";"); updateSort.call(newSelected.getText(), buttons.get(newSelected).get()); }); }
Example 19
Source File: CActionButton.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public Node getNode( PageActionManager actionmanager, CPageData inputdata, Window parentwindow, TabPane[] parenttabpanes, CollapsibleNode nodetocollapsewhenactiontriggered) { if (this.conditionalshow) { DataElt thiselement = inputdata.lookupDataElementByName(conditionalshowdatareference.getName()); if (thiselement == null) throw new RuntimeException(String.format( "could not find any page data with name = %s" + conditionalshowdatareference.getName())); if (!thiselement.getType().equals(conditionalshowdatareference.getType())) throw new RuntimeException( String.format("page data with name = %s does not have expected %s type, actually found %s", conditionalshowdatareference.getName(), conditionalshowdatareference.getType(), thiselement.getType())); ChoiceDataElt<?> thischoiceelement = (ChoiceDataElt<?>) thiselement; if (thischoiceelement.getStoredValue().compareTo("YES") != 0) return new Label(""); } button = new Button(label); button.setStyle("-fx-base: #ffffff; -fx-hover-base: #ddeeff;"); button.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE); button.textOverrunProperty().set(OverrunStyle.CLIP); // button.setMinWidth((new // Text(this.label).getBoundsInLocal().getWidth()+20)*1.3); if (tooltip != null) button.setTooltip(new Tooltip("tooltip")); if (!this.hasconfirmationmessage) { if (action != null) { actionmanager.registerEvent(button, action); if (callback != null) actionmanager.registerCallback(button, callback); buttonhandler = new ButtonHandler(actionmanager); button.setOnMouseClicked(buttonhandler); } if (inlineaction != null) { if (nodetocollapsewhenactiontriggered != null) inlineaction.setNodeToCollapse(nodetocollapsewhenactiontriggered); if (this.forcepopuphidewheninline) { actionmanager.registerInlineActionwithPopupClose(button, inlineaction); } else { actionmanager.registerInlineAction(button, inlineaction); } buttonhandler = new ButtonHandler(actionmanager); button.setOnMouseClicked(buttonhandler); } } if (this.hasconfirmationmessage) { button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("User Confirmation"); alert.setContentText(confirmationmessage); ButtonType continuetype = new ButtonType(confirmationmessagecontinuelabel); ButtonType stoptype = new ButtonType(confirmationmessagestoplabel); alert.getButtonTypes().setAll(continuetype, stoptype); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == continuetype) { if (action != null) { if (callback != null) actionmanager.directfireEvent(action, callback); if (callback == null) actionmanager.directfireEvent(action); } if (inlineaction != null) { if (forcepopuphidewheninline) inlineaction.forcePopupClose(); actionmanager.directfireInlineEvent(inlineaction); } } } }); } return button; }
Example 20
Source File: CPopupButton.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public Node getNode( PageActionManager actionmanager, CPageData inputdata, Window parentwindow, TabPane[] parenttabpanes, CollapsibleNode nodetocollapsewhenactiontriggered) { Button button = new Button(label); button.setStyle("-fx-base: #ffffff; -fx-hover-base: #ddeeff;"); Label hamburgerlabel = new Label("\u2630"); hamburgerlabel.setFont(Font.font(hamburgerlabel.getFont().getFamily(), FontWeight.THIN, hamburgerlabel.getFont().getSize() * 0.5f)); button.setGraphic(hamburgerlabel); button.setContentDisplay(ContentDisplay.RIGHT); button.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE); button.textOverrunProperty().set(OverrunStyle.CLIP); if (rollovertip != null) if (rollovertip.length() > 0) button.setTooltip(new Tooltip(rollovertip)); // --------- setup popup window button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { try { CPopupButton.generateAndShowPopup(button, payload.getNode(actionmanager, inputdata, parentwindow, new TabPane[0],nodetocollapsewhenactiontriggered), inputdata, parentwindow, allowscroll, showunderwidget); } catch (Exception e) { logger.severe("Unexpected exception " + e.getMessage()); for (int i = 0; i < e.getStackTrace().length; i++) logger.severe(" + " + e.getStackTrace()[i].toString()); } } }); // ------------------------ return button; }