/** * Sets up the OverlayMenu with all buttons from the existing table view. * * @param tableView The table view to put on the overlay menu. * @return A {@link BorderPane} containing the full menu. */ private BorderPane setUpMenu(TableView<FilterInput> tableView) { final Button addButton = setAddButton(); final Button removeButton = setRemoveButton(tableView); final Button editButton = setEditButton(tableView); final Button selectionButton = setSelectionButton(); // Set up components on overlay final BorderPane borderPane = new BorderPane(); borderPane.setCenter(tableView); tableView.setMinHeight(300); AnchorPane anchorPane = new AnchorPane(); anchorPane.getChildren().addAll(addButton, removeButton, editButton, selectionButton); borderPane.setBottom(anchorPane); AnchorPane.setBottomAnchor(addButton, 0d); AnchorPane.setRightAnchor(addButton, 0d); AnchorPane.setBottomAnchor(removeButton, 0d); AnchorPane.setRightAnchor(removeButton, 30d); AnchorPane.setBottomAnchor(editButton, 0d); AnchorPane.setRightAnchor(editButton, 60d); AnchorPane.setBottomAnchor(selectionButton, 0d); AnchorPane.setRightAnchor(selectionButton, 95d); return borderPane; }
public RNADrawingView() { // set up gui drawingPane.setPrefWidth(400); drawingPane.setPrefHeight(400); warningLabel.setTextFill(Color.RED); animateCheckbox.setSelected(false); buttonBox.getChildren().addAll(foldButton, drawButton, animateCheckbox); inputBox.getChildren().addAll(sequenceField, bracketField, buttonBox); buttonInputBox.getChildren().addAll(inputBox, warningLabel, buttonBox); drawingPane.getChildren().add(drawing); root.setTop(buttonInputBox); root.setBottom(drawingPane); buttonBox.setAlignment(Pos.BOTTOM_LEFT); inputBox.setPadding(new Insets(10, 5, 10, 5)); HBox.setMargin(foldButton, new Insets(0, 2.5, 0, 2.5)); HBox.setMargin(drawButton, new Insets(0, 2.5, 0, 2.5)); HBox.setMargin(animateCheckbox, new Insets(0, 2.5, 0, 2.5)); VBox.setMargin(sequenceField, new Insets(0, 0, 5, 0)); this.scene = new Scene(root); scene.getStylesheets().add("resources/assignment6and7.css"); drawingPane.getStyleClass().add("drawingPane"); }
private Scene createMainTetrisScene() { mainPane = new BorderPane(); VBox mainBox = new VBox(); mainBox.setPadding(new Insets(200, 0, 0, 20)); mainBox.getChildren().add(mainGrid); mainGrid.setOnKeyPressed(new KeyboardHandler()); mainPane.setBottom(mainBox); mainPane.setTop(createActionPane()); mainPane.setRight(createStatePane()); Group group = new Group(); for (int i = 19; i >= 0; i--) { for (int j = 0; j < 10; j++) { Image img; if (mainGrid.getColor(i, j) != Color.DARKGRAY) { img = new Image(getClass().getResourceAsStream("RED.png")); } else { img = new Image(getClass().getResourceAsStream("EMPTY.png")); } ImageView iView = new ImageView(img); iView.setX(j * 17); iView.setY(i * 16); iView.setOpacity(1); iView.setPreserveRatio(true); group.getChildren().addAll(iView); } } Scene scene = new Scene(group, 600, 600); mainPane.setCenter(group); return new Scene(mainPane, 380, 540); // 540 }
private void updateChildren(boolean useButtons) { hboxLayout.getChildren().clear(); hboxLayout.getChildren().addAll(createChildren(useButtons)); vboxLayout.getChildren().clear(); vboxLayout.getChildren().addAll(createChildren(useButtons)); flowLayout.getChildren().clear(); flowLayout.getChildren().addAll(createChildren(useButtons)); List<Node> contents1 = createChildren(useButtons); gridLayout.getChildren().clear(); gridLayout.add(contents1.get(0), 0, 0); gridLayout.add(contents1.get(1), 1, 0); gridLayout.add(contents1.get(2), 0, 1, 2, 1); List<Node> contents = createChildren(useButtons); borderLayout.getChildren().clear(); borderLayout.setLeft(contents.get(0)); borderLayout.setTop(contents.get(1)); borderLayout.setRight(contents.get(2)); borderLayout.setBottom(contents.get(3)); borderLayout.setCenter(contents.get(4)); stackLayout.getChildren().clear(); stackLayout.getChildren().addAll(createChildren(useButtons)); tileLayout.getChildren().clear(); tileLayout.getChildren().addAll(createChildren(useButtons)); }
// REMOVE ME public static Node createIconContent() { StackPane sp = new StackPane(); BorderPane borderPane = new BorderPane(); Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY); rectangle.setStroke(Color.BLACK); borderPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight()); Rectangle recTop = new Rectangle(62, 5, Color.web("#349b00")); recTop.setStroke(Color.BLACK); Rectangle recBottom = new Rectangle(62, 14, Color.web("#349b00")); recBottom.setStroke(Color.BLACK); Rectangle recLeft = new Rectangle(20, 41, Color.TRANSPARENT); recLeft.setStroke(Color.BLACK); Rectangle recRight = new Rectangle(20, 41, Color.TRANSPARENT); recRight.setStroke(Color.BLACK); Rectangle centerRight = new Rectangle(20, 41, Color.TRANSPARENT); centerRight.setStroke(Color.BLACK); borderPane.setRight(recRight); borderPane.setTop(recTop); borderPane.setLeft(recLeft); borderPane.setBottom(recBottom); borderPane.setCenter(centerRight); sp.getChildren().addAll(rectangle, borderPane); return new Group(sp); }
private void createMasterPane() { webView = new WebView(); webViewAnchorPane = new AnchorPane(webView); AnchorPane.setBottomAnchor(webView, 0.0); AnchorPane.setTopAnchor(webView, 0.0); AnchorPane.setLeftAnchor(webView, 0.0); AnchorPane.setRightAnchor(webView, 0.0); webEngine = webView.getEngine(); dialog = Dialogs.create().lightweight().modal().owner(webView); // locals = new LocalJSObject(webEngine); // globals = GlobalJSObject.getGlobalJSObject(webEngine); javaScriptHelpers = new BurpKitBridge(webEngine); originalUserAgent = webEngine.getUserAgent(); webEngine.setJavaScriptEnabled(true); webEngine.setOnAlert(this::handleAlert); webEngine.setOnError(this::handleError); webEngine.setConfirmHandler(param -> true); webEngine.getLoadWorker().stateProperty().addListener(this::workerStateChanged); createToolBar(); createStatusBar(); webEngine.load("about:blank"); masterPane = new BorderPane(); masterPane.setTop(toolBar); masterPane.setCenter(webViewAnchorPane); masterPane.setBottom(statusBar); }
@Override public void start(Stage primaryStage) throws Exception { BorderPane root = new BorderPane(); HBox message = new HBox(); userText = new TextField(); userText.setEditable(false); userText.setOnAction( e -> { sendMessage(e.getEventType().toString()); userText.setText(""); }); message.getChildren().add(userText); message.setAlignment(Pos.CENTER); message.setPadding(new Insets(10)); chatWindow = new TextArea(); chatWindow.setPrefSize(300, 150); chatWindow.setVisible(true); root.setCenter(chatWindow); root.setBottom(message); startRunning(); primaryStage.setTitle("Instant Messenger"); primaryStage.setScene(new Scene(root, 300, 275)); primaryStage.show(); }
public Node getPolizistAnsicht() { if (PolizistAnsichtGeneriert) { refreshPolizistAnsicht(); return DatenAnsicht; } IM.setInfoText("Lade Polizist Ansicht"); DatenAnsicht = new BorderPane(getPolizistAnsichtInnereTabelle()); HBox ButtonLeiste = new HBox(10); ButtonLeiste.setPadding(new Insets(10)); Button ButtonNeue = new Button("Neuer Eintrag..."); Button ButtonChan = new Button("Eintrag ändern..."); Button ButtonDele = new Button("Eintrag löschen"); ButtonNeue.setOnAction(event -> insertNewEntry()); ButtonChan.setOnAction(event -> updateSelectedEntry()); ButtonDele.setOnAction(event -> deleteSelectedEntrys()); ButtonLeiste.getChildren().addAll(ButtonNeue, ButtonChan, ButtonDele); DatenAnsicht.setBottom(ButtonLeiste); IM.setInfoText("Laden der Polizist Ansicht erfolgreich"); PolizistAnsichtGeneriert = true; return DatenAnsicht; }
/** DEFAULT. */ public CafePricingDialog() { this.priceMap = new HashMap<>(); this.primaryStage = new Stage(); this.root = new Group(); this.scrollPane = new ScrollPane(); this.scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); this.scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); this.scene = new Scene(scrollPane, 0x190, 0x1f4, Color.LIGHTGREY); makeDialog(fp); fp.setMinSize(380, 480); fp.setAlignment(Pos.TOP_CENTER); bp.setTop(logoChildBP); bp.setCenter(labelChildBP); bp.setBottom(fp); root.getChildren().add(bp); scrollPane.setContent(root); // -------------------------------------------- this.primaryStage.setTitle(TITLE); this.primaryStage.setScene(scene); this.primaryStage.setResizable(false); this.primaryStage.show(); }
public void displayPane() throws IOException { addStationsToCB(); paneTop.getColumnConstraints().add(new ColumnConstraints(60)); paneTop.getColumnConstraints().add(new ColumnConstraints(200)); paneTop.getColumnConstraints().add(new ColumnConstraints(100)); paneBot.getColumnConstraints().add(new ColumnConstraints(60)); paneBot.getColumnConstraints().add(new ColumnConstraints(200)); paneBot.getColumnConstraints().add(new ColumnConstraints(100)); paneCenter.getColumnConstraints().add(new ColumnConstraints(300)); paneTop.setPadding(new Insets(10, 10, 10, 10)); paneTop.setAlignment(Pos.CENTER); paneTop.setHgap(5); paneTop.setVgap(5); paneBot.setPadding(new Insets(10, 10, 10, 10)); paneBot.setAlignment(Pos.CENTER); paneBot.setHgap(5); paneBot.setVgap(5); paneTop.add(new Label("Station :"), 0, 0); paneTop.add(cbStations, 1, 0); paneTop.add(btOpen, 2, 0); paneBot.add(new Label("Quantity :"), 0, 0); paneBot.add(cbQuantity, 1, 0); paneBot.add(btShow, 2, 0); paneTop.setHalignment(btOpen, HPos.RIGHT); paneBot.setHalignment(btShow, HPos.RIGHT); paneCenter.setHgap(5); paneCenter.setVgap(5); paneCenter.setAlignment(Pos.CENTER); sp.setContent(paneCenter); sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS); bp.setMargin(sp, new Insets(20, 50, 40, 50)); bp.setTop(paneTop); bp.setCenter(sp); bp.setBottom(paneBot); btOpen.setOnAction( e -> { try { open(); } catch (IOException er) { er.printStackTrace(); } }); btShow.setOnAction(e -> showGraph()); }
public SubExperimentListCell() { BorderPane.setMargin(progressRect, new Insets(2)); BorderPane.setMargin(progressRect, new Insets(2, 0, 0, 0)); BorderPane.setAlignment(label, Pos.BOTTOM_LEFT); progressRect.setMaxWidth(Integer.MAX_VALUE); progressRect.setPrefHeight(3); progressRect.setMinHeight(3); progressRect.getStyleClass().add("mini-progress-bar"); content.setBottom(progressRect); content.setCenter(label); }
public Scene createLoginScene() { BorderPane borderPane = new BorderPane(); HBox title = createTitle(); GridPane grid = createLoginForm(borderPane); HBox hbox = createSkipLoginBar(); borderPane.setTop(title); borderPane.setCenter(grid); borderPane.setBottom(hbox); Scene scene = new Scene(borderPane, sceneWidth, sceneHeight); return scene; }
@Override public void start(Stage primaryStage) throws Exception { BorderPane outerPane = new BorderPane(); HBox topBox = new HBox(20); HBox bottomBox = new HBox(20); outerPane.setCenter(newText); fontChoice.setValue("Times New Roman"); sizeChoice.setValue(12); topBox.setPadding(new Insets(20, 20, 20, 20)); bottomBox.setPadding(new Insets(20, 20, 20, 20)); List<String> items = Font.getFamilies(); fontChoice.getItems().addAll(items); for (int i = 1; i <= 100; i++) sizeChoice.getItems().add(i); topBox.getChildren().addAll(fontName, fontChoice, fontSize, sizeChoice); bottomBox.getChildren().addAll(bold, italic); topBox.setAlignment(Pos.CENTER); bottomBox.setAlignment(Pos.CENTER); outerPane.setTop(topBox); outerPane.setCenter(newText); outerPane.setBottom(bottomBox); fontChoice.setOnAction( e -> { setFont(); }); sizeChoice.setOnAction( e -> { setFont(); }); bold.setOnAction( e -> { setFont(); }); italic.setOnAction( e -> { setFont(); }); Scene scene = new Scene(outerPane, X, Y); primaryStage.setScene(scene); primaryStage.show(); }
public void start(Stage primaryStage) throws Exception { final TextField t1 = new TextField(); t1.setText("Hello"); final BorderPane pane = new BorderPane(); pane.setCenter(t1); final Scene myScene = new Scene(pane); final Button b2 = new Button("Click me!!!!"); b2.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { PropertySupervisor<String> textPropertySupervisor = new PropertySupervisor<>(t1.textProperty()); textPropertySupervisor.assertValueIsEquals("Hello"); textPropertySupervisor.assertWillChange(); textPropertySupervisor.assertWillChangeByDefinedCount(1); t1.setText("123"); // Will fail if a rule is broken textPropertySupervisor.confirm(); // remove all rules textPropertySupervisor.reset(); textPropertySupervisor.assertWillNeverChange(); textPropertySupervisor.confirm(); textPropertySupervisor.reset(); textPropertySupervisor.assertWillChange(); textPropertySupervisor.assertWillChangeByDefinedCount(3); textPropertySupervisor.assertWillChangeThisWay("A", "B", "C"); t1.setText("A"); t1.setText("B"); t1.setText("C"); textPropertySupervisor.confirm(); } }); pane.setBottom(b2); primaryStage.setScene(myScene); primaryStage.setTitle("MarvFX Demo3"); primaryStage.show(); }
public BorderPaneSample() { super(400, 400); BorderPane borderPane = new BorderPane(); // Top content Rectangle topRectangle = new Rectangle(400, 23, Color.DARKSEAGREEN); topRectangle.setStroke(Color.BLACK); borderPane.setTop(topRectangle); // Left content Label label1 = new Label("Left hand"); Label label2 = new Label("Choice One"); Label label3 = new Label("Choice Two"); Label label4 = new Label("Choice Three"); VBox leftVbox = new VBox(); leftVbox.getChildren().addAll(label1, label2, label3, label4); borderPane.setLeft(leftVbox); // Right content Label rightlabel1 = new Label("Right hand"); Label rightlabel2 = new Label("Thing A"); Label rightlabel3 = new Label("Thing B"); VBox rightVbox = new VBox(); rightVbox.getChildren().addAll(rightlabel1, rightlabel2, rightlabel3); borderPane.setRight(rightVbox); // Center content Label centerLabel = new Label("We're in the center area."); ImageView imageView = new ImageView(ICON_48); // Using AnchorPane only to position items in the center AnchorPane centerAP = new AnchorPane(); AnchorPane.setTopAnchor(centerLabel, Double.valueOf(5)); AnchorPane.setLeftAnchor(centerLabel, Double.valueOf(20)); AnchorPane.setTopAnchor(imageView, Double.valueOf(40)); AnchorPane.setLeftAnchor(imageView, Double.valueOf(30)); centerAP.getChildren().addAll(centerLabel, imageView); borderPane.setCenter(centerAP); // Bottom content Label bottomLabel = new Label("I am a status message, and I am at the bottom."); borderPane.setBottom(bottomLabel); getChildren().add(borderPane); }
public void repaint3D() { mainPane = new BorderPane(); VBox mainBox = new VBox(); mainBox.setPadding(new Insets(200, 0, 0, 20)); mainBox.getChildren().add(mainGrid); mainGrid.setOnKeyPressed(new KeyboardHandler()); mainPane.setBottom(mainBox); mainPane.setTop(createActionPane()); mainPane.setRight(createStatePane()); Group group = new Group(); for (int i = 22; i >= 0; i--) { for (int j = -1; j < 11; j++) { Image img; if (i == 22 || (j == -1 || j == 10)) img = new Image(getClass().getResourceAsStream("GRAY.png")); else if (mainGrid.getColor(i, j) == Color.YELLOW) img = new Image(getClass().getResourceAsStream("YELLOW.png")); else if (mainGrid.getColor(i, j) == Color.MAGENTA) img = new Image(getClass().getResourceAsStream("RED.png")); else if (mainGrid.getColor(i, j) == Color.GREEN) img = new Image(getClass().getResourceAsStream("GREEN.png")); else if (mainGrid.getColor(i, j) == Color.ORANGE) img = new Image(getClass().getResourceAsStream("ORANGE.png")); else if (mainGrid.getColor(i, j) == Color.BLUE) img = new Image(getClass().getResourceAsStream("BLUE.png")); else if (mainGrid.getColor(i, j) == Color.CYAN) img = new Image(getClass().getResourceAsStream("CYAN.png")); else if (mainGrid.getColor(i, j) == Color.PINK) img = new Image(getClass().getResourceAsStream("VIOLET.png")); else img = new Image(getClass().getResourceAsStream("EMPTY.png")); ImageView iView = new ImageView(img); iView.setX(j * 17); iView.setY(i * 16); iView.setOpacity(1); iView.setPreserveRatio(true); group.getChildren().addAll(iView); } } mainPane.setCenter(group); // Stage old = stage3D; // stage3D = new Stage(); stage3D.setScene(new Scene(mainPane, 380, 540)); }
protected FxSidebarPasswordbox(ApplicationInstance instance) { final JavaFxUserInterfaceApi fxUI = JavaFxUserInterface.getInstance(instance); row = new BorderPane(); inputElement = createPasswordbox(instance, true); row.setCenter(inputElement); CheckBox showPw = new CheckBox(fxUI.getLocaleBundleString("passwordfield.show_password")); showPw.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (showPw.isSelected()) { TextField t = new TextField(getUIValue()); t.addEventFilter( KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { storeData(instance.getTree().getSelectedNode()); } }); inputElement = t; } else { inputElement = createPasswordbox(instance, false); } row.setCenter(inputElement); } }); row.setBottom(showPw); Button copy = new Button("", ImageMap.getFxImageView(("icon_copy"))); copy.setMinWidth(16); copy.setMaxWidth(16); copy.setTooltip(new Tooltip(fxUI.getLocaleBundleString("mainwindow.menu.edit.copy_text"))); copy.getStyleClass().add("noBorder"); copy.setFocusTraversable(false); copy.setOnAction((event) -> fxUI.setClipboardText(getUIValue())); row.setRight(copy); }
public GameState(StateManager sm) { super(sm); shop = new Shop(); game = new ShopSimulation(shop); gameClock = new GameClock(); gameClock.setListener( new GameClock.GameClockListener() { @Override public void crappyHourBegins() { game.startCrappyHour(); Platform.runLater(() -> shop.getLog().addLog("The chaos has begun..")); } @Override public void shopClosed() { Platform.runLater(() -> endGame()); } }); // Check if game closed sm.getStage().setOnCloseRequest(e -> stageClosed()); statusLabel = new Label(); shop.setListener(this); moneyFormat = NumberFormat.getCurrencyInstance(); // Setup basic panes + contents BorderPane rootPane = new BorderPane(); rootPane.setStyle("-fx-background-color: #474F53;"); rootPane.setTop(new VBox(initMenu(), initStatusBar())); rootPane.setBottom(initGame()); startGame(); scene = new Scene(rootPane); setupStyle(); setupSubWindow(); }
@Override public void start(Stage primaryStage) throws Exception { BorderPane layout = new BorderPane(); // imageview currImage = new ImageView(); layout.setMargin(currImage, new Insets(25, 180, 0, 180)); currImage.setSmooth(true); layout.setTop(currImage); // add bottom layout BottomLayout bottomLayoutObject = new BottomLayout(primaryStage); HBox bottomLayout = bottomLayoutObject.getLayout(); bottomLayout.setAlignment(Pos.BOTTOM_RIGHT); layout.setBottom(bottomLayout); currImage.setOnMouseClicked( e -> { clicked = !clicked; if (clicked) { BottomLayout.statusBar.setText("Paused"); ImageSelector.timer.cancel(); stoppedCount = ImageSelector.count; } else { BottomLayout.statusBar.setText("Running the images display"); ImageSelector.startSelectImages(ImageSelector.currPath); } }); // cancel the timer if the user exited the program primaryStage.setOnCloseRequest( e -> { if (ImageSelector.timer != null) ImageSelector.timer.cancel(); }); primaryStage.setTitle("Images Displayer"); primaryStage.setResizable(false); primaryStage.setScene(new Scene(layout, 900, 600)); primaryStage.show(); }
@Override public void start(Stage stage) { indexer = new Indexer(); indexer.read("index.ser"); window = stage; window.setTitle("Browser"); // Layout BorderPane border = new BorderPane(); HBox hBox = new HBox(10); hBox.setPadding(new Insets(20, 20, 20, 20)); border.setTop(hBox); VBox vBox = new VBox(10); vBox.setPadding(new Insets(20, 20, 20, 20)); border.setCenter(vBox); // Search Bar / Button searchTextField = new TextField(); searchButton = new Button("Search"); searchTextField.setPrefWidth(1000); searchButton.setOnAction(event -> search()); label = new Label("Status: "); label.setPadding(new Insets(20, 20, 20, 20)); border.setBottom(label); // WebView webView = new WebView(); webEngine = webView.getEngine(); webView.isVisible(); vBox.getChildren().addAll(webView); hBox.getChildren().addAll(searchTextField, searchButton); scene = new Scene(border, 1200, 600); window.setScene(scene); stage.setResizable(false); window.show(); System.out.println(searchTextField.getText()); }
@Inject public OverwriteConfirmationDialog(StylesConfig styles) { initModality(Modality.WINDOW_MODAL); initStyle(StageStyle.UTILITY); setResizable(false); BorderPane containerPane = new BorderPane(); containerPane.getStyleClass().addAll(Style.CONTAINER.css()); containerPane.getStyleClass().addAll("-pdfsam-dialog", "-pdfsam-warning-dialog"); containerPane.setCenter(dialogContent); HBox buttons = new HBox( buildButton(DefaultI18nContext.getInstance().i18n("Overwrite"), true), buildButton(DefaultI18nContext.getInstance().i18n("Cancel"), false)); buttons.getStyleClass().add("-pdfsam-dialog-buttons"); containerPane.setBottom(buttons); Scene scene = new Scene(containerPane); scene.getStylesheets().addAll(styles.styles()); scene.setOnKeyReleased(new HideOnEscapeHandler(this)); setScene(scene); }
@Override public void start(Stage primaryStage) { HBox sizingHB = new HBox(15.0); sizingHB.setAlignment(Pos.CENTER); Button sizeUpButton = new Button("Increase"); Button sizeDownButton = new Button("Decrease"); sizingHB.getChildren().addAll(sizeUpButton, sizeDownButton); Circle circle = new Circle(50, Color.YELLOW); BorderPane bp = new BorderPane(circle); bp.setPadding(new Insets(10, 10, 10, 10)); bp.setBottom(sizingHB); primaryStage.setTitle("Circle Size Adjustment"); primaryStage.setScene(new Scene(bp, 200, 200)); primaryStage.show(); }
@Override public void start(Stage pPrimaryStage) { aText.setText(PART_1); pPrimaryStage.setTitle("Welcome to COMP303"); aButton.setOnAction(this); aSkin.selectedToggleProperty().addListener(this); RadioButton rb1 = new RadioButton("Plain"); rb1.setToggleGroup(aSkin); rb1.setUserData("Plain"); rb1.setSelected(true); RadioButton rb2 = new RadioButton("Floral"); rb2.setUserData("Floral"); rb2.setToggleGroup(aSkin); RadioButton rb3 = new RadioButton("Chintz"); rb3.setUserData("Chintz"); rb3.setToggleGroup(aSkin); VBox centerPanel = new VBox(MARGIN); centerPanel.setPadding(new Insets(MARGIN)); centerPanel.setAlignment(Pos.CENTER); centerPanel.getChildren().addAll(aText, aButton); BorderPane root = new BorderPane(); root.setCenter(centerPanel); HBox bottomPanel = new HBox(MARGIN); bottomPanel.setPadding(new Insets(MARGIN)); bottomPanel.setAlignment(Pos.CENTER); bottomPanel.getChildren().addAll(rb1, rb2, rb3); root.setBottom(bottomPanel); aScene = new Scene(root, WIDTH, HEIGHT); pPrimaryStage.setResizable(false); pPrimaryStage.setScene(aScene); pPrimaryStage.show(); }
@Override // Override the start method in the Application class public void start(Stage primaryStage) throws Exception { Text text = new Text(20.0, 20.0, "JavaFx Programming"); ScrollBar sbHorizontal = new ScrollBar(); ScrollBar sbVertical = new ScrollBar(); sbVertical.setOrientation(Orientation.VERTICAL); // Create a text in a pane Pane paneForText = new Pane(); paneForText.getChildren().addAll(text); // Create a border pane to hold text and scroll bars BorderPane pane = new BorderPane(); pane.setCenter(paneForText); pane.setRight(sbVertical); pane.setBottom(sbHorizontal); // Listener for horizontal scroll bar value change sbHorizontal .valueProperty() .addListener( observable -> { text.setX(sbHorizontal.getValue() * paneForText.getWidth() / sbHorizontal.getMax()); }); // Listener for vertical scroll bar value change sbVertical .valueProperty() .addListener( observable -> { text.setY(sbVertical.getValue() * paneForText.getHeight() / sbVertical.getMax()); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 450.0, 170.0); primaryStage.setTitle("ScrollBarDemo"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
public void askImageScreen() { Integer[] randomImageNumber = new Integer[49]; for (int i = 0; i < randomImageNumber.length; i++) { randomImageNumber[i] = i; } Collections.shuffle(Arrays.asList((randomImageNumber))); String[] listOfImageAsk = new String[levelFactor]; Group group = new Group(); for (int i = 0; i < listOfImageAsk.length; i++) { Image image = allImages[randomImageNumber[i]]; ImageView imageAsk = new ImageView(image); imageAsk.setId(randomImageNumber[i] + ".gif"); listOfImageAsk[i] = (randomImageNumber[i] + ".gif"); imageAsk.setX(i * 83); group.getChildren().add(imageAsk); System.out.println(listOfImageAsk[i]); } // scene3 elements Label instruction = new Label("RULES TO BE HERE"); Button nextButton = new Button("NEXT"); BorderPane layout3 = new BorderPane(); layout3.setCenter(group); layout3.setTop(instruction); layout3.setBottom(nextButton); layout3.setAlignment(instruction, Pos.TOP_CENTER); layout3.setAlignment(nextButton, Pos.BASELINE_CENTER); nextButton.setOnAction(e -> checkResultScreen(listOfImageAsk)); nextButton.setOnKeyPressed(e -> checkResultScreen(listOfImageAsk)); scene3 = new Scene(layout3, 800, 600); window1.setScene(scene3); }
public void setContents() { Scene scene = new Scene(root, 250, 100); setScene(scene); Group groupInDialog = new Group(); groupInDialog.getChildren().add(new Label("Would you like to buy land ?")); root.setCenter(groupInDialog); Button yes = new Button("Yes"); yes.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { postStatus = true; answer = 1; stage.close(); } }); Button no = new Button("No"); no.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { postStatus = false; answer = 2; stage.close(); // Close the pop up only } }); HBox buttonPane = new HBox(); buttonPane.setSpacing(10); buttonPane.getChildren().addAll(yes, no); root.setBottom(buttonPane); stage.showAndWait(); }
public Pane createRoot(double spacing) { final String ipAddressPattern = "\\d{3}.\\d{3}.\\d.\\d"; final String portPattern = "\\d{2}|\\d{4}"; final TextArea status = new TextArea(); status.setEditable(false); orca.messageProperty() .addListener( new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> ov, String t, String t1) { status.appendText(t1); } }); BorderPane root = new BorderPane(); root.setPadding(new Insets(spacing)); root.setLeft(createORCADatePane(spacing)); root.setCenter(createChartsPane(spacing)); root.setRight(createControlsPane(spacing)); root.setBottom(status); return root; }
@Override public void start(Stage theStage) { this.tStage = theStage; theStage.setTitle("Ball of Duty"); theStage.setHeight(WINDOW_START_HEIGHT); theStage.setWidth(WINDOW_START_WIDTH); theStage.centerOnScreen(); theStage.setResizable(false); theStage.setOnCloseRequest( new EventHandler<WindowEvent>() { public void handle(WindowEvent we) { gameManager.quitGame(); System.exit(0); } }); BorderPane startMenuRoot = new BorderPane(); startMenu = new Scene(startMenuRoot); gameBox = new BorderPane(); Scene gameScene = new Scene(gameBox); BorderPane createAccountRoot = new BorderPane(); BorderPane lohInRoot = new BorderPane(); theStage.setScene(startMenu); gameManager = new GameClient(getRelativeSceneLocation(theStage)); scale = new Scale(); scale.xProperty().bind(gameScene.widthProperty().divide(WINDOW_START_WIDTH)); scale.yProperty().bind(gameScene.heightProperty().divide(WINDOW_START_HEIGHT)); scale.setPivotX(0); scale.setPivotY(0); // gameBox.getTransforms().add(scale); // gameBox.setBackground(null); // TODO scaling theStage .heightProperty() .addListener( e -> { gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); // This // only // happens // once // for // some // reason. }); theStage .widthProperty() .addListener( e -> { gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); }); theStage .xProperty() .addListener( e -> { gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); }); theStage .yProperty() .addListener( e -> { gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); }); gameScene .xProperty() .addListener( e -> { gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); }); gameScene .yProperty() .addListener( e -> { gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); }); Image image = new Image("images/frontpage.png"); BackgroundSize backgroundSize = new BackgroundSize(100, 100, true, true, true, false); // new BackgroundImage(image, repeatX, repeatY, position, size) BackgroundImage backgroundImage = new BackgroundImage( image, BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, backgroundSize); // new Background(images...) Background background = new Background(backgroundImage); startMenuRoot.setBackground(background); RadioButton chooseBlaster = new RadioButton("Blaster"); RadioButton chooseRoller = new RadioButton("Roller"); RadioButton chooseHeavy = new RadioButton("Heavy"); final ToggleGroup specializationGroup = new ToggleGroup(); chooseBlaster.setToggleGroup(specializationGroup); chooseRoller.setToggleGroup(specializationGroup); chooseHeavy.setToggleGroup(specializationGroup); chooseBlaster.setSelected(true); HBox specializationBox = new HBox(); specializationBox.setSpacing(9); specializationBox.getChildren().add(chooseBlaster); specializationBox.getChildren().add(chooseRoller); specializationBox.getChildren().add(chooseHeavy); Label lblNickname = new Label("Nickname:"); TextField tfNickname = new TextField(); Button loginStart = new Button("Log in"); Button createStart = new Button("Create Account"); theStage.getIcons().add(new Image("images/ball_red.png")); VBox mainButtonBox = new VBox(); mainButtonBox.setSpacing(5); Button joinBtn = new Button("Join game"); Button viewLB = new Button("Leaderboard"); viewLB.setPrefSize(150, 50); viewLB.setId("viewLB"); viewLB.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); BorderPane lbBorder = new BorderPane(); VBox lbBox = new VBox(); Scene lbScene = new Scene(lbBorder); Button lbBack = new Button("Start menu"); lbBox.getChildren().add(lbBack); lbBorder.setLeft(lbBox); lbBack.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); Label topText = new Label("Only shows scores higher than 100!"); topText.setStyle("-fx-font-size: 20pt;-fx-font-family: Segoe UI Semibold;"); viewLB.setOnAction( ActionEvent -> { HighscoreLeaderboard hBoard = gameManager.getHighscoreLeaderboard(); hBoard.setFocusTraversable(false); lbBorder.setCenter(hBoard); if (gameManager.getPlayer() != null) { Player client = gameManager.getPlayer(); Label you = new Label( "YOU: " + client.getNickname() + " [" + client.getId() + "] | Score: " + client.getHighscore()); you.setStyle("-fx-font-size: 15pt;-fx-font-family: Segoe UI Semibold;"); lbBorder.setBottom(you); } BorderPane.setMargin(hBoard, new Insets(12, 12, 12, 12)); lbBorder.setTop(topText); theStage.setScene(lbScene); lbBack.setOnAction( ActionEvent1 -> { theStage.setScene(startMenu); startMenuRoot.setLeft(mainButtonBox); BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150)); }); }); joinBtn.setPrefSize(150, 50); tfNickname.setPrefSize(150, 20); joinBtn.setId("joinBtn"); joinBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); lblNickname.setId("lblNickname"); lblNickname.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); createStart.setId("CreateStart"); createStart.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); loginStart.setId("loginStart"); loginStart.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); joinBtn.setOnAction( ActionEvent -> { Specializations spec; if (chooseRoller.isSelected()) { spec = Specializations.ROLLER; } else if (chooseHeavy.isSelected()) { spec = Specializations.HEAVY; } else // Blaster is default, if something goes wrong with radio // buttons { spec = Specializations.BLASTER; } theStage.setScene(gameScene); gameManager.joinAsGuest(gameBox, tfNickname.getText(), spec); gameManager.getMap().addObserver(this); gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); gameBox.requestFocus(); }); tfNickname.setOnAction( ActionEvent -> { Specializations spec; if (chooseRoller.isSelected()) { spec = Specializations.ROLLER; } else if (chooseHeavy.isSelected()) { spec = Specializations.HEAVY; } else // Blaster is default, if something goes wrong with radio // buttons { spec = Specializations.BLASTER; } theStage.setScene(gameScene); gameManager.joinAsGuest(gameBox, tfNickname.getText(), spec); gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); gameBox.requestFocus(); }); mainButtonBox.getChildren().add(lblNickname); mainButtonBox.getChildren().add(tfNickname); mainButtonBox.getChildren().add(specializationBox); mainButtonBox.getChildren().add(joinBtn); mainButtonBox.getChildren().add(loginStart); mainButtonBox.getChildren().add(createStart); mainButtonBox.getChildren().add(viewLB); startMenuRoot.setLeft(mainButtonBox); createStart.setOnAction( ActionEvent -> { VBox createAccountButtonBox = new VBox(); Label lblNickname2 = new Label("Nickname:"); TextField tfNickname2 = new TextField(); Label lblUserName = new Label("Name:"); TextField tfUserName = new TextField(); Label lblPassword = new Label("Password:"******"Repeat password:"******"Create account"); Button back = new Button("Start menu"); createBtn.setId("join-yyyyy"); createBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); lblUserName.setId("join-game"); lblUserName.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); lblPassword.setId("join-game"); lblPassword.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); lblPassword2.setId("join-game"); lblPassword2.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); back.setId("join-game"); back.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); createAccountButtonBox.getChildren().add(lblNickname2); createAccountButtonBox.getChildren().add(tfNickname2); createAccountButtonBox.getChildren().add(lblUserName); createAccountButtonBox.getChildren().add(tfUserName); createAccountButtonBox.getChildren().add(lblPassword); createAccountButtonBox.getChildren().add(pf); createAccountButtonBox.getChildren().add(lblPassword2); createAccountButtonBox.getChildren().add(pf2); createAccountButtonBox.getChildren().add(createBtn); createAccountButtonBox.getChildren().add(back); startMenuRoot.setLeft(createAccountButtonBox); BorderPane.setMargin(createAccountButtonBox, new Insets(350, 0, 0, 150)); createBtn.setOnAction( ActionEvent1 -> { gameManager.createAccount( tfUserName.getText(), tfNickname2.getText(), pf.getText().toCharArray(), pf2.getText().toCharArray()); startMenuRoot.setLeft(mainButtonBox); BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150)); }); back.setOnAction( ActionEvent1 -> { startMenuRoot.setLeft(mainButtonBox); BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150)); }); }); loginStart.setOnAction( ActionEvent -> { VBox loginButtonBox = new VBox(); Button logInBtn = new Button("Log in"); Label lblUserName2 = new Label("Name:"); TextField tfUserName2 = new TextField(); Label lblPassword2 = new Label("Password:"******"Start Menu"); logInBtn.setId("join-game"); logInBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); back2.setId("join-game"); back2.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;"); loginButtonBox.getChildren().add(lblUserName2); loginButtonBox.getChildren().add(tfUserName2); loginButtonBox.getChildren().add(lblPassword2); loginButtonBox.getChildren().add(pf3); loginButtonBox.getChildren().add(logInBtn); loginButtonBox.getChildren().add(back2); startMenuRoot.setLeft(loginButtonBox); BorderPane.setMargin(loginButtonBox, new Insets(350, 0, 0, 150)); logInBtn.setOnAction( ActionEvent1 -> { // TODO login }); back2.setOnAction( ActionEvent1 -> { startMenuRoot.setLeft(mainButtonBox); BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150)); }); }); BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150)); Button quitBtn = new Button("Quit game"); quitBtn.setPrefSize(80, 40); quitBtn.setId("quit-game"); quitBtn.setOnAction( ActionEvent -> { gameManager.quitGame(); theStage.setScene(startMenu); }); canvas = new Canvas(CANVAS_START_WIDTH, CANVAS_START_HEIGHT); gameBox.setCenter(canvas); BorderPane.setAlignment(canvas, Pos.TOP_LEFT); gameBox.setBottom(quitBtn); BorderPane.setAlignment(quitBtn, Pos.TOP_LEFT); theStage.show(); }
/** * Das GUI besteht aus zwei wesentlichen Komponenten, einer GridPane namens entryArea und einem * TextAreaHandler, beide sind in eine BorderPane eingebettet. */ @Override protected Scene create_GUI() { // ServiceLocator und Translator werden gesetzt. ServiceLocator sl = ServiceLocator.getServiceLocator(); Translator t = sl.getTranslator(); // Die MenuBar enthält die Sprachauswahl MenuBar menuBar = new MenuBar(); menuFile = new Menu(t.getString("program.menu.file")); menuFileLanguage = new Menu(t.getString("program.menu.file.language")); menuFile.getItems().add(menuFileLanguage); for (Locale locale : sl.getLocales()) { MenuItem language = new MenuItem(locale.getLanguage()); menuFileLanguage.getItems().add(language); language.setOnAction( event -> { sl.setTranslator(new Translator(locale.getLanguage())); updateTexts(); }); } BorderPane root = new BorderPane(); root.setPrefSize(409, 219); menuBar.getMenus().addAll(menuFile); root.setTop(menuBar); /** * ______________________________________________________________________________________________ * START OF GRIDPANE !!! ENTRYAREA !!! */ // Serverentry Area GridPane entryArea = new GridPane(); entryArea.setAlignment(Pos.CENTER); root.setCenter(entryArea); Label lblIP = new Label(); lblIP.setText("IP: "); ; lblIP.setAlignment(Pos.CENTER_LEFT); entryArea.add(lblIP, 0, 0); GridPane.setMargin(lblIP, new Insets(5, 5, 0, 50)); Label lblPort = new Label(); lblPort.setText("Port: "); lblPort.setAlignment(Pos.CENTER_LEFT); entryArea.add(lblPort, 0, 1); GridPane.setMargin(lblPort, new Insets(5, 5, 0, 50)); lblHostName = new Label(); lblHostName.setAlignment(Pos.CENTER_LEFT); lblHostName.setId("lblHostName"); entryArea.add(lblHostName, 0, 2); GridPane.setMargin(lblHostName, new Insets(5, 5, 0, 50)); tfIP = new TextField(); tfIP.setId("tfIP"); tfIP.setEditable(false); entryArea.add(tfIP, 1, 0); GridPane.setMargin(tfIP, new Insets(5, 5, 0, 0)); tfPort = new TextField(); tfPort.setId("tfPort"); tfPort.setText("14000"); tfPort.setPromptText("Bitte Portnummer eingeben."); entryArea.add(tfPort, 1, 1); GridPane.setMargin(tfPort, new Insets(5, 5, 0, 0)); btnStart = new Button(); btnStart.setId("btnStart"); btnStart.setText(t.getString("button.start")); entryArea.add(btnStart, 2, 0); GridPane.setMargin(btnStart, new Insets(5, 5, 0, 50)); btnClose = new Button(); btnClose.setId("btnClose"); btnClose.setText(t.getString("button.close")); entryArea.add(btnClose, 2, 1); GridPane.setMargin(btnClose, new Insets(5, 5, 0, 50)); /** * ______________________________________________________________________________________________ * START OF !!! TEXTAREAHANDLER !!! */ textAreaHandler = new TextAreaHandler(); taLogger = textAreaHandler.getTextArea(); taLogger.setId("taLogger"); taLogger.setEditable(false); root.setBottom(taLogger); Scene scene = new Scene(root); return scene; }
public ConfigurationsDialogBuilder create( DependencyDotFileGenerator dependencyDotFileGenerator, GradleScriptPreferences preferences, Os os, String outputFileName) { this.outputFileName = outputFileName; this.dependencyDotFileGenerator = dependencyDotFileGenerator; this.preferences = preferences; this.os = os; dialog = new ConfigurationChoiceDialog(this); dialog.setResizable(true); dialog.initStyle(UTILITY); dialog.initModality(APPLICATION_MODAL); dialog.setIconified(false); dialog.centerOnScreen(); dialog.borderPanel = BorderPaneBuilder.create().styleClass("dialog").build(); dialog.stackPane = new StackPane(); StackPane stackPane = dialog.stackPane; dialog.log = new TextArea(); TextArea log = dialog.log; BorderPane borderPanel = dialog.borderPanel; // message dialog.configurationsBox = new VBox(); VBox configurationsBox = dialog.configurationsBox; dialog.configurationsBox = configurationsBox; dialog.progressIndicator = new ProgressIndicator(); ProgressIndicator progressIndicator = dialog.progressIndicator; stackPane.getChildren().add(log); stackPane.getChildren().add(progressIndicator); progressIndicator.setPrefSize(50, 50); progressIndicator.setMaxSize(50, 50); configurationsBox.setSpacing(15); configurationsBox.setAlignment(CENTER_LEFT); dialog.scrollPane = new ScrollPane(); ScrollPane scrollPane = dialog.scrollPane; scrollPane.setContent(configurationsBox); dialog.borderPanel.setCenter(stackPane); BorderPane.setAlignment(configurationsBox, CENTER_LEFT); BorderPane.setMargin(configurationsBox, new Insets(MARGIN, MARGIN, MARGIN, 2 * MARGIN)); // buttons dialog.buttonsPanel = new HBox(); final HBox buttonsPanel = dialog.buttonsPanel; buttonsPanel.setSpacing(MARGIN); buttonsPanel.setAlignment(BOTTOM_CENTER); BorderPane.setMargin(buttonsPanel, new Insets(0, 0, 1.5 * MARGIN, 0)); borderPanel.setBottom(buttonsPanel); borderPanel .widthProperty() .addListener( new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) { buttonsPanel.layout(); } }); dialog.scene = new Scene(borderPanel); dialog.setScene(dialog.scene); URL resource = ConfigurationsDialogBuilder.class.getResource( "/com/nurflugel/gradle/ui/dialogservice/dialog.css"); String externalForm = resource.toExternalForm(); // dialog.borderPanel.styleClass("dialog"); dialog.getScene().getStylesheets().add(externalForm); return this; }