Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package guifx;
- import javafx.application.Application;
- import javafx.geometry.Insets;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.control.ListView;
- import javafx.scene.control.TextField;
- import javafx.scene.layout.GridPane;
- import javafx.stage.Stage;
- public class MainApp extends Application {
- public static void main(String[] args) {
- Application.launch(args);
- }
- @Override
- public void start(Stage stage) {
- stage.setTitle("AArhus Bryghus");
- GridPane pane = new GridPane();
- this.initContent(pane);
- produktWindow = new ProduktInputWindow("Opret produkt", stage);
- Scene scene = new Scene(pane);
- stage.setScene(scene);
- stage.show();
- }
- // -------------------------------------------------------------------------
- private TextField txfResult;
- private ListView<Produkt> lvwProdukt;
- private ProduktInputWindow produktWindow;
- private void initContent(GridPane pane) {
- // show or hide grid lines
- pane.setGridLinesVisible(false);
- // set padding of the pane
- pane.setPadding(new Insets(20));
- // set horizontal gap between components
- pane.setHgap(10);
- // set vertical gap between components
- pane.setVgap(10);
- // add a label to the pane (at col=0, row=0)
- Label lblName = new Label("Produkt :");
- pane.add(lblName, 0, 0);
- // add a text field to the pane
- // (at col=1, row=0, extending 2 columns and 1 row)
- txfResult = new TextField();
- pane.add(txfResult, 1, 0, 2, 1);
- lvwProdukt = new ListView<Produkt>();
- pane.add(lvwProdukt, 1,1,3,1);
- lvwProdukt.setPrefWidth(200);
- lvwProdukt.setPrefHeight(200);
- // add a button to the pane (at col=1, row=1)
- Button btnCreateMovie = new Button("Opret Produkt");
- pane.add(btnCreateMovie, 1, 1);
- GridPane.setMargin(btnCreateMovie, new Insets(10, 10, 0, 10));
- // connect a method to the button
- btnCreateMovie.setOnAction(event -> this.createProduktAction());
- }
- // -----------------------------------------------------
- // Button actions
- private void createProduktAction() {
- produktWindow.showAndWait();
- if (produktWindow.getActualProdukt() != null) {
- txfResult.setText(produktWindow.getActualProdukt().toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement