private Scene initScene() { workspace = BorderPaneBuilder.create() .center(StackPaneBuilder.create().children(new Button()).build()) .bottom(statusBar = HBoxBuilder.create().build()) .build(); Scene scene = new Scene(workspace, 300, 250); scene.getStylesheets().add("/taskservice/testcss2.css"); return scene; }
/** * Build and return the footer panel. * * @return the footer panel */ protected Node getFooterPanel() { this.pageLabel = LabelBuilder.create() .text(String.valueOf(model().getSlide().getPage())) .font(PrezFonts.PAGE.get()) .build(); final AnchorPane ap = AnchorPaneBuilder.create().children(this.pageLabel).build(); AnchorPane.setRightAnchor(this.pageLabel, 20.0); final StackPane sp = StackPaneBuilder.create() .styleClass("footer") .prefHeight(35.0) .minHeight(Region.USE_PREF_SIZE) .maxHeight(Region.USE_PREF_SIZE) .children(ap) .build(); StackPane.setAlignment(ap, Pos.CENTER_RIGHT); return sp; }
protected Node buildButton(String url, double ancho, double largo, boolean focus) { String cadena = "Imagenes/Botones/" + url; final StackPane boton = new StackPane(); boton.setMaxWidth(ancho); boton.setMaxHeight(largo); StackPane stackPane = StackPaneBuilder.create() .children( ImageViewBuilder.create() .cursor(Cursor.HAND) .image(new Image(getClass().getResource(cadena).toString())) .fitWidth(ancho) .fitHeight(largo) .build()) .focusTraversable(focus) .onMousePressed( new EventHandler<Event>() { public void handle(Event event) { boton.setOpacity(.6f); } }) .onMouseReleased( new EventHandler<Event>() { @Override public void handle(Event event) { boton.setOpacity(1); } }) .build(); boton.getChildren().add(stackPane); return boton; }
@Override public void start(final Stage primaryStage) { // initialize the stage primaryStage.setTitle("Modal Confirm Example"); final WebView webView = new WebView(); webView.getEngine().load("http://docs.oracle.com/javafx/"); primaryStage.setScene(new Scene(webView)); primaryStage.show(); // initialize the confirmation dialog final Stage util = new Stage(StageStyle.TRANSPARENT); util.initModality(Modality.APPLICATION_MODAL); util.setScene( new Scene( StackPaneBuilder.create() .children( PaneBuilder.create().styleClass("modal-dialog-glass").build(), HBoxBuilder.create() .styleClass("modal-dialog-content") .children( LabelBuilder.create().text("Will you like this page?").build(), ButtonBuilder.create() .text("Yes") .defaultButton(true) .onAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { // take action and close the dialog. System.out.println( "Liked: " + webView.getEngine().getTitle()); primaryStage.getScene().getRoot().setEffect(null); util.close(); } }) .build(), ButtonBuilder.create() .text("No") .cancelButton(true) .onAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { // abort action and close the dialog. System.out.println( "Disliked: " + webView.getEngine().getTitle()); primaryStage.getScene().getRoot().setEffect(null); util.close(); } }) .build()) .build()) .build(), Color.TRANSPARENT)); util.getScene() .getStylesheets() .add(getClass().getResource("/assets/fxml/modal-dialog.css").toExternalForm()); // show the confirmation dialog each time a new page is loaded. webView .getEngine() .getLoadWorker() .stateProperty() .addListener( new ChangeListener<Worker.State>() { @Override public void changed( ObservableValue<? extends Worker.State> observableValue, Worker.State state, Worker.State newState) { if (newState.equals(Worker.State.SUCCEEDED)) { primaryStage.getScene().getRoot().setEffect(new BoxBlur()); util.show(); util.toFront(); } } }); }
public class AboutUs { private Stage stage; private Scene scene; private StackPane root; private double startDragX; private double startDragY; private double aboutWindowsWidth = 1020d; private double aboutWindowsHeight = 700d; private double aboutWindowsPos; StackPane mask = StackPaneBuilder.create() .style("-fx-background-color:black; -fx-opacity:.2; -fx-background-radius: 10px;") .build(); public AboutUs() { this.aboutWindowsPos = 0d; } public AboutUs(double aboutWindowsPos) { this.aboutWindowsPos = aboutWindowsPos; } public void initComponents(final Stage parentStage) throws MalformedURLException { this.root = new StackPane(); this.root.autosize(); this.scene = new Scene(root, aboutWindowsWidth, aboutWindowsHeight, Color.web("#FFFFFF")); this.scene.getStylesheets().add(FileUtil.getStyleAsUrl("style")); this.scene.setFill(Color.TRANSPARENT); this.stage = new Stage(); this.stage.setScene(scene); this.stage.initOwner(parentStage); this.stage.initModality(Modality.NONE); this.stage.initStyle(StageStyle.UNDECORATED); Group mainRoot = new Group(); StackPane rootStack = new StackPane() { @Override protected void layoutChildren() { super.layoutChildren(); stage.setWidth(scene.getWidth()); stage.setHeight(scene.getHeight()); stage.setX(parentStage.getX()); stage.setY(parentStage.getY() + aboutWindowsPos); } }; mainRoot.getChildren().add(rootStack); this.root.getChildren().add(mainRoot); HBox vb = new HBox(); addDragListeners(vb); VBox leftContent = new VBox(); leftContent.getStyleClass().add("about-content"); Text aboutTitle = new Text("Our Address"); Text company = new Text("MAP Consultancy Services"); Text address1 = new Text("A/201, Yugandhar Sudama, Manpada Road,"); Text address2 = new Text("Dombivli (E), Thane, Maharashtra"); Text telephone = new Text("+91 9324788024 / +91 7738610004"); Text email = new Text("*****@*****.**"); Text website = new Text("website : http://www.mapconsultancyservices.com/"); Button submitBtn = new Button("Submit"); submitBtn.getStyleClass().add("map-submit-button"); submitBtn.setMinWidth(79); submitBtn.setPrefHeight(29); leftContent .getChildren() .addAll(aboutTitle, company, address1, address2, telephone, email, website, submitBtn); VBox rightContent = new VBox(); rightContent.setPrefSize(515, 410); rightContent.getStyleClass().add("map-content"); File aboutUsFile = new File("resources/aboutus/aboutus.html"); final URL urlGoogleMaps = aboutUsFile.toURI().toURL(); WebView webView = new WebView(); WebEngine webEngine = webView.getEngine(); webEngine.load(urlGoogleMaps.toExternalForm()); rightContent.getChildren().addAll(webView); vb.getChildren().addAll(leftContent, rightContent); rootStack.getChildren().add(vb); } public final void addDragListeners(final Node n) { n.setOnMousePressed( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { startDragX = me.getSceneX(); startDragY = me.getSceneY(); root.setStyle("-fx-opacity:.7;"); } }); n.setOnMouseReleased( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { root.setStyle("-fx-opacity:1;"); } }); n.setOnMouseDragged( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { stage.setX(me.getScreenX() - startDragX); stage.setY(me.getScreenY() - startDragY); } }); } /** Method to close the pop up and remove the background mask. */ public void hide() { Parent parentRoot = ((Stage) stage.getOwner()).getScene().getRoot(); if (parentRoot instanceof StackPane) { ((StackPane) parentRoot).getChildren().remove(mask); } stage.close(); } public final void show() { StackPane parentRoot = (StackPane) ((Stage) stage.getOwner()).getScene().getRoot(); parentRoot.getChildren().add(mask); stage.show(); } }