private Parent createRightPane() { HBox hbox = new HBox(10); VBox lbox = new VBox(10); lbox.getChildren().addAll(targetControlPane, new Separator(), new Text("Target control type:"), createControlCombo(targetControlPane, false), new Text("Target transfer modes:"), createTMSelect(targetModes)); VBox rbox = new VBox(10); rbox.getChildren().addAll(new Text("Data formats:"), createFormatSelect(targetFormats), ButtonBuilder.create().text("paste from clipboard").id(ID_FROM_CLIPBOARD_BUTTON).onAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { getDataFromClipboard(Clipboard.getSystemClipboard()); } }).build()); VBox content = new VBox(10); content.getChildren().addAll(new Text("Transfered content:"), transferedContentPane); hbox.getChildren().addAll(lbox, new Separator(Orientation.VERTICAL), rbox, new Separator(Orientation.VERTICAL), content); if (parameters.size() > 0) { hbox.setStyle("-fx-background-color: " + parameters.get(0) + ";"); } return hbox; }
@Override public void addControlSpecificButtons(Pane pane) { Button button = ButtonBuilder.create().id(ADD_TEXT_BUTTON_ID).text("Add much text").build(); button.setOnAction(new EventHandler() { public void handle(Event t) { for (int i = 0; i < 1000; i++) { TextArea ta = (TextArea) testedTextInput; ta.setText(ta.getText() + " some text"); if (i % 10 == 0) { ta.setText(ta.getText() + "\n"); } } } }); pane.getChildren().add(button); }
private PageWithSlots getPageSlot(Pages page) { PageWithSlots pageWithSlot = new PageWithSlots(page.name(), WIDTH, HEIGHT); Pane slot = new Pane(); slot.setPrefSize(200, 200); if (page == Pages.IPHONE_TOOLBAR) { slot.getChildren().add(ToolBarBuilder.create() .id(page.name().toLowerCase()) .items( ButtonBuilder.create().text("iPhone").id("iphone").build()) .build()); } else { slot.getChildren().add(ButtonBuilder.create() .text("Button") .id(page.name().toLowerCase()) .minWidth(100) .build()); } pageWithSlot.add(new TestNodeLeaf(page.name(), slot)); return pageWithSlot; }
/** * Builds the start game panel. * * @return the node */ private Node buildStartGamePanel() { final FlowPane fp = new FlowPane(); this.playButton = ButtonBuilder.create().id("playButton") .styleClass("play") .minHeight(130) .minWidth(180) // .text("Start Game") .build(); fp.getChildren().add(this.playButton); fp.setAlignment(Pos.TOP_CENTER); return fp; }
public InsetTextButtonSample() { String insetTextCss = InsetTextButtonSample.class.getResource("InsetTextButton.css").toExternalForm(); VBox vbox = VBoxBuilder.create().id("insettextvbox").spacing(10).padding(new Insets(10)).children( ButtonBuilder.create().text("Inset Text Button").id("button1").build(), ButtonBuilder.create().text("Plain Text Button").id("button2").build()).build(); vbox.getStylesheets().add(insetTextCss); getChildren().add(vbox); }
/** * About content */ @SuppressWarnings("deprecation") private void showAboutContent() { try { Node content = FXMLLoader.load(getClass().getResource("/com/shekkar/xpanderfx/top/popup/AboutFXMLDocument.fxml")); about_box = new VBox(); about_box.getChildren().addAll(content, HBoxBuilder.create().alignment(Pos.CENTER_RIGHT) .padding(new Insets(0,3,0,0)) .children( ButtonBuilder.create().text("OK") .minHeight(40) .minWidth(70) .style("-fx-base:black;" + "-fx-border-radius: 7;" + "-fx-background-radius: 7;") .onAction(e -> this.popupCloser(about, about_box)) .font(Font.font("System", FontWeight.MEDIUM, FontPosture.REGULAR, 20)) .build() ) .build() ); about_box.setStyle("-fx-background-color: linear-gradient(black, lightgrey);" + "-fx-background-radius: 7;" + "-fx-border-radius: 7;"); about.getContent().add(about_box); } catch (IOException ex) { Logger.getLogger(MainFXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex); } about.show(this.ICON.getScene().getWindow(), this.getNodeMaxX() - 14, this.getNodeMaxY() + 12); this.popupOpener(about_box); }
/** * * @param controller * @return restart-button */ public Button getRestartButton(MainFXMLDocumentController controller) { @SuppressWarnings("deprecation") Button restart = ButtonBuilder.create().text("Restart") .minWidth(50).minHeight(24) .font(Font.font("System", FontWeight.SEMI_BOLD, FontPosture.REGULAR, 20)) .style("-fx-base:darkslategrey;" + "-fx-background-radius:7;" + "-fx-border-radius:7;") .onAction(e -> { controller.restart(); pp.hide(); }) .build(); return restart; }
/** * * @param controller * @return exit-button */ public Button getQuitButton(MainFXMLDocumentController controller) { @SuppressWarnings("deprecation") Button quit = ButtonBuilder.create().text("Exit") .minWidth(50).minHeight(24) .font(Font.font("System", FontWeight.SEMI_BOLD, FontPosture.REGULAR, 20)) .style("-fx-base:darkslategrey;" + "-fx-background-radius:7;" + "-fx-border-radius:7;") .onAction(e -> Platform.exit()) .build(); return quit; }
/** * * @return root-node */ @SuppressWarnings("deprecation") private BorderPane getBody() { return BorderPaneBuilder.create().minHeight(200).minWidth(440).center( VBoxBuilder.create().alignment(Pos.CENTER).children( LabelBuilder.create() .minHeight(10).build(), LabelBuilder.create().text("Congratulation !! You won the game.") .font(Font.font("", FontWeight.BOLD, FontPosture.ITALIC, 20)) .textFill(Color.WHITE).build(), LabelBuilder.create() .minHeight(30).build(), HBoxBuilder.create().alignment(Pos.CENTER).spacing(20).children( ButtonBuilder.create().text("Continue").font(Font.font("", FontWeight.SEMI_BOLD, FontPosture.REGULAR, 18)) .minWidth(140).textFill(Color.WHITE).style("-fx-base:darkslategrey") .onAction(e -> this.close()).build(), ButtonBuilder.create().text("Try Again").font(Font.font("", FontWeight.SEMI_BOLD, FontPosture.REGULAR, 18)) .minWidth(140).textFill(Color.WHITE).style("-fx-base:darkslategrey") .onAction(e -> { controller.restart(); this.close(); }).build() ).build() ) .build() ).style("-fx-background-color: linear-gradient(#000000cc, darkslategrey); -fx-background-radius: 15; -fx-border-radius:15;" + "-fx-border-width:1; -fx-border-color:lightgrey").build(); }
public CustomPopUp(StackPane parentWindow) { super(); this.parent = parentWindow; setMaxHeight(200); setMaxWidth(200); getChildren().add( StackPaneBuilder.create().style(style).minHeight(200).minWidth(200).alignment(Pos.TOP_RIGHT) .children(ButtonBuilder.create().text("Close").onAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent paramT) { parent.getChildren().remove(CustomPopUp.this); } }).build(), TextFieldBuilder.create().translateY(20).build()).build()); }
public CustomPopUp() { super(); getContent().add( StackPaneBuilder.create().style(style).minHeight(200).minWidth(200).alignment(Pos.TOP_RIGHT) .children(ButtonBuilder.create().text("Close").onAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent paramT) { CustomPopUp.this.hide(); } }).build(), TextFieldBuilder.create().translateY(20).build()).build()); }
@Override public void start(Stage stage) throws Exception { this.stage = stage; configureScene(); configureStage(); // Logic starts VBox vb = new VBox(); vb.setSpacing(10); final VBox layout = VBoxBuilder.create().build(); layout.getChildren().add(new DynamicTextArea()); Button btn = ButtonBuilder.create().text("Add").onAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { layout.getChildren().add(new DynamicTextArea()); } }).build(); final GridPane gridPane = GridPaneBuilder.create() .styleClass("contact-details-gridpane") // [ARE] Further modification for CAEMR-2098. Setting minimum width to show labels even if application width is changed. .columnConstraints(ColumnConstraintsBuilder.create().hgrow(Priority.NEVER).minWidth(80).build(), ColumnConstraintsBuilder.create().hgrow(Priority.ALWAYS).build(), ColumnConstraintsBuilder.create().hgrow(Priority.NEVER).minWidth(100).build()).build(); gridPane.addRow(0, new Label("hi"), layout, btn); root.getChildren().add(ScrollPaneBuilder.create().styleClass("contact-details-pane").hbarPolicy(ScrollBarPolicy.NEVER) .fitToWidth(true).content(gridPane).build()); }
/** * create the UI on first call * * @return */ private Node createUI() { final AnchorPane anchor = AnchorPaneBuilder.create() .styleClass("roundedAnchorPaneFX").build(); final Label heading = LabelBuilder.create() .text(this.getResourceBundle().getString("javafxCompTop")) .alignment(Pos.CENTER).styleClass("propLabel").build(); final Button top = ButtonBuilder.create() .text(this.getResourceBundle().getString("send")).layoutX(120) .onMouseClicked(this.getEventHandler()).alignment(Pos.CENTER) .build(); this.textField = TextFieldBuilder.create().text("") .styleClass("propTextField").alignment(Pos.CENTER).build(); AnchorPane.setBottomAnchor(top, 25.0); AnchorPane.setRightAnchor(top, 25.0); AnchorPane.setRightAnchor(heading, 50.0); AnchorPane.setTopAnchor(heading, 10.0); AnchorPane.setTopAnchor(this.textField, 50.0); AnchorPane.setRightAnchor(this.textField, 25.0); anchor.getChildren().addAll(heading, top, this.textField); GridPane.setHgrow(anchor, Priority.ALWAYS); GridPane.setVgrow(anchor, Priority.ALWAYS); return anchor; }
/** * create the UI on first call * * @return */ private Node createUI() { final AnchorPane anchor = AnchorPaneBuilder.create() .styleClass("roundedAnchorPaneFX").build(); final Label heading = LabelBuilder.create() .text(this.getResourceBundle().getString("javafxComp")) .alignment(Pos.CENTER_RIGHT).styleClass("propLabelBig").build(); final Button left = ButtonBuilder .create() .text(this.getResourceBundle().getString("send")) .layoutX(120) .onMouseClicked( this.getActionListener("id01.id003", "hello stateful component").getListener()) .alignment(Pos.CENTER).build(); this.textField = TextFieldBuilder.create().text("") .styleClass("propTextField").alignment(Pos.CENTER).build(); AnchorPane.setRightAnchor(heading, 25.0); AnchorPane.setTopAnchor(heading, 15.0); AnchorPane.setTopAnchor(left, 80.0); AnchorPane.setRightAnchor(left, 25.0); AnchorPane.setTopAnchor(this.textField, 50.0); AnchorPane.setRightAnchor(this.textField, 25.0); AnchorPane.setLeftAnchor(this.textField, 25.0); anchor.getChildren().addAll(heading, left, this.textField); GridPane.setHgrow(anchor, Priority.ALWAYS); GridPane.setVgrow(anchor, Priority.ALWAYS); return anchor; }
/** * Instantiates a new {@link ImageDisplay}. * * @param f * The file to use to construct the Image. * @param owner * The owner of the image * @param index * The index of the image in the gallery */ public ImageDisplay(File f, final Gallery owner, final int index) { this.file = f; double prefSize = 65; this.progressIndicator = ProgressIndicatorBuilder.create().progress(-1.0).prefWidth(prefSize).prefHeight(prefSize) .build(); this.button = ButtonBuilder.create().alignment(Pos.CENTER).textAlignment(TextAlignment.CENTER) .contentDisplay(ContentDisplay.TOP).graphic(progressIndicator).build(); // setAlignment(Pos.CENTER); setPrefSize(125, 125); setCenter(button); if (LJGM.instance().getConfigManager().isDebug()) { button.setText(index + "; " + file.getName()); } EventHandler<MouseEvent> click = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (!(e.getButton() == MouseButton.PRIMARY)) { return; } FullScreenView view = new FullScreenView(owner, index); view.setImage(index); view.show(); } }; button.setOnMouseClicked(click); // This is necessary because if the user clicks on the progress // indicator while it's still loading, then the image will not be // displayed. progressIndicator.setOnMouseClicked(click); }
protected void bindComponent(final BindingType btype, final Object testedControl) { this.btype = btype; String bindButtonId = ((btype == BindingType.UNIDIRECTIONAL) ? UNIDIR_PREFIX : BIDIR_PREFIX) + listeningProperty.getName().toUpperCase() + BIND_BUTTON_SUFFIX; setStyle("-fx-border-color : black;"); setSpacing(3); binding = new ToggleBindingSwitcher(leadingProperty, listeningProperty, btype); binding.getVisualRepresentation().setId(bindButtonId); String labelDescription = btype.equals(BindingType.UNIDIRECTIONAL) ? "UNIDIR" : "BIDIR"; getChildren().addAll(new Label(labelDescription.toUpperCase().substring(0, Math.min(15, labelDescription.length()) - 1)), leadingControl, binding.getVisualRepresentation()); if (btype == BindingType.UNIDIRECTIONAL) { Button setButton = ButtonBuilder.create().text("set").minWidth(38).id(SET_PREFIX + listeningProperty.getName().toUpperCase()).build(); setAction = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { //bindingTB.setSelected(false);I think, that is not obligative. //But otherwise, exception will be thrown each time, when unidirectional binding is switched on. Method setter; try { Object value = listeningProperty.getValue(); Class returnClass; if (value instanceof Boolean) { returnClass = boolean.class; } else { returnClass = testedControl.getClass().getMethod("get" + listeningProperty.getName().substring(0, 1).toUpperCase() + listeningProperty.getName().substring(1, listeningProperty.getName().length())).getReturnType(); } Object argument = leadingProperty.getValue(); if (value instanceof Integer) { argument = (int) Math.round((Double) argument); } setter = testedControl.getClass().getMethod("set" + listeningProperty.getName().substring(0, 1).toUpperCase() + listeningProperty.getName().substring(1, listeningProperty.getName().length()), returnClass); setter.invoke(testedControl, argument); } catch (Throwable ex) { log(ex); } } }; setButton.setOnAction(setAction); getChildren().add(setButton); } }
/** * Creates a {@linkplain DialogService} that displays a * login screen * * @param primaryStage * the primary application {@linkplain Stage} */ public DialogService createLoginDialog(final Stage primaryStage) { final TextField username = TextFieldBuilder.create().promptText( "Username").build(); final PasswordField password = PasswordFieldBuilder.create().promptText( "Password").build(); final Button closeBtn = ButtonBuilder.create().text("Close").build(); final Service<Void> submitService = new Service<Void>() { @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { final boolean hasUsername = !username.getText() .isEmpty(); final boolean hasPassword = !password.getText() .isEmpty(); if (hasUsername && hasPassword) { // TODO : perform some sort of authentication here // or you can throw an exception to see the error // message in the dialog window } else { final String invalidFields = (!hasUsername ? username .getPromptText() : "") + ' ' + (!hasPassword ? password.getPromptText() : ""); throw new RuntimeException("Invalid " + invalidFields); } return null; } }; } }; final DialogService dialogService = dialog(primaryStage, "Test Dialog Window", "Please provide a username and password to access the application", null, "Login", 550d, 300d, submitService, closeBtn, username, password); if (closeBtn != null) { closeBtn.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(final MouseEvent event) { dialogService.hide(); } }); } return dialogService; }
@Override public void start(final Stage primaryStage) { primaryStage.setTitle("java-buddy.blogspot.com"); Group root = new Group(); final String Santa_Claus_Is_Coming_To_Town = "You better watch out\n" + "You better not cry\n" + "Better not pout\n" + "I'm telling you why\n" + "Santa Claus is coming to town\n" + "\n" + "He's making a list\n" + "And checking it twice;\n" + "Gonna find out Who's naughty and nice\n" + "Santa Claus is coming to town\n" + "\n" + "He sees you when you're sleeping\n" + "He knows when you're awake\n" + "He knows if you've been bad or good\n" + "So be good for goodness sake!\n" + "\n" + "O! You better watch out!\n" + "You better not cry\n" + "Better not pout\n" + "I'm telling you why\n" + "Santa Claus is coming to town\n" + "Santa Claus is coming to town\n"; Text textSong = TextBuilder.create() .text(Santa_Claus_Is_Coming_To_Town) .build(); Button buttonSave = ButtonBuilder.create() .text("Save") .build(); buttonSave.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { FileChooser fileChooser = new FileChooser(); //Set extension filter FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt"); fileChooser.getExtensionFilters().add(extFilter); //Show save file dialog File file = fileChooser.showSaveDialog(primaryStage); if(file != null){ SaveFile(Santa_Claus_Is_Coming_To_Town, file); } } }); VBox vBox = VBoxBuilder.create() .children(textSong, buttonSave) .build(); root.getChildren().add(vBox); primaryStage.setScene(new Scene(root, 500, 400)); primaryStage.show(); }
@Override public void start(Stage stage) throws Exception { Button buttonToDrag1 = ButtonBuilder.create().text("Draggable Button 1").id("b1").build(); Button buttonToDrag2 = ButtonBuilder.create().text("Draggable Button 2").id("b2").build(); Button buttonToDrag3 = ButtonBuilder.create().text("Draggable Button 3").id("b3").build(); DragUtility dragUtility = new DragUtility(); dragUtility.setDragControl(buttonToDrag1); dragUtility.setDragControl(buttonToDrag2); // dragUtility.setDragControl(buttonToDrag3); HorizontalDock horizontalDock = new HorizontalDock(); horizontalDock.addChildren(buttonToDrag1); horizontalDock.addChildren(buttonToDrag2); // horizontalDock.addChildren(buttonToDrag3); dragUtility.setTargetPane(horizontalDock); stage.centerOnScreen(); Scene scene = new Scene(horizontalDock, 750, 500, Color.AQUAMARINE); stage.setScene(scene); stage.show(); }