@Override public void start(Stage primaryStage) throws Exception { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setVgap(10); grid.setHgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); Scene sc = new Scene(grid, 500, 500); String css = Main.class.getResource("Login.css").toExternalForm(); // System.out.println(css); sc.getStylesheets().add(css); Text scenetitle = new Text("Welcome"); // scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(scenetitle, 0, 0, 1, 1); Label userName = new Label("User Name:"); grid.add(userName, 0, 1); TextField userTextField = new TextField("Мудак"); grid.add(userTextField, 1, 1); Label pw = new Label("Password:"******"Sign in"); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(btn); grid.add(hbBtn, 1, 4); final Text actiontarget = new Text(); grid.add(actiontarget, 1, 6); btn.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // actiontarget.setFill(Color.FIREBRICK); actiontarget.setText("Pressed"); } }); // grid.setGridLinesVisible(true); scenetitle.setId("welc"); actiontarget.setId("act"); primaryStage.setScene(sc); primaryStage.setTitle("Hello World"); primaryStage.show(); }
@Override public void start(Stage primaryStage) { try { TabPane page = (TabPane) FXMLLoader.load(Main.class.getResource("simple.fxml")); Scene scene = new Scene(page); primaryStage.setScene(scene); primaryStage.setTitle("Hotels"); primaryStage.show(); textf = (TextField) scene.lookup("#HotelNameTextb"); Button create = (Button) scene.lookup("#CreateButton"); create.setOnAction(this::handleButtonAction); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } }