public static void setPayPane(int amount) { message = new Label(Custom.PAY_PTS_MESSAGE); Labels.setLabelStyle(message, Custom.TEXT_SIZE_LARGER, true); StackPane.setAlignment(message, Pos.CENTER); payBtn = new Button(Custom.YES); Buttons.setStoreLargerButtons(payBtn, true); StackPane.setAlignment(payBtn, Pos.BOTTOM_LEFT); payBtn.setOnAction((ae) -> PayPoints.buy(amount)); backBtn = new Button(Custom.NO); Buttons.setStoreLargerButtons(backBtn, true); StackPane.setAlignment(backBtn, Pos.BOTTOM_RIGHT); backBtn.setOnAction((ae) -> PayPoints.goBack()); mainPane = new StackPane(); mainPane.setStyle(Custom.WINDOW_STYLING); mainPane.setMinWidth(Custom.SCREEN_WIDTH * 95 / 100); mainPane.setMaxWidth(Custom.SCREEN_WIDTH * 95 / 100); mainPane.setMinHeight(Custom.SCREEN_HEIGHT * 2 / 5); mainPane.setMaxHeight(Custom.SCREEN_HEIGHT * 2 / 5); mainPane.setBorder( new Border( new BorderStroke( Paint.valueOf("#000000"), BorderStrokeStyle.SOLID, new CornerRadii(30), new BorderWidths(5)))); mainPane.getChildren().addAll(message, payBtn, backBtn); mainPane.setPadding(new Insets(10, 10, 10, 10)); StackPane.setAlignment(mainPane, Pos.CENTER); backPane = new StackPane(); backPane.getChildren().add(mainPane); backPane.setStyle(Custom.MENU_BACKGROUND); getRoot().getChildren().add(backPane); }
@Override public void start(Stage stage) { StackPane pane = new StackPane(); pane.setPadding(new Insets(10, 10, 10, 10)); pane.getChildren().setAll(control); Scene scene = new Scene(pane, 200, 200); stage.setTitle("JavaFX TButton"); stage.setScene(scene); stage.show(); }
/** Initialisation de l'UI. */ private void init(Stage primaryStage) throws Exception { primaryStage.setTitle("RestoFX"); // Scene root StackPane root = new StackPane(); root.setPadding(new Insets(16)); // Scene Scene scene = new Scene(root, 480, 320); // Buttons notGood = new Button(); notGood.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); notGood.setText("Pas bien"); notGood.setOnAction(new NotGoodFetchMenuActionHandler()); good = new Button(); good.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); good.setText("Bien"); good.setOnAction(new GoodFetchMenuActionHandler()); // Label text = new TextArea(); text.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); VBox.setVgrow(text, Priority.ALWAYS); // Progress Bar progress = new ProgressBar(); progress.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); progress.setProgress(1); // Vertical layout VBox vbox = new VBox(16); vbox.setAlignment(Pos.TOP_LEFT); // Scene tree vbox.getChildren().addAll(notGood, good, text, progress); root.getChildren().add(vbox); // Set stage scene primaryStage.setScene(scene); // Setup RestoFX HTTP Client restoFXClient = new RestoFXClient("http://127.0.0.1:" + HTTP_PORT + "/"); }
public JFXToggleButtonSkin(JFXToggleButton toggleButton) { super(toggleButton); // hide the togg le button toggleButton.setStyle("-fx-background-color:TRANSPARENT"); line = new Line(startX, startY, endX, startY); line.setStroke(unToggledColor); line.setStrokeWidth(1); circle = new Circle(startX - circleRadius, startY, circleRadius); circle.setFill(Color.TRANSPARENT); circle.setStroke(unToggledColor); circle.setStrokeWidth(strokeWidth); innerCircle = new Circle(startX - circleRadius, startY, 0); innerCircle.setStrokeWidth(0); StackPane circlePane = new StackPane(); circlePane.getChildren().add(circle); circlePane.getChildren().add(innerCircle); circlePane.setPadding(new Insets(15)); rippler = new JFXRippler(circlePane, RipplerMask.CIRCLE, RipplerPos.BACK); circles.getChildren().add(rippler); main.getChildren().add(line); main.getChildren().add(circles); main.setCursor(Cursor.HAND); AnchorPane.setTopAnchor(circles, -12.0); AnchorPane.setLeftAnchor(circles, -15.0); getSkinnable() .selectedProperty() .addListener( (o, oldVal, newVal) -> { rippler.setRipplerFill(newVal ? unToggledColor : toggledColor); transition.setRate(newVal ? 1 : -1); transition.play(); }); updateChildren(); }
private StackPane buildLeft() { StackPane sp = new StackPane(); sp.setPadding(new Insets(0, 0, 0, 5.0)); gpPackRow = 1; gpPack = new GridPane(); gpPack.setHgap(15); gpPack.setVgap(10); Label name = new Label("Nome Viaggio Gruppo"); name.getStyleClass().add("text-titlesmall"); Label price = new Label("Prezzo"); price.getStyleClass().add("text-titlesmall"); Label citta = new Label("Città"); citta.getStyleClass().add("text-titlesmall"); Label tipoPern = new Label("Tipologia"); tipoPern.getStyleClass().add("text-titlesmall"); Label stelle = new Label("Stelle"); stelle.getStyleClass().add("text-titlesmall"); Label notti = new Label("Numero notti"); notti.getStyleClass().add("text-titlesmall"); Label cittaP = new Label("Partenza"); cittaP.getStyleClass().add("text-titlesmall"); Label tipoTras = new Label("Tipologia"); tipoTras.getStyleClass().add("text-titlesmall"); Label durata = new Label("Durata"); durata.getStyleClass().add("text-titlesmall"); Label evento = new Label("Nome evento"); evento.getStyleClass().add("text-titlesmall"); Label tipoEven = new Label("Tipologia"); tipoEven.getStyleClass().add("text-titlesmall"); Label pernotto = new Label("Pernotto"); pernotto.getStyleClass().add("text-titlesmall"); Label trasporto = new Label("Trasporto"); trasporto.getStyleClass().add("text-titlesmall"); Label eventi = new Label("Eventi"); eventi.getStyleClass().add("text-titlesmall"); Label caratteristiche = new Label("Caratteristiche Viaggio Gruppo"); caratteristiche.getStyleClass().add("text-titlesmall"); Label pacchetto = new Label("Pacchetto"); pacchetto.getStyleClass().add("text-titlesmall"); Label minL = new Label("Minimo numero partecipanti"); minL.getStyleClass().add("text-titlesmall"); Label maxL = new Label("Massimo numero partecipanti"); maxL.getStyleClass().add("text-titlesmall"); Label discountL = new Label("Sconto da applicare"); discountL.getStyleClass().add("text-titlesmall"); Label reservedL = new Label("Numero Prenotati"); reservedL.getStyleClass().add("text-titlesmall"); Separator separator = new Separator(); gpPack.add(separator, 0, gpPackRow, 20, 1); gpPackRow++; gpPack.add(pacchetto, 1, 2, 3, 1); gpPack.add(pernotto, 4, 2, 3, 1); gpPack.add(trasporto, 8, 2, 2, 1); gpPack.add(eventi, 12, 2, 2, 1); gpPack.add(caratteristiche, 16, 2, 4, 1); gpPack.add(name, 0, 3); gpPack.add(price, 1, 3); gpPack.add(citta, 2, 3); gpPack.add(tipoPern, 4, 3); gpPack.add(stelle, 5, 3); gpPack.add(notti, 6, 3); gpPack.add(cittaP, 8, 3); gpPack.add(tipoTras, 9, 3); gpPack.add(durata, 10, 3); gpPack.add(evento, 12, 3); gpPack.add(tipoEven, 13, 3); gpPack.add(minL, 15, 3); gpPack.add(maxL, 16, 3); gpPack.add(discountL, 17, 3); gpPack.add(reservedL, 18, 3); Separator separator1 = new Separator(); separator1.setOrientation(Orientation.VERTICAL); Separator separator2 = new Separator(); separator2.setOrientation(Orientation.VERTICAL); Separator separator3 = new Separator(); separator3.setOrientation(Orientation.VERTICAL); Separator separator4 = new Separator(); separator4.setOrientation(Orientation.VERTICAL); Separator separator6 = new Separator(); separator4.setOrientation(Orientation.VERTICAL); Separator separator7 = new Separator(); separator4.setOrientation(Orientation.VERTICAL); gpPack.add(separator1, 3, 1, 1, 5); gpPack.add(separator2, 7, 1, 1, 5); gpPack.add(separator3, 11, 1, 1, 5); gpPack.add(separator4, 14, 1, 1, 5); gpPack.add(separator6, 19, 1, 1, 5); gpPackRow += 2; Separator separator5 = new Separator(); gpPack.add(separator5, 0, gpPackRow, 20, 1); gpPackRow++; List<ViaggioGruppo> viaggi = prenotaViaggioControl.getTrips(); if (viaggi != null) { for (ViaggioGruppo viaggioGruppo : viaggi) { this.addTrip(viaggioGruppo); } } sp.getChildren().add(gpPack); return sp; }
@Override public void start(Stage stage) { stage.setTitle("TitledPane"); // --- Simple grid test TitledPane gridTitlePane = new TitledPane(); GridPane grid = new GridPane(); grid.setVgap(4); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("First Name: "), 0, 0); grid.add(new TextField(), 1, 0); grid.add(new Label("Last Name: "), 0, 1); grid.add(new TextField(), 1, 1); grid.add(new Label("Email: "), 0, 2); grid.add(new TextField(), 1, 2); gridTitlePane.setText("Hello World!"); gridTitlePane.setContent(grid); // --- Label test TitledPane normalText = new TitledPane(); Label lbl = new Label( "This is a collapsible TitledPane\nthat allows for text to be wrapped.\n\nIt should be the perfect height to fit all text provided.\n\nIs it?"); normalText.setText("Hello World!"); normalText.setFont(Font.font(20)); normalText.setContent(lbl); // --- Big button test TitledPane normal = new TitledPane(); Button bn = new Button("Button"); bn.setPrefSize(75, 50); StackPane pane = new StackPane(bn); pane.setPadding(new Insets(5)); normal.setText("Hello World!"); normal.setFont(Font.font(5)); normal.setContent(pane); TitledPane unanimated = new TitledPane(); unanimated.setAnimated(false); unanimated.setText("Not Animated"); Button bs = new Button("Button"); bs.setPrefSize(75, 50); unanimated.setContent(bs); TitledPane uncollapsible = new TitledPane(); uncollapsible.setCollapsible(false); uncollapsible.setText("Not Collapsible"); Button bf = new Button("Button"); bf.setPrefSize(75, 50); uncollapsible.setContent(bf); // -- Content is a ScrollPane Image image = new Image("hello/duke.jpg", 200f, 200f, true, true, false); ImageView imageView = new ImageView(); imageView.setImage(image); ScrollPane scrollPane = new ScrollPane(imageView); scrollPane.setPannable(true); TitledPane scrollableImage = new TitledPane(); scrollableImage.setPrefHeight(100); scrollableImage.setText("ScrollPane content"); scrollableImage.setContent(scrollPane); VBox hbox = new VBox(10); hbox.setPadding(new Insets(20, 0, 0, 20)); hbox.getChildren() .setAll(normal, gridTitlePane, normalText, unanimated, uncollapsible, scrollableImage); Scene scene = new Scene(hbox); scene.setFill(Color.GHOSTWHITE); stage.setScene(scene); stage.show(); }
/** * Draws the MapMaker screen and displays it to the user * * @param primaryStage the stage to show it in * @throws Exception */ public void drawScreen(Stage primaryStage) throws Exception { // Create the base BorderPane for the whole window BorderPane borderPane = new BorderPane(); borderPane.setStyle("-fx-background-color: papayawhip"); // Add some instructions to the user String text = "Instructions:\n" + "1. Click on the map component that you would like to place in the map\n" + "2. Click on the place in the map where you want to place the component\n" + "3. Repeat until you built the map you want!\n" + "4. Hit the 'Save' button when you are done"; Label instructions = new Label(text); instructions.setFont(Font.font("Arial", FontWeight.BOLD, 12)); instructions.setPadding(new Insets(5, 5, 5, 5)); borderPane.setTop(instructions); // Create the blank Map Pane mapPane = new Pane(); Map map = new Map(width, height); MapGridGUIDecorator mapGridGUIDecorator = new MapGridGUIDecorator(map.getGrid()); ResizeFactor rf = ResizeFactor.getSuggestedResizeFactor(width, height); mapGridGUIDecorator.setResizeFactor(rf); GridPane mapGridPane = mapGridGUIDecorator.drawComponents(); mapGridPane.setPadding(new Insets(0, 0, 5, 5)); mapPane.getChildren().add(mapGridPane); borderPane.setCenter(mapPane); MapMakerController.setCurrentFocused(ComponentType.NOTHING); VBox sideComponents = new VBox(); /* Add "Components" label */ Label componentsLabel = new Label("Components"); componentsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14)); componentsLabel.setPadding(new Insets(15, 5, 0, 20)); sideComponents.getChildren().add(componentsLabel); /* Add Intersection square image */ VBox intersectionPane = new VBox(); Label intersectionLabel = new Label("Intersection"); intersectionLabel.setPadding(new Insets(5, 5, 0, 30)); intersectionLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image intersectionImg = new Image("IntersectionX.png", 60, 60, true, false); intersectionImgView = new ImageView(intersectionImg); StackPane intersectionStackPane = new StackPane(intersectionImgView); intersectionStackPane.setPadding(new Insets(0, 10, 10, 10)); intersectionPane.getChildren().add(intersectionLabel); intersectionPane.getChildren().add(intersectionStackPane); sideComponents.getChildren().add(intersectionPane); /* Add RoadNS square image */ VBox roadNSPane = new VBox(); Label roadNSLabel = new Label("Road (North-South)"); roadNSLabel.setPadding(new Insets(5, 5, 0, 15)); roadNSLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image roadNSImg = new Image("RoadBackgroundNS.png", 60, 60, true, false); roadNSImgView = new ImageView(roadNSImg); StackPane roadNSStackPane = new StackPane(roadNSImgView); roadNSStackPane.setPadding(new Insets(0, 10, 10, 10)); roadNSPane.getChildren().add(roadNSLabel); roadNSPane.getChildren().add(roadNSStackPane); sideComponents.getChildren().add(roadNSPane); /* Add RoadEW square image */ VBox roadEWPane = new VBox(); Label roadEWLabel = new Label("Road (East-West)"); roadEWLabel.setPadding(new Insets(5, 5, 0, 15)); roadEWLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image roadEWImg = new Image("RoadBackgroundEW.png", 60, 60, true, false); roadEWImgView = new ImageView(roadEWImg); StackPane roadEWStackPane = new StackPane(roadEWImgView); roadEWStackPane.setPadding(new Insets(0, 10, 10, 10)); roadEWPane.getChildren().add(roadEWLabel); roadEWPane.getChildren().add(roadEWStackPane); sideComponents.getChildren().add(roadEWPane); /* Add Grass square image to empty out cells */ VBox grassPane = new VBox(); Label grassLabel = new Label("Grass (clear square)"); grassLabel.setPadding(new Insets(5, 5, 0, 15)); grassLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image grassImg = new Image("Grass.png", 60, 60, true, false); grassImgView = new ImageView(grassImg); StackPane grassStackPane = new StackPane(grassImgView); grassStackPane.setPadding(new Insets(0, 10, 10, 10)); grassPane.getChildren().add(grassLabel); grassPane.getChildren().add(grassStackPane); sideComponents.getChildren().add(grassPane); /* Add Save, Reset buttons */ VBox buttonsPane = new VBox(); buttonsPane.setPadding(new Insets(0, 0, 0, 10)); Label toolsLabel = new Label("Tools"); toolsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14)); toolsLabel.setPadding(new Insets(15, 5, 5, 35)); buttonsPane.getChildren().add(toolsLabel); Insets padding = new Insets(0, 0, 5, 0); Button saveButton = new Button("Save Map"); StackPane saveButtonPane = new StackPane(saveButton); saveButtonPane.setPadding(padding); saveButton.setStyle("-fx-base:Gold"); saveButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); buttonsPane.getChildren().add(saveButtonPane); Button resetButton = new Button("Reset Map"); resetButton.setStyle("-fx-base:Gold"); resetButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); StackPane resetButtonPane = new StackPane(resetButton); resetButtonPane.setPadding(padding); buttonsPane.getChildren().add(resetButtonPane); Button backButton = new Button("Go Back"); backButton.setStyle("-fx-base:Gold"); backButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); StackPane backButtonPane = new StackPane(backButton); backButtonPane.setPadding(padding); buttonsPane.getChildren().add(backButtonPane); sideComponents.getChildren().add(buttonsPane); Ticker.start(); /* Add click processing for Map grid squares */ for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Node current = getNodeFromIndex(i, j, mapGridPane); final int x = j; final int y = i; current.setOnMouseClicked( (MouseEvent click) -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.MAP_SQUARE); current.requestFocus(); }); current .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { ComponentType previous = MapMakerController.getPreviousFocused(); if (previous == ComponentType.INTERSECTION) { addIntersection( x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView); } else if (previous == ComponentType.ROADNS) { addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView); } else if (previous == ComponentType.ROADEW) { addRoadEW(x, y, map, mapGridGUIDecorator, mapGridPane, roadEWImgView); } else if (previous == ComponentType.GRASS) { addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView); } }); } } /* Add intersection icon click processing */ DropShadow ds = new DropShadow(15, Color.BLUE); intersectionImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.INTERSECTION); intersectionImgView.requestFocus(); }); intersectionImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) intersectionImgView.setEffect(ds); else intersectionImgView.setEffect(null); }); /* Add roadNS icon click processing */ roadNSImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.ROADNS); roadNSImgView.requestFocus(); }); roadNSImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) roadNSImgView.setEffect(ds); else roadNSImgView.setEffect(null); }); /* Add roadEW icon click processing */ roadEWImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.ROADEW); roadEWImgView.requestFocus(); }); roadEWImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) roadEWImgView.setEffect(ds); else roadEWImgView.setEffect(null); }); /* Add grass icon click processing */ grassImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.GRASS); grassImgView.requestFocus(); }); grassImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) grassImgView.setEffect(ds); else grassImgView.setEffect(null); }); /* Add save button functionality */ saveButton.setOnMouseClicked( click -> { TextInputDialog nameDialog = new TextInputDialog(); nameDialog.setTitle("Save Map"); nameDialog.setHeaderText( "Please provide a name for your map (no spaces or special characters).\nSaved maps go into the /maps directory of your working directory."); nameDialog.setContentText("File name"); Button btOk = (Button) nameDialog.getDialogPane().lookupButton(ButtonType.OK); TextField textfield = nameDialog.getEditor(); Platform.runLater(() -> textfield.requestFocus()); btOk.setDisable(true); textfield .textProperty() .addListener( ((observable, oldValue, newValue) -> { btOk.setDisable(newValue.trim().isEmpty()); })); Optional<String> result = nameDialog.showAndWait(); result.ifPresent( name -> { name = name.concat(".map"); try { Map finalMap = buildAndSaveMap(map); finalMap.saveMap(name); goBack(primaryStage); } catch (Exception e) { e.printStackTrace(); } }); }); resetButton.setOnMouseClicked( click -> { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Component component = map.getAtLocation(new Coordinate(x, y)); if (component instanceof Road || component instanceof Intersection) { addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView); } } } }); backButton.setOnMouseClicked( click -> { try { goBack(primaryStage); } catch (Exception e) { e.printStackTrace(); } }); borderPane.setRight(sideComponents); Scene scene = new Scene(borderPane); primaryStage.setScene(scene); primaryStage.centerOnScreen(); primaryStage.setResizable(false); }