public Pane getCSSStyledPane() { Pane p = new Pane(); p.setPrefSize(100, 50); p.setStyle( "-fx-background-color: lightgray, red;" + "-fx-background-insets: 0, 4;" + "-fx-background-radius: 4, 2;"); return p; }
private void drawPanelForTopHeader() { Pane panel = new Pane(); panel.setId("panelForTopheader"); panel.setPrefSize(722, 382); panel.setLayoutX(-1); panel.setLayoutY(63); this.addToStep(panel); this.contentPanel = panel; }
public void createWallLine(int y) { PositionButton button; Pane wallRec; for (int x = 0; x < 8; x++) { wallRec = new Pane(); wallRec.setPrefSize(30, 10); wallRec.setId("wallRec"); horizontalWalls[x][y] = wallRec; gameGrid.setConstraints(horizontalWalls[x][y], column, row); gameGrid.getChildren().add(horizontalWalls[x][y]); column++; button = new WallPositionButton(new Position(x, y)); button.setPrefSize(10, 10); button.setId("wallPosBtn"); wallPositionButtons[x][y] = button; gameGrid.setConstraints(wallPositionButtons[x][y], column, row); gameGrid.getChildren().addAll(wallPositionButtons[x][y]); column++; } wallRec = new Pane(); wallRec.setPrefSize(30, 10); wallRec.setId("wallRec"); horizontalWalls[8][y] = wallRec; gameGrid.setConstraints(horizontalWalls[8][y], column, row); gameGrid.getChildren().add(horizontalWalls[8][y]); column = 0; row++; }
public Pane getObjectStyledPane() { Pane p = new Pane(); p.setPrefSize(100, 50); BackgroundFill lightGrayFill = new BackgroundFill(Color.LIGHTGRAY, new CornerRadii(4), new Insets(0)); BackgroundFill redFill = new BackgroundFill(Color.RED, new CornerRadii(2), new Insets(4)); // Create a Background object with two BackgroundFill objects Background bg = new Background(lightGrayFill, redFill); p.setBackground(bg); return p; }
/** Draw the header at the top of the window */ private void drawHeader() { final String title = this.getParentWizardTitle(); // FIXME: use this variable to draw the title of the window Pane header = new Pane(); header.setId("header"); header.setPrefSize(722, 65); header.setLayoutX(-1); header.setLayoutY(-1); header.setBackground( new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY))); ImageView topImage = new ImageView(this.createTopImage()); topImage.setLayoutX(626); header.getChildren().add(topImage); this.addToStep(header); }
@Override public void start(Stage primaryStage) throws Exception { root = new Pane((Pane) createContent()); // from game menu root.setPrefSize(windowWidth, windowHeight); gameMenu = new BlackjackMain.GameMenu(); gameMenu.setVisible(true); root.getChildren().addAll(gameMenu); // root.setStyle("-fx-background-image: url('res/images/casino.jpg')"); Scene scene = new Scene(root); scene.setOnKeyPressed( event -> { if (event.getCode() == KeyCode.ESCAPE) { if (!gameMenu.isVisible()) { FadeTransition ft = new FadeTransition(Duration.seconds(0.5), gameMenu); ft.setFromValue(0); ft.setToValue(1); gameMenu.setVisible(true); ft.play(); } else { FadeTransition ft = new FadeTransition(Duration.seconds(0.5), gameMenu); ft.setFromValue(1); ft.setToValue(0); ft.setOnFinished(evt -> gameMenu.setVisible(false)); ft.play(); } } }); // resize(primaryStage); primaryStage.setScene(scene); primaryStage.show(); // primaryStage.setScene(new Scene(createContent())); primaryStage.setWidth(800); primaryStage.setHeight(600); primaryStage.setResizable(false); primaryStage.setTitle("BlackJack"); primaryStage.show(); }
/** Teken het bord */ private void drawBoard() { int x = 0; int y = 0; for (String[] row : this.items) { for (String type : row) { Pane item = new Pane(); item.getStyleClass().add(type); item.setPrefSize(50, 50); this.board.add(item, x, y); x++; } x = 0; y++; } }
public Parent createContent() { Pane root = new Pane(); root.setPrefSize(140, 140); root.setMinSize(Pane.USE_PREF_SIZE, Pane.USE_PREF_SIZE); root.setMaxSize(Pane.USE_PREF_SIZE, Pane.USE_PREF_SIZE); // create rectangle Rectangle rect = new Rectangle(20, 20, 100, 100); rect.setArcHeight(20); rect.setArcWidth(20); rect.setFill(Color.ORANGE); root.getChildren().add(rect); rotateTransition = new RotateTransition(Duration.seconds(4), rect); rotateTransition.setFromAngle(0); rotateTransition.setToAngle(720); rotateTransition.setCycleCount(Timeline.INDEFINITE); rotateTransition.setAutoReverse(true); return root; }
@Override public void start(Stage stage) { Pane p1 = this.getCSSStyledPane(); Pane p2 = this.getObjectStyledPane(); p1.setLayoutX(10); p1.setLayoutY(10); // Place p2 20px right to p1 p2.layoutYProperty().bind(p1.layoutYProperty()); p2.layoutXProperty().bind(p1.layoutXProperty().add(p1.widthProperty()).add(20)); Pane root = new Pane(p1, p2); root.setPrefSize(240, 70); Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("Setting Background Fills for a Region"); stage.show(); stage.sizeToScene(); }
public void createMoveLine(int y) { PositionButton button; Pane wallRec; button = new PlayerPositionButton(new Position(0, y)); button.setPrefSize(60, 60); button.setId("board"); playerPositionButtons[0][y] = button; gameGrid.setConstraints(button, column, row); gameGrid.getChildren().addAll(playerPositionButtons[0][y]); for (int x = 1; x < 9; x++) { column++; wallRec = new Pane(); wallRec.setPrefSize(10, 30); wallRec.setId("wallRec"); verticalWalls[x][y] = wallRec; gameGrid.setConstraints(wallRec, column, row); gameGrid.getChildren().add(verticalWalls[x][y]); column++; button = new PlayerPositionButton(new Position(x, y)); button.setPrefSize(60, 60); button.setId("board"); playerPositionButtons[x][y] = button; gameGrid.setConstraints(button, column, row); gameGrid.getChildren().addAll(playerPositionButtons[x][y]); } column = 0; row++; }
private Parent createContent() throws IOException { dealer = new Hand(dealerCards.getChildren()); player = new Hand(playerCards.getChildren()); Pane root = new Pane(); root.setPrefSize(windowWidth, windowHeight); Region background = new Region(); background.setPrefSize(windowWidth, windowHeight); background.setStyle("-fx-background-image: url('res/images/casino.jpg')"); HBox rootLayout = new HBox(5); rootLayout.setPadding(new Insets(5, 5, 5, 5)); // Rectangle leftBG = new Rectangle(550, 560); // leftBG.setArcWidth(50); // leftBG.setArcHeight(50); // leftBG.setFill(Color.GREEN); // Canvas canvas = new Canvas(560, 560); BufferedImage imgi; GraphicsContext gcfx = canvas.getGraphicsContext2D(); // Graphics gc = canvas.getGraphics(); Image zbyszek = new Image("/res/images/table.png", 560, 560, true, false); gcfx.setFill(DARKSLATEGRAY); gcfx.fillRoundRect(0, 0, 550, 300, 10, 100); gcfx.setFill(BLACK); gcfx.drawImage(zbyszek, 0, 280); // try { // imgi = ImageIO.read(Card.class.getResource("/res/images/table.png")); // // gcfx.drawImage(imgi, 300, 300, null); // canvas.setVisible(true); // } catch (Exception e) { // } Rectangle rightBG = new Rectangle(230, 560); rightBG.setArcWidth(50); rightBG.setArcHeight(50); rightBG.setFill(Color.ORANGE); // LEFT VBox leftVBox = new VBox(50); leftVBox.setAlignment(Pos.TOP_CENTER); Text dealerScore = new Text("Dealer: "); Text playerScore = new Text("Player: "); leftVBox.getChildren().addAll(dealerScore, dealerCards, message, playerCards, playerScore); // RIGHT VBox rightVBox = new VBox(20); rightVBox.setAlignment(Pos.CENTER); // final TextField bet = new TextField("BET"); // bet.setDisable(true); // bet.setMaxWidth(50); // Text money = new Text("MONEY"); Button btnPlay = new Button("PLAY"); Button btnHit = new Button("HIT"); Button btnStand = new Button("STAND"); HBox buttonsHBox = new HBox(15, btnHit, btnStand); buttonsHBox.setAlignment(Pos.CENTER); // rightVBox.getChildren().addAll(bet, btnPlay, money, buttonsHBox); rightVBox.getChildren().addAll(btnPlay, buttonsHBox); // ADD BOTH STACKS TO ROOT LAYOUT rootLayout .getChildren() .addAll(new StackPane(canvas, leftVBox), new StackPane(rightBG, rightVBox)); root.getChildren().addAll(background, rootLayout); // BIND PROPERTIES btnPlay.disableProperty().bind(playable); btnHit.disableProperty().bind(playable.not()); btnStand.disableProperty().bind(playable.not()); playerScore .textProperty() .bind(new SimpleStringProperty("Player: ").concat(player.valueProperty().asString())); dealerScore .textProperty() .bind(new SimpleStringProperty("Dealer: ").concat(dealer.valueProperty().asString())); player .valueProperty() .addListener( (obs, old, newValue) -> { if (newValue.intValue() >= 21) { endGame(); } }); dealer .valueProperty() .addListener( (obs, old, newValue) -> { if (newValue.intValue() >= 21) { endGame(); } }); // INIT BUTTONS btnPlay.setOnAction( event -> { startNewGame(); }); btnHit.setOnAction( event -> { player.takeCard(deck.drawCard()); }); btnStand.setOnAction( event -> { while (dealer.valueProperty().get() < 17) { dealer.takeCard(deck.drawCard()); } endGame(); }); return root; }
public void setContainerSize(double x, double y) { pane.setPrefSize(x, y); }
public void buildForm() { try { URL location = getClass().getResource("/com/webfront/app/fxml/LedgerEntryForm.fxml"); ResourceBundle resources = ResourceBundle.getBundle("com.webfront.app.bank"); FXMLLoader loader = new FXMLLoader(location, resources); btnOk.setDefaultButton(true); btnCancel.setCancelButton(true); stage = new Stage(); scene = new Scene(this); stage.setScene(scene); stage.setTitle("Item Detail"); loader.setRoot(this); loader.setController(this); loader.load(); ObservableList<Category> cList = view.getCategoryManager().getCategories(); ObservableList<Account> accountList = javafx.collections.FXCollections.observableArrayList(Bank.accountList); accountList .stream() .forEach( (acct) -> { accountNum.getItems().add(acct.getId()); }); for (Category c : cList) { // Category parent = c.getParent(); Integer parent = c.getParent(); categoryMap.put(c.getDescription(), c); if (parent == 0) { primaryCat.getItems().add(c.getDescription()); } else if (oldItem != null) { if (oldItem.getPrimaryCat() != null) { if (parent == oldItem.getPrimaryCat().getId()) { subCat.getItems().add(c.getDescription()); } } } } if (oldItem != null) { if (oldItem.getSubCat() != null) { Category c = oldItem.getSubCat(); if (c != null) { String desc = c.getDescription(); if (!subCat.getItems().contains(desc)) { subCat.getItems().add(desc); } subCat.setValue(c.getDescription()); } } } primaryCat .getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { String newCat = newValue.toString(); if (categoryMap.containsKey(newCat)) { if (oldItem.getId() != null) { Category c = categoryMap.get(newCat); String sqlStmt = "SELECT * FROM categories WHERE parent = " + Integer.toString(c.getId()); sqlStmt += " order by description"; ObservableList<Category> subCatList = view.getCategoryManager().getCategories(sqlStmt); subCat.getItems().clear(); subCatMap.clear(); for (Category cat2 : subCatList) { subCatMap.put(cat2.getDescription(), cat2); } subCat.getItems().addAll(subCatMap.keySet()); if (oldItem.getPrimaryCat() == null) { oldItem.setPrimaryCat(c); btnOk.setDisable(false); } if (!oldItem.getPrimaryCat().getDescription().equals(primaryCat.getValue())) { oldItem.setPrimaryCat(c); btnOk.setDisable(false); } } } } }); subCat .getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (newValue != null) { String newCat = newValue.toString(); if (subCatMap.containsKey(newCat)) { if (oldItem != null) { oldItem.setSubCat(subCatMap.get(newCat)); btnOk.setDisable(false); } } } } }); transDescription.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (!transDescription.getText().equals(oldItem.getTransDesc())) { oldItem.setTransDesc(transDescription.getText()); btnOk.setDisable(false); } } }); transDescription .textProperty() .addListener( new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (!oldValue.equals(newValue)) { btnOk.setDisable(false); } } }); checkNum.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.TAB) { if (!checkNum.getText().equals(oldItem.getCheckNum())) { oldItem.setCheckNum(checkNum.getText()); btnOk.setDisable(false); } } } }); transAmt .textProperty() .addListener( new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (!oldValue.equals(newValue)) { btnOk.setDisable(false); } } }); distView.setPrefSize(857.0, 175.0); paymentDetail.setPrefSize(857.0, 175.0); distView.getChildren().add(paymentDetail); stage.show(); } catch (IOException ex) { Logger.getLogger(LedgerForm.class.getName()).log(Level.SEVERE, null, ex); } }
@Override public void start(Stage stage) { LoginFX.stage = stage; stage.setTitle("SGAP - Login"); pane = new Pane(); pane.setPrefSize(400, 120); pane.setStyle( "-fx-background-color:linear-gradient(from 0% 0% to 100% 100%, silver 0%, gold 100%);"); tfLogin = new TextField(); tfLogin.setPromptText("Digite aqui seu login"); tfLogin.setPrefSize(200, tfLogin.getFont().getSize()); tfSenha = new PasswordField(); tfSenha.setPromptText("Digite aqui a senha"); tfSenha.setPrefSize(200, tfSenha.getFont().getSize()); tfSenha.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { botaoLogar(); } } }); bEntrar = new Button("Entrar"); bEntrar.setPrefSize(100, bEntrar.getFont().getSize() + 5); bEntrar.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { botaoLogar(); } }); bSair = new Button("Sair"); bSair.setPrefSize(100, bSair.getFont().getSize() + 5); bSair.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { botaoSair(); } }); tfLogin.setLayoutX( (pane.getPrefWidth() - 1.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2); tfSenha.setLayoutX( (pane.getPrefWidth() - 1.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2); bEntrar.setLayoutX( (pane.getPrefWidth() + 3.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2); bSair.setLayoutX( (pane.getPrefWidth() + 3.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2); tfLogin.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 - 20); tfSenha.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 + 20); bEntrar.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 - 20); bSair.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 + 20); pane.getChildren().addAll(tfLogin, tfSenha, bEntrar, bSair); Scene cena = new Scene(pane); stage.setScene(cena); stage.show(); }
private void resize() { width = getSkinnable().getWidth() - getSkinnable().getInsets().getLeft() - getSkinnable().getInsets().getRight(); height = getSkinnable().getHeight() - getSkinnable().getInsets().getTop() - getSkinnable().getInsets().getBottom(); if (ASPECT_RATIO * width > height) { width = 1 / (ASPECT_RATIO / height); } else if (1 / (ASPECT_RATIO / height) > width) { height = ASPECT_RATIO * width; } if (width > 0 && height > 0) { double centerX = width * 0.5; double centerY = height * 0.85; double barRadius = height * 0.54210526; double barWidth = width * 0.28472222; pane.setMaxSize(width, height); pane.relocate( (getSkinnable().getWidth() - width) * 0.5, (getSkinnable().getHeight() - height) * 0.5); barBackground.setCenterX(centerX); barBackground.setCenterY(centerY); barBackground.setRadiusX(barRadius); barBackground.setRadiusY(barRadius); barBackground.setStrokeWidth(barWidth); barBackground.setStartAngle(angleRange * 0.5 + 90); barBackground.setLength(-angleRange); if (sectionsVisible && sectionsAlwaysVisible) { sectionLayer.setPrefSize(width, height); drawSections(); } bar.setCenterX(centerX); bar.setCenterY(centerY); bar.setRadiusX(barRadius); bar.setRadiusY(barRadius); bar.setStrokeWidth(barWidth); bar.setStartAngle(angleRange * 0.5 + 90); bar.setLength(-(getSkinnable().getCurrentValue() - minValue) * angleStep); double needleWidth = height * 0.13157895; double needleHeight = height * 0.91315789; needle.setCache(true); needleMoveTo1.setX(0.0); needleMoveTo1.setY(0.927953890489914 * needleHeight); needleCubicCurveTo2.setControlX1(0); needleCubicCurveTo2.setControlY1(0.968299711815562 * needleHeight); needleCubicCurveTo2.setControlX2(0.22 * needleWidth); needleCubicCurveTo2.setControlY2(needleHeight); needleCubicCurveTo2.setX(0.5 * needleWidth); needleCubicCurveTo2.setY(needleHeight); needleCubicCurveTo3.setControlX1(0.78 * needleWidth); needleCubicCurveTo3.setControlY1(needleHeight); needleCubicCurveTo3.setControlX2(needleWidth); needleCubicCurveTo3.setControlY2(0.968299711815562 * needleHeight); needleCubicCurveTo3.setX(needleWidth); needleCubicCurveTo3.setY(0.927953890489914 * needleHeight); needleCubicCurveTo4.setControlX1(needleWidth); needleCubicCurveTo4.setControlY1(0.92507204610951 * needleHeight); needleCubicCurveTo4.setControlX2(0.6 * needleWidth); needleCubicCurveTo4.setControlY2(0.0144092219020173 * needleHeight); needleCubicCurveTo4.setX(0.6 * needleWidth); needleCubicCurveTo4.setY(0.0144092219020173 * needleHeight); needleCubicCurveTo5.setControlX1(0.6 * needleWidth); needleCubicCurveTo5.setControlY1(0.0144092219020173 * needleHeight); needleCubicCurveTo5.setControlX2(0.58 * needleWidth); needleCubicCurveTo5.setControlY2(0); needleCubicCurveTo5.setX(0.5 * needleWidth); needleCubicCurveTo5.setY(0); needleCubicCurveTo6.setControlX1(0.42 * needleWidth); needleCubicCurveTo6.setControlY1(0); needleCubicCurveTo6.setControlX2(0.4 * needleWidth); needleCubicCurveTo6.setControlY2(0.0144092219020173 * needleHeight); needleCubicCurveTo6.setX(0.4 * needleWidth); needleCubicCurveTo6.setY(0.0144092219020173 * needleHeight); needleCubicCurveTo7.setControlX1(0.4 * needleWidth); needleCubicCurveTo7.setControlY1(0.0144092219020173 * needleHeight); needleCubicCurveTo7.setControlX2(0); needleCubicCurveTo7.setControlY2(0.92507204610951 * needleHeight); needleCubicCurveTo7.setX(0); needleCubicCurveTo7.setY(0.927953890489914 * needleHeight); needle.setCache(true); needle.setCacheHint(CacheHint.ROTATE); needle.relocate( (width - needle.getLayoutBounds().getWidth()) * 0.5, centerY - needle.getLayoutBounds().getHeight() + needle.getLayoutBounds().getWidth() * 0.5); needleRotate.setPivotX(needle.getLayoutBounds().getWidth() * 0.5); needleRotate.setPivotY( needle.getLayoutBounds().getHeight() - needle.getLayoutBounds().getWidth() * 0.5); resizeStaticText(); } }