Search in sources :

Example 51 with GridPane

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();
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) ActionEvent(javafx.event.ActionEvent) BackgroundImage(javafx.scene.layout.BackgroundImage) Image(javafx.scene.image.Image) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) BackgroundImage(javafx.scene.layout.BackgroundImage) Button(javafx.scene.control.Button) ImageView(javafx.scene.image.ImageView) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane)

Example 52 with GridPane

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);
                    }
                });
            }
        }
    }
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) AlertUtils(org.kanonizo.gui.AlertUtils) TestSuite(org.kanonizo.framework.objects.TestSuite) URL(java.net.URL) Control(javafx.scene.control.Control) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) Application(javafx.application.Application) Task(javafx.concurrent.Task) AlertType(javafx.scene.control.Alert.AlertType) ComboBox(javafx.scene.control.ComboBox) ContextMenu(javafx.scene.control.ContextMenu) Method(java.lang.reflect.Method) ScriptException(javax.script.ScriptException) Rectangle2D(javafx.geometry.Rectangle2D) TextField(javafx.scene.control.TextField) SearchAlgorithm(org.kanonizo.algorithms.SearchAlgorithm) MenuItem(javafx.scene.control.MenuItem) Set(java.util.Set) ConditionalParameter(org.kanonizo.annotations.ConditionalParameter) Screen(javafx.stage.Screen) OptionProvider(org.kanonizo.annotations.OptionProvider) Collectors(java.util.stream.Collectors) TreeView(javafx.scene.control.TreeView) InvocationTargetException(java.lang.reflect.InvocationTargetException) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) List(java.util.List) Util(org.kanonizo.util.Util) Logger(org.apache.logging.log4j.Logger) PropertyChangeListener(java.beans.PropertyChangeListener) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) Display(org.kanonizo.display.Display) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) MouseEvent(javafx.scene.input.MouseEvent) Framework(org.kanonizo.Framework) ReadableConverter(org.kanonizo.display.fx.converters.ReadableConverter) Parameter(com.scythe.instrumenter.InstrumentationProperties.Parameter) HashSet(java.util.HashSet) ResourceBundle(java.util.ResourceBundle) FXMLLoader(javafx.fxml.FXMLLoader) Prerequisite(org.kanonizo.annotations.Prerequisite) Tooltip(javafx.scene.control.Tooltip) GridPane(javafx.scene.layout.GridPane) DirectoryChooser(javafx.stage.DirectoryChooser) KanonizoFxApplication(org.kanonizo.gui.KanonizoFxApplication) ProgressIndicator(javafx.scene.control.ProgressIndicator) Label(javafx.scene.control.Label) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) ScriptEngineManager(javax.script.ScriptEngineManager) StringConverter(javafx.util.StringConverter) Field(java.lang.reflect.Field) File(java.io.File) GuiUtils(org.kanonizo.gui.GuiUtils) FileChooser(javafx.stage.FileChooser) Condition(java.util.concurrent.locks.Condition) ActionEvent(javafx.event.ActionEvent) ScriptEngine(javax.script.ScriptEngine) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) LogManager(org.apache.logging.log4j.LogManager) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) TextField(javafx.scene.control.TextField) Field(java.lang.reflect.Field) ScriptException(javax.script.ScriptException) Control(javafx.scene.control.Control) ConditionalParameter(org.kanonizo.annotations.ConditionalParameter) ConditionalParameter(org.kanonizo.annotations.ConditionalParameter) Parameter(com.scythe.instrumenter.InstrumentationProperties.Parameter)

Example 53 with GridPane

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();
}
Also used : HBox(javafx.scene.layout.HBox) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) RadioButton(javafx.scene.control.RadioButton) MouseButton(javafx.scene.input.MouseButton) Button(javafx.scene.control.Button) TextInputDialog(javafx.scene.control.TextInputDialog) InputDialog(com.kendy.util.InputDialog) Dialog(javafx.scene.control.Dialog) Alert(javafx.scene.control.Alert) ButtonType(javafx.scene.control.ButtonType) Hyperlink(javafx.scene.control.Hyperlink)

Example 54 with GridPane

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);
    });
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) MainPanel(eu.ggnet.saft.sample.support.MainPanel)

Example 55 with GridPane

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();
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets)

Aggregations

GridPane (javafx.scene.layout.GridPane)147 Label (javafx.scene.control.Label)83 Insets (javafx.geometry.Insets)67 Button (javafx.scene.control.Button)46 TextField (javafx.scene.control.TextField)42 VBox (javafx.scene.layout.VBox)37 Scene (javafx.scene.Scene)36 HBox (javafx.scene.layout.HBox)26 ButtonType (javafx.scene.control.ButtonType)25 Text (javafx.scene.text.Text)24 Node (javafx.scene.Node)23 Dialog (javafx.scene.control.Dialog)23 ColumnConstraints (javafx.scene.layout.ColumnConstraints)18 Stage (javafx.stage.Stage)18 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)17 List (java.util.List)16 CheckBox (javafx.scene.control.CheckBox)16 ImageView (javafx.scene.image.ImageView)14 ActionEvent (javafx.event.ActionEvent)13 ComboBox (javafx.scene.control.ComboBox)13