@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(); }
/** Initializer */ protected void init() { mFossilUpgradesPane = new FossilUpgradePane(mModel); EventHandler<ActionEvent> upgradeEvent = new PanelChangeEvent(mFossilUpgradesPane); mFossilUpgrades = new ImageButton("fossilfuelupgrade.png", upgradeEvent); mApply = new Button("Apply"); EventHandler<ActionEvent> applyEvent = new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { mModel .getEnergyManager() .getFossil() .setAmount(Integer.parseInt(mValues.get("Plants in Operation").getText())); } }; EventHandler<ActionEvent> upEvent = new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { mValues .get("Plants in Operation") .setText("" + (Integer.parseInt(mValues.get("Plants in Operation").getText()) + 1)); } }; EventHandler<ActionEvent> downEvent = new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { if (Integer.parseInt(mValues.get("Plants in Operation").getText()) != 0) { mValues .get("Plants in Operation") .setText( "" + (Integer.parseInt(mValues.get("Plants in Operation").getText()) - 1)); } } }; mApply.setOnAction(applyEvent); mUp = new ImageButton("up.png", upEvent); mDown = new ImageButton("down.png", downEvent); mUp.setPrefSize(0, 0); mDown.setPrefSize(0, 0); setHalignment(mDown, HPos.CENTER); setHalignment(mUp, HPos.CENTER); setHalignment(mApply, HPos.CENTER); setHalignment(mFossilUpgrades, HPos.RIGHT); }
protected void init() { mActionButton = new Button("Apply"); mActionButton.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { mModel.getUpgradeManager().addLobby(mLobby.getChange()); mModel.getResourceManager().spendActionPoints(Math.abs(mLobby.getChange())); mModel.getUpgradeManager().addOilDrilling(mOil.getChange()); mModel.getResourceManager().spendActionPoints(Math.abs(mOil.getChange())); mModel.getUpgradeManager().addPriceChange(mPrice.getChange()); mModel.getResourceManager().spendActionPoints(Math.abs(mPrice.getChange())); mLobby.saveChanges(); mOil.saveChanges(); mPrice.saveChanges(); update(); } }); setHalignment(mActionButton, HPos.LEFT); }
public static void setJar(final Tile node) { node.data.put("type", "Jar"); List<Node> toRemove = new ArrayList<>(); for (Node n : node.node.getChildren()) { if (!n.getId().equals("delete")) { if (n.getId().equals("typeLabel")) { Label l = (Label) n; l.setText("jar"); l.setTranslateY(l.getTranslateY() - 1); } else { toRemove.add(n); } } } VBox leftPadding = new VBox(); leftPadding.setPrefWidth(14); VBox buttons = new VBox(); VBox textBoxes = new VBox(); VBox extra = new VBox(); buttons.setSpacing(5); textBoxes.setSpacing(5); extra.setSpacing(5); buttons.setPadding(new Insets(7, 0, 0, 0)); textBoxes.setPadding(new Insets(7, 0, 0, 0)); extra.setPadding(new Insets(7, 0, 0, 0)); textBoxes.setTranslateX(17); extra.setTranslateX(32); node.node.getChildren().removeAll(toRemove); final String name = "Package Name"; final String name2 = "Jar Name"; Button findPkg = new Button(); final TextField pkgText = new TextField(); final TextField jarName = new TextField(); findPkg.getStyleClass().add("defaultButton"); findPkg.setText("Find Package Name"); findPkg.setPrefHeight(25); findPkg.setTranslateX(12); findPkg.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { String mainClassName = Util.packageNameFromTile(); if (mainClassName != null) { pkgText.setText(mainClassName); } } }); pkgText.setText(name); pkgText.setPrefSize(150, 27); pkgText.setFont(Font.font("Segoe UI")); pkgText.setId("textBox"); pkgText .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("package", pkgText.getText().trim()); } }); pkgText .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && pkgText.getText().equals(name)) { pkgText.setText(""); } else if (newValue == false && pkgText.getText().trim().equals("")) { pkgText.setText(name); } } }); jarName.setText(name2); jarName.setPrefSize(150, 27); jarName.setFont(Font.font("Segoe UI")); jarName.setId("textBox"); jarName .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("jarname", jarName.getText().trim()); } }); jarName .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && jarName.getText().equals(name2)) { jarName.setText(""); } else if (newValue == false && jarName.getText().trim().equals("")) { jarName.setText(name2); } } }); final String defTxt = "Additional Flags"; final TextField flags = new TextField(); flags.setText(defTxt); flags.setPrefSize(150, 27); flags.setFont(Font.font("Segoe UI")); flags.setId("textBox"); flags .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && flags.getText().equals(defTxt)) { flags.setText(""); } else if (newValue == false && flags.getText().trim().equals("")) { flags.setText(defTxt); } } }); flags .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("flags", flags.getText().trim()); } }); final String defTxt2 = "Output Directory"; final TextField outputDir = new TextField(); outputDir.setText(defTxt2); outputDir.setPrefSize(150, 27); outputDir.setFont(Font.font("Segoe UI")); outputDir.setId("textBox"); outputDir .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && outputDir.getText().equals(defTxt2)) { outputDir.setText(""); } else if (newValue == false && outputDir.getText().trim().equals("")) { outputDir.setText(defTxt2); } } }); outputDir .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("output", outputDir.getText().trim()); } }); buttons.getChildren().addAll(findPkg); textBoxes.getChildren().addAll(pkgText, jarName); extra.getChildren().addAll(flags, outputDir); node.node.getChildren().addAll(leftPadding, buttons, textBoxes, extra); }