@SuppressWarnings("unchecked") private void initComponents() { pane = new AnchorPane(); pane.setPrefSize(800, 600); pane.setStyle( "-fx-background-color: linear-gradient(from 0% 0% to 100% 100%, blue 0%, silver 100%);"); txPesquisa = new TextField(); DropShadow ds = new DropShadow(); ds.setSpread(0.5); ds.setColor(Color.web("#FF0000")); txPesquisa.setEffect(ds); txPesquisa.setPromptText("Digite o item para pesquisa"); txPesquisa.setPrefWidth(200); txPesquisa.setFocusTraversable(false); tbVitrine = new TableView<ItensProperty>(); initItens(); tbVitrine.setItems(listItens); tbVitrine.setPrefSize(780, 550); columnProduto = new TableColumn<ItensProperty, String>(); columnProduto.setCellValueFactory(new PropertyValueFactory<ItensProperty, String>("produto")); columnProduto.setText("Produto"); columnPreco = new TableColumn<ItensProperty, Double>(); columnPreco.setCellValueFactory(new PropertyValueFactory<ItensProperty, Double>("preco")); columnPreco.setText("Preço"); tbVitrine.getColumns().addAll(columnProduto, columnPreco); pane.getChildren().addAll(txPesquisa, tbVitrine); }
/** * Desactive le textfield passe en parametre * * @param textField le textfield a desactiver */ public static void desactiverTextField(TextField textField) { textField.setEditable(false); textField.setMouseTransparent(true); textField.setFocusTraversable(false); textField.setText(""); textField.setStyle("-fx-background-color:#cccccc"); }
public static Tuple2<Label, TextField> addLabelTextField( GridPane gridPane, int rowIndex, String title, String value, double top) { Label label = addLabel(gridPane, rowIndex, title, top); TextField textField = new TextField(value); textField.setEditable(false); textField.setMouseTransparent(true); textField.setFocusTraversable(false); GridPane.setRowIndex(textField, rowIndex); GridPane.setColumnIndex(textField, 1); GridPane.setMargin(textField, new Insets(top, 0, 0, 0)); gridPane.getChildren().add(textField); return new Tuple2<>(label, textField); }
public static void launchForm() { loginForm.setTitle("Welcome to GEEK - Log in or Register"); loginForm.setResizable(false); loginForm .getIcons() .add(new Image(LoginForm.class.getResource("../style_elements/logo.png").toExternalForm())); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); ImageView logo = new ImageView((LoginForm.class.getResource("../style_elements/logo.png").toExternalForm())); logo.setFitHeight(100); logo.setFitWidth(100); grid.setMargin(logo, new Insets(0, 0, 0, 72)); grid.add(logo, 1, 1); username.setId("input_field"); username.setPromptText("Username"); username.setMinWidth(250); username.setFocusTraversable(false); grid.add(username, 1, 2); password.setId("input_field"); password.setPromptText("Password"); password.setMinWidth(250); password.setFocusTraversable(false); grid.add(password, 1, 3); sign_in_button.setId("sign_in_button"); sign_in_button.setPrefHeight(35); sign_in_button.setCursor(Cursor.HAND); register_button.setId("register_button"); register_button.setPrefHeight(35); register_button.setCursor(Cursor.HAND); HBox buttons = new HBox(10); buttons.setAlignment(Pos.CENTER); buttons.getChildren().addAll(sign_in_button, register_button); grid.add(buttons, 1, 4); HBox text = new HBox(3); text.setAlignment(Pos.CENTER); error_message_field.setFill(Color.WHITE); error_message_field.setId("error"); text.getChildren().add(error_message_field); grid.add(text, 1, 6); setButtonsActions(); Scene scene = new Scene(grid, 500, 500); scene .getStylesheets() .add(LoginForm.class.getResource("../style_elements/login_form.css").toExternalForm()); loginForm.setScene(scene); loginForm.show(); isOpen = true; }
/** * Active le textfield passe en parametre * * @param textField le textfield a activer */ public static void activerTextField(TextField textField) { textField.setEditable(true); textField.setMouseTransparent(false); textField.setFocusTraversable(true); textField.setStyle(null); }
/** * Here is our whole stage with layout, </Br > ( Grid, TextField and Buttons) * * @author PatrikWebb */ public void NameDisplay() { Stage nameWindow = new Stage(); // Block events to other windows nameWindow.initModality(Modality.APPLICATION_MODAL); nameWindow.setTitle("Enter your name"); nameWindow.setMinWidth(250); // GridPane Form GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(8); grid.setHgap(10); // Name Label Label nameLabel = new Label("Player Name:"); GridPane.setConstraints(nameLabel, 0, 0); // Name Input nameInput = new TextField(); nameInput.setPromptText("Name"); nameInput.setFocusTraversable(false); GridPane.setConstraints(nameInput, 1, 0); // Betting Label Label bettingLabel = new Label("Betting amount: "); GridPane.setConstraints(bettingLabel, 0, 1); // Bett Input playerCashInput = new TextField(); playerCashInput.setFocusTraversable(false); playerCashInput.setPromptText("Betting amount"); GridPane.setConstraints(playerCashInput, 1, 1); // Enter button Button enterButton = new Button("Enter"); enterButton.setFocusTraversable(false); // setPercentWidth(50); GridPane.setConstraints(enterButton, 1, 2); // Cancel button Button cancelButton = new Button("Demo Player"); cancelButton.setFocusTraversable(false); GridPane.setConstraints(cancelButton, 2, 2); // enterButton.setOnAction( e -> { Platform.runLater( () -> { // Get the input from the nameInput TextField name = nameInput.getText(); // Get the betting input from the bettsInput TextField playerCash = Integer.parseInt(playerCashInput.getText()); // Add name and playerCash input to a new player Bank.getInstance().addPlayerToBank(name, playerCash); // Add the player to the table Bank.getInstance().addPlayersToTheTable(); // Close the stage nameWindow.close(); System.out.println("\nPlayer Name: " + name); System.out.println("Betting Amount: " + playerCash + "\n"); }); }); cancelButton.setOnAction( e -> { // TODO Platform.runLater( () -> { /* * * * * * * * * * * * * * If you press cancel you still want a player to join * the table so I add a test player insted of * getting the error, Exception JavaFX Application THREAD ;) * * * * * * * * * * * * */ Bank.getInstance().addPlayerToBank("Demo Player", 500); // Add the player to the table Bank.getInstance().addPlayersToTheTable(); nameWindow.close(); }); }); // Add everything to grid grid.getChildren() .addAll(nameLabel, nameInput, bettingLabel, playerCashInput, enterButton, cancelButton); // Display window and wait for it to be closed before returning Scene scene = new Scene(grid, 450, 150); nameWindow.setScene(scene); nameWindow.showAndWait(); }