use of javafx.scene.layout.GridPane in project CST-135 by psradke.
the class FinalSale method start.
@Override
public void start(Stage primaryStage) throws Exception {
// Background image
BackgroundImage backImg = new BackgroundImage(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/FinalSaleBackground.png", 810, 720, false, true), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
// PANE CREATION
// Home and Back Buttons Pane
GridPane buttons = new GridPane();
buttons.setHgap(10);
buttons.setVgap(10);
buttons.setPadding(new Insets(0, 10, 0, 10));
// TableView Cart Pane
GridPane cartView = new GridPane();
cartView.setHgap(9);
cartView.setVgap(9);
cartView.setOpacity(0.9);
cartView.setPadding(new Insets(0, 10, 0, 10));
// Delete and Purchase Buttons Pane
GridPane buttons2 = new GridPane();
buttons2.setHgap(10);
buttons2.setVgap(10);
buttons2.setPadding(new Insets(0, 10, 0, 10));
// Main Pane for arrangement
VBox vBox = new VBox();
vBox.setPadding(new Insets(10, 10, 10, 10));
vBox.getChildren().addAll(buttons, cartView, buttons2);
// Background Pane
StackPane root = new StackPane();
root.setMaxSize(800, 610);
root.setMinSize(800, 610);
root.setBackground(new Background(backImg));
root.setPadding(new Insets(0, 10, 0, 10));
root.getChildren().add(vBox);
// BUTTON CREATION
// Home Button
Button home = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/HomeButton.png")));
home.setBackground(Background.EMPTY);
home.setMaxSize(5, 10);
home.setMinSize(5, 10);
buttons.add(home, 9, 2);
// home.setOnAction(e -> {
// homePage.setScene(scene);
// });
// Back Button
Button back = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/BackButton.png")));
back.setBackground(Background.EMPTY);
back.setMaxSize(5, 10);
back.setMinSize(5, 10);
buttons.add(back, 64, 2);
back.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Back");
}
});
// Purchase Button
Button purchase = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/Purchase.png")));
purchase.setBackground(Background.EMPTY);
purchase.setMaxSize(5, 10);
purchase.setMinSize(5, 10);
buttons2.add(purchase, 36, 11);
purchase.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Purcahse");
}
});
// Delete Button
// Button delete = new Button("Delete Product");
// delete.setOnAction(e -> deleteClicked());
// CREATE TABLE FOR DISPLAYING CART
TableView<Product> table;
// Name column
TableColumn<Product, String> nameCol = new TableColumn<>("Name");
nameCol.setMinWidth(150);
nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
// Price column
TableColumn<Product, Double> priceCol = new TableColumn<>("Price");
priceCol.setMinWidth(20);
priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
// Weight column
TableColumn<Product, Double> weightCol = new TableColumn<>("Weight");
weightCol.setMinWidth(50);
weightCol.setCellValueFactory(new PropertyValueFactory<>("weight"));
// Quantity column
TableColumn<Product, Double> quantityCol = new TableColumn<>("Quantity");
quantityCol.setMinWidth(20);
quantityCol.setCellValueFactory(new PropertyValueFactory<>("quantity"));
table = new TableView<>();
table.setItems(getProduct());
table.setBackground(Background.EMPTY);
table.setMaxSize(620, 313);
table.setMinSize(620, 313);
table.getColumns().addAll(nameCol, priceCol, weightCol, quantityCol);
cartView.add(table, 7, 18);
Scene scene = new Scene(root, 800, 710);
primaryStage.setTitle("Checkout");
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
use of javafx.scene.layout.GridPane in project kanonizo by kanonizo.
the class KanonizoFrame method addParams.
private void addParams(Object alg, GridPane paramLayout, boolean runPrerequisites) {
List<Field> params = Arrays.asList(alg.getClass().getFields()).stream().filter(f -> f.getAnnotation(Parameter.class) != null).collect(Collectors.toList());
int row = 0;
int col = -1;
for (Field param : params) {
if (col + 2 > ITEMS_PER_ROW * 2) {
col = -1;
row++;
}
Label paramLabel = new Label(Util.humanise(param.getName()) + ":");
paramLabel.setAlignment(Pos.CENTER_LEFT);
paramLabel.setTooltip(new Tooltip(Util.humanise(param.getName())));
Control paramField = getParameterField(param, runPrerequisites);
paramField.setTooltip(new Tooltip(param.getAnnotation(Parameter.class).description()));
paramLayout.add(paramLabel, ++col, row, 1, 1);
paramLayout.add(paramField, ++col, row, 1, 1);
if (param.isAnnotationPresent(ConditionalParameter.class)) {
String condition = param.getAnnotation(ConditionalParameter.class).condition();
String[] listensTo = param.getAnnotation(ConditionalParameter.class).listensTo().split(",");
for (String listen : listensTo) {
Util.addPropertyChangeListener(listen, (e) -> {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("nashorn");
try {
Class<?> container = param.getDeclaringClass();
engine.put("CallerClass", container);
engine.eval("var " + container.getSimpleName() + " = CallerClass.static");
boolean cond = (boolean) engine.eval(condition);
paramField.setDisable(!cond);
paramLabel.setDisable(!cond);
} catch (ScriptException ex) {
logger.error(ex);
}
});
}
}
}
}
use of javafx.scene.layout.GridPane in project financial by greatkendy123.
the class MyController method selectLM.
private void selectLM() {
Dialog dialog = new Dialog<>();
dialog.setTitle("请选择联盟:");
dialog.setHeaderText(null);
// 添加联盟按钮
GridPane grid = new GridPane();
grid.setPrefHeight(150);
grid.setPrefWidth(200);
grid.setHgap(10);
grid.setVgap(20);
grid.setPadding(new Insets(20, 15, 10, 10));
for (int i = 0; i < 3; i++) {
Button btn = new Button("联盟" + (i + 1));
btn.setPrefWidth(200);
btn.setOnAction(event -> {
selected_LM_type = btn.getText();
dialog.setTitle(selected_LM_type);
System.out.println(selected_LM_type);
});
grid.add(btn, 0, i);
}
// 添加取消按钮
HBox hbox = new HBox();
hbox.setPadding(new Insets(0, 0, 0, 70));
hbox.setSpacing(10);
hbox.setStyle("-fx-background-color:#FFFFFF;");
Hyperlink cancleLink = new Hyperlink("取消");
cancleLink.setPrefWidth(100);
cancleLink.setOnAction(event -> {
selected_LM_type = "";
System.out.println("selected_LM_type:" + selected_LM_type);
dialog.close();
});
hbox.getChildren().addAll(cancleLink);
grid.add(hbox, 0, 3);
// 添加确定按钮
ButtonType loginButtonType = new ButtonType("确定", ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType);
dialog.setOnCloseRequest(event -> {
final_selected_LM_type = StringUtil.nvl(selected_LM_type, "联盟1");
if ("".equals(selected_LM_type)) {
return;
}
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("提示");
alert.setHeaderText(null);
alert.setContentText("\r\n==== " + selected_LM_type + " ===, 确定??");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() != ButtonType.OK) {
selected_LM_type = "";
System.out.println("selected_LM_type:" + selected_LM_type);
} else {
System.out.println("最终选择:" + selected_LM_type);
}
});
dialog.getDialogPane().setContent(grid);
dialog.showAndWait();
}
use of javafx.scene.layout.GridPane in project dwoss by gg-net.
the class SwingJavaFxDialog method main.
public static void main(String[] args) {
Ui.exec(() -> {
UiCore.startSwing(() -> new MainPanel());
Ui.build().dialog().eval(() -> {
Dialog<String> dialog = new Dialog<>();
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField username = new TextField();
username.setPromptText("Username");
grid.add(new Label("Username:"), 0, 0);
grid.add(username, 1, 0);
dialog.setResultConverter(buttonType -> {
if (buttonType.equals(OK))
return username.getText();
return null;
});
dialog.getDialogPane().setContent(grid);
dialog.getDialogPane().getButtonTypes().addAll(OK, CANCEL);
return dialog;
}).opt().ifPresent(System.out::println);
});
}
use of javafx.scene.layout.GridPane in project dwoss by gg-net.
the class JavaFxDialogExample method start.
@Override
public void start(Stage primaryStage) throws Exception {
Dialog<String> dialog = new Dialog<>();
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField username = new TextField();
username.setPromptText("Username");
grid.add(new Label("Username:"), 0, 0);
grid.add(username, 1, 0);
dialog.setResultConverter(buttonType -> {
if (buttonType.equals(OK))
return username.getText();
return null;
});
dialog.getDialogPane().setContent(grid);
dialog.getDialogPane().getButtonTypes().addAll(OK, CANCEL);
dialog.showAndWait();
}
Aggregations