private void createMasterPane() {
    webView = new WebView();

    webViewAnchorPane = new AnchorPane(webView);
    AnchorPane.setBottomAnchor(webView, 0.0);
    AnchorPane.setTopAnchor(webView, 0.0);
    AnchorPane.setLeftAnchor(webView, 0.0);
    AnchorPane.setRightAnchor(webView, 0.0);

    webEngine = webView.getEngine();

    dialog = Dialogs.create().lightweight().modal().owner(webView);

    //        locals = new LocalJSObject(webEngine);
    //        globals = GlobalJSObject.getGlobalJSObject(webEngine);
    javaScriptHelpers = new BurpKitBridge(webEngine);
    originalUserAgent = webEngine.getUserAgent();
    webEngine.setJavaScriptEnabled(true);
    webEngine.setOnAlert(this::handleAlert);
    webEngine.setOnError(this::handleError);
    webEngine.setConfirmHandler(param -> true);
    webEngine.getLoadWorker().stateProperty().addListener(this::workerStateChanged);

    createToolBar();

    createStatusBar();

    webEngine.load("about:blank");

    masterPane = new BorderPane();
    masterPane.setTop(toolBar);
    masterPane.setCenter(webViewAnchorPane);
    masterPane.setBottom(statusBar);
  }
Exemple #2
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    window = primaryStage;
    window.setTitle("The Title");

    // Edit menu
    Menu difficultyMenu = new Menu("Difficulty");

    ToggleGroup group = new ToggleGroup();
    RadioMenuItem easy = new RadioMenuItem("Easy");
    RadioMenuItem medium = new RadioMenuItem("Medium");
    RadioMenuItem hard = new RadioMenuItem("Hard");

    easy.setToggleGroup(group);
    medium.setToggleGroup(group);
    hard.setToggleGroup(group);

    hard.setSelected(false);
    hard.setOnAction(
        e -> {
          System.out.println("You selected hard");
        });

    difficultyMenu.getItems().addAll(easy, medium, hard);

    MenuBar menuBar = new MenuBar();
    menuBar.getMenus().addAll(difficultyMenu);

    BorderPane layout = new BorderPane();
    layout.setTop(menuBar);

    Scene scene = new Scene(layout, 500, 400);
    window.setScene(scene);
    window.show();
  }
  private Scene createMainTetrisScene() {
    mainPane = new BorderPane();

    VBox mainBox = new VBox();
    mainBox.setPadding(new Insets(200, 0, 0, 20));
    mainBox.getChildren().add(mainGrid);
    mainGrid.setOnKeyPressed(new KeyboardHandler());

    mainPane.setBottom(mainBox);
    mainPane.setTop(createActionPane());
    mainPane.setRight(createStatePane());

    Group group = new Group();
    for (int i = 19; i >= 0; i--) {
      for (int j = 0; j < 10; j++) {
        Image img;
        if (mainGrid.getColor(i, j) != Color.DARKGRAY) {
          img = new Image(getClass().getResourceAsStream("RED.png"));
        } else {
          img = new Image(getClass().getResourceAsStream("EMPTY.png"));
        }
        ImageView iView = new ImageView(img);
        iView.setX(j * 17);
        iView.setY(i * 16);
        iView.setOpacity(1);
        iView.setPreserveRatio(true);
        group.getChildren().addAll(iView);
      }
    }
    Scene scene = new Scene(group, 600, 600);
    mainPane.setCenter(group);

    return new Scene(mainPane, 380, 540); // 540
  }
  /** DEFAULT. */
  public CafePricingDialog() {
    this.priceMap = new HashMap<>();
    this.primaryStage = new Stage();
    this.root = new Group();
    this.scrollPane = new ScrollPane();
    this.scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    this.scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    this.scene = new Scene(scrollPane, 0x190, 0x1f4, Color.LIGHTGREY);

    makeDialog(fp);

    fp.setMinSize(380, 480);
    fp.setAlignment(Pos.TOP_CENTER);

    bp.setTop(logoChildBP);
    bp.setCenter(labelChildBP);
    bp.setBottom(fp);

    root.getChildren().add(bp);

    scrollPane.setContent(root);

    // --------------------------------------------
    this.primaryStage.setTitle(TITLE);
    this.primaryStage.setScene(scene);
    this.primaryStage.setResizable(false);
    this.primaryStage.show();
  }
Exemple #5
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    top = new Top(this);
    tWindow = new TeacherWindow();
    sWindow = new StudentWindow();
    // Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("Jeopardy");
    background.setImage(jeopardy);
    stack.getChildren().add(background);
    stack.getChildren().add(border);
    border.setTop(top);
    Scene scene = new Scene(stack, 800, 800);
    primaryStage.setScene(scene);
    background.fitWidthProperty().bind(scene.widthProperty());
    background.fitHeightProperty().bind(scene.heightProperty());
    primaryStage.show();

    top.tButton.setOnAction(
        e -> {
          System.out.println("clicked");
          displayTeacherWindow();
        });

    top.sButton.setOnAction(
        e -> {
          displayStudentWindow();
        });
  }
  private void updateChildren(boolean useButtons) {
    hboxLayout.getChildren().clear();
    hboxLayout.getChildren().addAll(createChildren(useButtons));

    vboxLayout.getChildren().clear();
    vboxLayout.getChildren().addAll(createChildren(useButtons));

    flowLayout.getChildren().clear();
    flowLayout.getChildren().addAll(createChildren(useButtons));

    List<Node> contents1 = createChildren(useButtons);
    gridLayout.getChildren().clear();
    gridLayout.add(contents1.get(0), 0, 0);
    gridLayout.add(contents1.get(1), 1, 0);
    gridLayout.add(contents1.get(2), 0, 1, 2, 1);

    List<Node> contents = createChildren(useButtons);
    borderLayout.getChildren().clear();
    borderLayout.setLeft(contents.get(0));
    borderLayout.setTop(contents.get(1));
    borderLayout.setRight(contents.get(2));
    borderLayout.setBottom(contents.get(3));
    borderLayout.setCenter(contents.get(4));

    stackLayout.getChildren().clear();
    stackLayout.getChildren().addAll(createChildren(useButtons));

    tileLayout.getChildren().clear();
    tileLayout.getChildren().addAll(createChildren(useButtons));
  }
  public RNADrawingView() {

    // set up gui
    drawingPane.setPrefWidth(400);
    drawingPane.setPrefHeight(400);
    warningLabel.setTextFill(Color.RED);
    animateCheckbox.setSelected(false);

    buttonBox.getChildren().addAll(foldButton, drawButton, animateCheckbox);
    inputBox.getChildren().addAll(sequenceField, bracketField, buttonBox);
    buttonInputBox.getChildren().addAll(inputBox, warningLabel, buttonBox);
    drawingPane.getChildren().add(drawing);
    root.setTop(buttonInputBox);
    root.setBottom(drawingPane);

    buttonBox.setAlignment(Pos.BOTTOM_LEFT);
    inputBox.setPadding(new Insets(10, 5, 10, 5));
    HBox.setMargin(foldButton, new Insets(0, 2.5, 0, 2.5));
    HBox.setMargin(drawButton, new Insets(0, 2.5, 0, 2.5));
    HBox.setMargin(animateCheckbox, new Insets(0, 2.5, 0, 2.5));
    VBox.setMargin(sequenceField, new Insets(0, 0, 5, 0));

    this.scene = new Scene(root);
    scene.getStylesheets().add("resources/assignment6and7.css");
    drawingPane.getStyleClass().add("drawingPane");
  }
  // REMOVE ME
  public static Node createIconContent() {
    StackPane sp = new StackPane();
    BorderPane borderPane = new BorderPane();

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    borderPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle recTop = new Rectangle(62, 5, Color.web("#349b00"));
    recTop.setStroke(Color.BLACK);
    Rectangle recBottom = new Rectangle(62, 14, Color.web("#349b00"));
    recBottom.setStroke(Color.BLACK);
    Rectangle recLeft = new Rectangle(20, 41, Color.TRANSPARENT);
    recLeft.setStroke(Color.BLACK);
    Rectangle recRight = new Rectangle(20, 41, Color.TRANSPARENT);
    recRight.setStroke(Color.BLACK);
    Rectangle centerRight = new Rectangle(20, 41, Color.TRANSPARENT);
    centerRight.setStroke(Color.BLACK);
    borderPane.setRight(recRight);
    borderPane.setTop(recTop);
    borderPane.setLeft(recLeft);
    borderPane.setBottom(recBottom);
    borderPane.setCenter(centerRight);

    sp.getChildren().addAll(rectangle, borderPane);
    return new Group(sp);
  }
  public void displayPane() throws IOException {

    addStationsToCB();

    paneTop.getColumnConstraints().add(new ColumnConstraints(60));
    paneTop.getColumnConstraints().add(new ColumnConstraints(200));
    paneTop.getColumnConstraints().add(new ColumnConstraints(100));

    paneBot.getColumnConstraints().add(new ColumnConstraints(60));
    paneBot.getColumnConstraints().add(new ColumnConstraints(200));
    paneBot.getColumnConstraints().add(new ColumnConstraints(100));

    paneCenter.getColumnConstraints().add(new ColumnConstraints(300));

    paneTop.setPadding(new Insets(10, 10, 10, 10));
    paneTop.setAlignment(Pos.CENTER);
    paneTop.setHgap(5);
    paneTop.setVgap(5);

    paneBot.setPadding(new Insets(10, 10, 10, 10));
    paneBot.setAlignment(Pos.CENTER);
    paneBot.setHgap(5);
    paneBot.setVgap(5);

    paneTop.add(new Label("Station :"), 0, 0);
    paneTop.add(cbStations, 1, 0);
    paneTop.add(btOpen, 2, 0);

    paneBot.add(new Label("Quantity :"), 0, 0);
    paneBot.add(cbQuantity, 1, 0);
    paneBot.add(btShow, 2, 0);

    paneTop.setHalignment(btOpen, HPos.RIGHT);
    paneBot.setHalignment(btShow, HPos.RIGHT);

    paneCenter.setHgap(5);
    paneCenter.setVgap(5);
    paneCenter.setAlignment(Pos.CENTER);
    sp.setContent(paneCenter);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
    bp.setMargin(sp, new Insets(20, 50, 40, 50));
    bp.setTop(paneTop);
    bp.setCenter(sp);
    bp.setBottom(paneBot);

    btOpen.setOnAction(
        e -> {
          try {
            open();
          } catch (IOException er) {
            er.printStackTrace();
          }
        });

    btShow.setOnAction(e -> showGraph());
  }
 public FxScrollPreview() {
   titleDisplay = new TextField("");
   titleDisplay.setEditable(false);
   titleDisplay.getStyleClass().add("scroll-title");
   content = new WebView();
   content.getStyleClass().add("scroll-preview-browser");
   pane = new BorderPane();
   pane.getStyleClass().add("scroll-preview-pane");
   pane.setTop(titleDisplay);
   pane.setCenter(content);
 }
Exemple #11
0
  public Scene createLoginScene() {
    BorderPane borderPane = new BorderPane();
    HBox title = createTitle();
    GridPane grid = createLoginForm(borderPane);
    HBox hbox = createSkipLoginBar();

    borderPane.setTop(title);
    borderPane.setCenter(grid);
    borderPane.setBottom(hbox);

    Scene scene = new Scene(borderPane, sceneWidth, sceneHeight);
    return scene;
  }
  @Override
  public void start(Stage primaryStage) throws Exception {
    BorderPane outerPane = new BorderPane();
    HBox topBox = new HBox(20);
    HBox bottomBox = new HBox(20);
    outerPane.setCenter(newText);

    fontChoice.setValue("Times New Roman");
    sizeChoice.setValue(12);

    topBox.setPadding(new Insets(20, 20, 20, 20));
    bottomBox.setPadding(new Insets(20, 20, 20, 20));

    List<String> items = Font.getFamilies();
    fontChoice.getItems().addAll(items);

    for (int i = 1; i <= 100; i++) sizeChoice.getItems().add(i);

    topBox.getChildren().addAll(fontName, fontChoice, fontSize, sizeChoice);
    bottomBox.getChildren().addAll(bold, italic);
    topBox.setAlignment(Pos.CENTER);
    bottomBox.setAlignment(Pos.CENTER);

    outerPane.setTop(topBox);
    outerPane.setCenter(newText);
    outerPane.setBottom(bottomBox);

    fontChoice.setOnAction(
        e -> {
          setFont();
        });

    sizeChoice.setOnAction(
        e -> {
          setFont();
        });

    bold.setOnAction(
        e -> {
          setFont();
        });
    italic.setOnAction(
        e -> {
          setFont();
        });

    Scene scene = new Scene(outerPane, X, Y);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Exemple #13
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    // Add mouse click event handler to the canvas to show the context menu
    canvas.setOnMouseClicked(this::showContextMenu);

    //
    BorderPane root = new BorderPane(canvas);
    root.setTop(new Label(Msg.get(this, "label.info")));
    root.setStyle(Msg.get(FlowPaneApp.class, "style"));

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle(Msg.get(this, "title"));
    primaryStage.show();
  }
Exemple #14
0
 @Override
 public void start(Stage stage) throws Exception {
   this.stage = stage;
   stage.initStyle(StageStyle.UNDECORATED);
   stage.setTitle("Choosing Hero");
   BorderPane pnlMain = new BorderPane();
   pnlMain.setTop(header);
   pnlMain.setCenter(heroPane);
   pnlMain.setLeft(alliedHeroPane);
   Scene scene = new Scene(pnlMain, 960, 600);
   stage.setResizable(false);
   stage.setScene(scene);
   scene
       .getStylesheets()
       .add(HeroChoosingGUI.class.getResource("/css/HeroChoosingLayout.css").toExternalForm());
   stage.show();
 }
  public BorderPaneSample() {
    super(400, 400);
    BorderPane borderPane = new BorderPane();

    // Top content
    Rectangle topRectangle = new Rectangle(400, 23, Color.DARKSEAGREEN);
    topRectangle.setStroke(Color.BLACK);
    borderPane.setTop(topRectangle);

    // Left content
    Label label1 = new Label("Left hand");
    Label label2 = new Label("Choice One");
    Label label3 = new Label("Choice Two");
    Label label4 = new Label("Choice Three");
    VBox leftVbox = new VBox();
    leftVbox.getChildren().addAll(label1, label2, label3, label4);
    borderPane.setLeft(leftVbox);

    // Right content
    Label rightlabel1 = new Label("Right hand");
    Label rightlabel2 = new Label("Thing A");
    Label rightlabel3 = new Label("Thing B");
    VBox rightVbox = new VBox();
    rightVbox.getChildren().addAll(rightlabel1, rightlabel2, rightlabel3);
    borderPane.setRight(rightVbox);

    // Center content
    Label centerLabel = new Label("We're in the center area.");
    ImageView imageView = new ImageView(ICON_48);

    // Using AnchorPane only to position items in the center
    AnchorPane centerAP = new AnchorPane();
    AnchorPane.setTopAnchor(centerLabel, Double.valueOf(5));
    AnchorPane.setLeftAnchor(centerLabel, Double.valueOf(20));
    AnchorPane.setTopAnchor(imageView, Double.valueOf(40));
    AnchorPane.setLeftAnchor(imageView, Double.valueOf(30));
    centerAP.getChildren().addAll(centerLabel, imageView);
    borderPane.setCenter(centerAP);

    // Bottom content
    Label bottomLabel = new Label("I am a status message, and I am at the bottom.");
    borderPane.setBottom(bottomLabel);

    getChildren().add(borderPane);
  }
  public void repaint3D() {
    mainPane = new BorderPane();
    VBox mainBox = new VBox();
    mainBox.setPadding(new Insets(200, 0, 0, 20));
    mainBox.getChildren().add(mainGrid);
    mainGrid.setOnKeyPressed(new KeyboardHandler());

    mainPane.setBottom(mainBox);
    mainPane.setTop(createActionPane());
    mainPane.setRight(createStatePane());

    Group group = new Group();
    for (int i = 22; i >= 0; i--) {
      for (int j = -1; j < 11; j++) {
        Image img;
        if (i == 22 || (j == -1 || j == 10))
          img = new Image(getClass().getResourceAsStream("GRAY.png"));
        else if (mainGrid.getColor(i, j) == Color.YELLOW)
          img = new Image(getClass().getResourceAsStream("YELLOW.png"));
        else if (mainGrid.getColor(i, j) == Color.MAGENTA)
          img = new Image(getClass().getResourceAsStream("RED.png"));
        else if (mainGrid.getColor(i, j) == Color.GREEN)
          img = new Image(getClass().getResourceAsStream("GREEN.png"));
        else if (mainGrid.getColor(i, j) == Color.ORANGE)
          img = new Image(getClass().getResourceAsStream("ORANGE.png"));
        else if (mainGrid.getColor(i, j) == Color.BLUE)
          img = new Image(getClass().getResourceAsStream("BLUE.png"));
        else if (mainGrid.getColor(i, j) == Color.CYAN)
          img = new Image(getClass().getResourceAsStream("CYAN.png"));
        else if (mainGrid.getColor(i, j) == Color.PINK)
          img = new Image(getClass().getResourceAsStream("VIOLET.png"));
        else img = new Image(getClass().getResourceAsStream("EMPTY.png"));
        ImageView iView = new ImageView(img);
        iView.setX(j * 17);
        iView.setY(i * 16);
        iView.setOpacity(1);
        iView.setPreserveRatio(true);
        group.getChildren().addAll(iView);
      }
    }
    mainPane.setCenter(group);
    // Stage old = stage3D;
    // stage3D = new Stage();
    stage3D.setScene(new Scene(mainPane, 380, 540));
  }
  public GameState(StateManager sm) {
    super(sm);
    shop = new Shop();
    game = new ShopSimulation(shop);
    gameClock = new GameClock();

    gameClock.setListener(
        new GameClock.GameClockListener() {
          @Override
          public void crappyHourBegins() {
            game.startCrappyHour();
            Platform.runLater(() -> shop.getLog().addLog("The chaos has begun.."));
          }

          @Override
          public void shopClosed() {

            Platform.runLater(() -> endGame());
          }
        });

    // Check if game closed
    sm.getStage().setOnCloseRequest(e -> stageClosed());

    statusLabel = new Label();
    shop.setListener(this);

    moneyFormat = NumberFormat.getCurrencyInstance();

    // Setup basic panes + contents
    BorderPane rootPane = new BorderPane();
    rootPane.setStyle("-fx-background-color: #474F53;");

    rootPane.setTop(new VBox(initMenu(), initStatusBar()));

    rootPane.setBottom(initGame());

    startGame();

    scene = new Scene(rootPane);
    setupStyle();
    setupSubWindow();
  }
  @Override
  public void start(Stage primaryStage) throws Exception {
    BorderPane layout = new BorderPane();

    // imageview
    currImage = new ImageView();
    layout.setMargin(currImage, new Insets(25, 180, 0, 180));
    currImage.setSmooth(true);
    layout.setTop(currImage);

    // add bottom layout
    BottomLayout bottomLayoutObject = new BottomLayout(primaryStage);
    HBox bottomLayout = bottomLayoutObject.getLayout();
    bottomLayout.setAlignment(Pos.BOTTOM_RIGHT);
    layout.setBottom(bottomLayout);

    currImage.setOnMouseClicked(
        e -> {
          clicked = !clicked;

          if (clicked) {
            BottomLayout.statusBar.setText("Paused");

            ImageSelector.timer.cancel();
            stoppedCount = ImageSelector.count;
          } else {
            BottomLayout.statusBar.setText("Running the images display");
            ImageSelector.startSelectImages(ImageSelector.currPath);
          }
        });

    // cancel the timer if the user exited the program
    primaryStage.setOnCloseRequest(
        e -> {
          if (ImageSelector.timer != null) ImageSelector.timer.cancel();
        });

    primaryStage.setTitle("Images Displayer");
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(layout, 900, 600));
    primaryStage.show();
  }
Exemple #19
0
  @Override
  public void start(Stage stage) {

    indexer = new Indexer();
    indexer.read("index.ser");

    window = stage;
    window.setTitle("Browser");

    // Layout
    BorderPane border = new BorderPane();
    HBox hBox = new HBox(10);
    hBox.setPadding(new Insets(20, 20, 20, 20));
    border.setTop(hBox);

    VBox vBox = new VBox(10);
    vBox.setPadding(new Insets(20, 20, 20, 20));
    border.setCenter(vBox);

    // Search Bar / Button
    searchTextField = new TextField();
    searchButton = new Button("Search");
    searchTextField.setPrefWidth(1000);
    searchButton.setOnAction(event -> search());
    label = new Label("Status: ");
    label.setPadding(new Insets(20, 20, 20, 20));
    border.setBottom(label);

    // WebView
    webView = new WebView();
    webEngine = webView.getEngine();
    webView.isVisible();

    vBox.getChildren().addAll(webView);
    hBox.getChildren().addAll(searchTextField, searchButton);
    scene = new Scene(border, 1200, 600);
    window.setScene(scene);
    stage.setResizable(false);
    window.show();

    System.out.println(searchTextField.getText());
  }
  @Override // Override the getPane() method in the super class
  protected BorderPane getPane() {
    BorderPane pane = super.getPane();

    BorderPane paneForTextField = new BorderPane();
    paneForTextField.setPadding(new Insets(5, 5, 5, 5));
    paneForTextField.setStyle("-fx-border-color: green");
    paneForTextField.setLeft(new Label("Enter a new message: "));

    TextField tf = new TextField();
    tf.setAlignment(Pos.BOTTOM_RIGHT);
    tf.setPrefWidth(100);
    tf.setPrefHeight(100);
    paneForTextField.setCenter(tf);
    pane.setTop(paneForTextField);

    tf.setOnAction(e -> text.setText(tf.getText()));

    return pane;
  }
Exemple #21
0
  public void askImageScreen() {

    Integer[] randomImageNumber = new Integer[49];
    for (int i = 0; i < randomImageNumber.length; i++) {
      randomImageNumber[i] = i;
    }
    Collections.shuffle(Arrays.asList((randomImageNumber)));

    String[] listOfImageAsk = new String[levelFactor];

    Group group = new Group();
    for (int i = 0; i < listOfImageAsk.length; i++) {
      Image image = allImages[randomImageNumber[i]];
      ImageView imageAsk = new ImageView(image);
      imageAsk.setId(randomImageNumber[i] + ".gif");
      listOfImageAsk[i] = (randomImageNumber[i] + ".gif");
      imageAsk.setX(i * 83);
      group.getChildren().add(imageAsk);
      System.out.println(listOfImageAsk[i]);
    }

    // scene3 elements

    Label instruction = new Label("RULES TO BE HERE");
    Button nextButton = new Button("NEXT");

    BorderPane layout3 = new BorderPane();

    layout3.setCenter(group);
    layout3.setTop(instruction);
    layout3.setBottom(nextButton);
    layout3.setAlignment(instruction, Pos.TOP_CENTER);
    layout3.setAlignment(nextButton, Pos.BASELINE_CENTER);
    nextButton.setOnAction(e -> checkResultScreen(listOfImageAsk));
    nextButton.setOnKeyPressed(e -> checkResultScreen(listOfImageAsk));

    scene3 = new Scene(layout3, 800, 600);
    window1.setScene(scene3);
  }
Exemple #22
0
  /**
   * Das GUI besteht aus zwei wesentlichen Komponenten, einer GridPane namens entryArea und einem
   * TextAreaHandler, beide sind in eine BorderPane eingebettet.
   */
  @Override
  protected Scene create_GUI() {

    // ServiceLocator und Translator werden gesetzt.
    ServiceLocator sl = ServiceLocator.getServiceLocator();
    Translator t = sl.getTranslator();

    // Die MenuBar enthält die Sprachauswahl
    MenuBar menuBar = new MenuBar();
    menuFile = new Menu(t.getString("program.menu.file"));
    menuFileLanguage = new Menu(t.getString("program.menu.file.language"));
    menuFile.getItems().add(menuFileLanguage);

    for (Locale locale : sl.getLocales()) {
      MenuItem language = new MenuItem(locale.getLanguage());
      menuFileLanguage.getItems().add(language);
      language.setOnAction(
          event -> {
            sl.setTranslator(new Translator(locale.getLanguage()));
            updateTexts();
          });
    }

    BorderPane root = new BorderPane();
    root.setPrefSize(409, 219);

    menuBar.getMenus().addAll(menuFile);
    root.setTop(menuBar);

    /**
     * ______________________________________________________________________________________________
     * START OF GRIDPANE !!! ENTRYAREA !!!
     */

    // Serverentry Area
    GridPane entryArea = new GridPane();
    entryArea.setAlignment(Pos.CENTER);
    root.setCenter(entryArea);

    Label lblIP = new Label();
    lblIP.setText("IP: ");
    ;
    lblIP.setAlignment(Pos.CENTER_LEFT);
    entryArea.add(lblIP, 0, 0);
    GridPane.setMargin(lblIP, new Insets(5, 5, 0, 50));

    Label lblPort = new Label();
    lblPort.setText("Port: ");
    lblPort.setAlignment(Pos.CENTER_LEFT);
    entryArea.add(lblPort, 0, 1);
    GridPane.setMargin(lblPort, new Insets(5, 5, 0, 50));

    lblHostName = new Label();
    lblHostName.setAlignment(Pos.CENTER_LEFT);
    lblHostName.setId("lblHostName");
    entryArea.add(lblHostName, 0, 2);
    GridPane.setMargin(lblHostName, new Insets(5, 5, 0, 50));

    tfIP = new TextField();
    tfIP.setId("tfIP");
    tfIP.setEditable(false);
    entryArea.add(tfIP, 1, 0);
    GridPane.setMargin(tfIP, new Insets(5, 5, 0, 0));

    tfPort = new TextField();
    tfPort.setId("tfPort");
    tfPort.setText("14000");
    tfPort.setPromptText("Bitte Portnummer eingeben.");
    entryArea.add(tfPort, 1, 1);
    GridPane.setMargin(tfPort, new Insets(5, 5, 0, 0));

    btnStart = new Button();
    btnStart.setId("btnStart");
    btnStart.setText(t.getString("button.start"));
    entryArea.add(btnStart, 2, 0);
    GridPane.setMargin(btnStart, new Insets(5, 5, 0, 50));

    btnClose = new Button();
    btnClose.setId("btnClose");
    btnClose.setText(t.getString("button.close"));
    entryArea.add(btnClose, 2, 1);
    GridPane.setMargin(btnClose, new Insets(5, 5, 0, 50));

    /**
     * ______________________________________________________________________________________________
     * START OF !!! TEXTAREAHANDLER !!!
     */
    textAreaHandler = new TextAreaHandler();
    taLogger = textAreaHandler.getTextArea();
    taLogger.setId("taLogger");
    taLogger.setEditable(false);
    root.setBottom(taLogger);

    Scene scene = new Scene(root);

    return scene;
  }
  public ItemPage(Login login) {

    this.login = login;

    data = new Database();
    dataTable = new DatabaseTable();

    Button goBack = new Button("Go Back");
    goBack.setMaxWidth(140);
    Button addItem = new Button("Add Item");
    addItem.setMaxWidth(140);

    Label username = new Label("Item ID");
    Label password = new Label("Item Name");
    Label name = new Label("Quantity");
    Label lastName = new Label("Price");
    Label address = new Label("Item Description");
    //	Label age = new Label("Picture");

    usernameText = new TextField();
    passwordText = new TextField();
    nameText = new TextField();
    lastNameText = new TextField();
    addressText = new TextField();
    //	ageText = new TextField();

    ImageView icon =
        new ImageView(
            new Image(getClass().getResourceAsStream("/res/beauty.png"), 300, 300, true, true));

    Button one = new Button("Ho");

    VBox hBox = new VBox();
    hBox.setMinWidth(400);
    hBox.setMinHeight(100);
    hBox.setSpacing(1);
    hBox.setAlignment(Pos.TOP_CENTER);
    hBox.setPadding(new Insets(30, 30, 30, 30));
    hBox.getChildren().add(icon);
    //	hBox.getChildren().add(goBack);

    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setPadding(new Insets(10, 25, 25, 25));
    grid.setVgap(10);
    grid.setHgap(10);
    grid.add(username, 1, 0);
    grid.add(usernameText, 2, 0);
    grid.add(password, 1, 1);
    grid.add(passwordText, 2, 1);
    grid.add(name, 1, 2);
    grid.add(nameText, 2, 2);
    grid.add(lastName, 1, 3);
    grid.add(lastNameText, 2, 3);
    grid.add(address, 1, 4);
    grid.add(addressText, 2, 4);
    //	grid.add(age, 1, 5);
    //	grid.add(ageText, 2, 5);
    grid.add(goBack, 1, 7);
    grid.add(addItem, 1, 6);

    goBack.setOnAction(
        (e) -> {
          login.InventoryPage.buildData();
          login.theStage.setScene(login.scene3);
          login.userID.clear();
          login.userPasswordField.clear();
          //		login.InventoryPage.buildData();

        });

    addItem.setOnAction(
        (e) -> {
          data.createItem(
              usernameText.getText(),
              passwordText.getText(),
              nameText.getText(),
              lastNameText.getText(),
              addressText.getText());
          clearText();
        });

    setBackground(new Background(new BackgroundFill(Color.PINK, CornerRadii.EMPTY, Insets.EMPTY)));
    super.setCenter(grid);
    super.setTop(hBox);
  }
 public ArchivProjekte() {
   elter = new BorderPane();
   elter.setTop(initGUItop());
   elter.setCenter(initGUIcenter());
 }
  public BoardView(int noPlayers, final Stage primaryStage) {

    window = primaryStage;
    window.setTitle("Quoridor");
    window.setMaxHeight(1280);
    window.setMaxWidth(1280);
    window.setResizable(false);

    BorderPane border = new BorderPane();

    infoPane = new FlowPane();
    infoPane.setPadding(new Insets(10));
    infoPane.setHgap(40);
    infoPane.setVgap(10);
    infoPane.setOrientation(Orientation.HORIZONTAL);

    bottomPane = new HBox();
    bottomPane.setSpacing(345);

    gameGrid = new GridPane();
    gameGrid.setPadding(new Insets(4));
    gameGrid.setId("gamegrid");

    border.setTop(infoPane);
    border.setCenter(gameGrid);

    playerPositionButtons = new PlayerPositionButton[9][9];
    wallPositionButtons = new WallPositionButton[9][8];
    horizontalWalls = new Pane[9][9];
    verticalWalls = new Pane[9][9];

    column = 0;
    row = 0;

    chooseVertical = new Button();
    chooseVertical.setPrefSize(100, 100);
    chooseVertical.setId("vWallBtn");

    Button home = new Button();
    home.setPrefSize(100, 100);
    home.setId("home");
    home.setOnAction(e -> confirmBox());

    bottomPane.getChildren().addAll(chooseVertical, home);

    border.setBottom(bottomPane);
    border.setMargin(bottomPane, new Insets(40, 40, 20, 20));

    for (int y = 0; y < 8; y++) {
      createMoveLine(y);
      createWallLine(y);
    }

    createMoveLine(8);

    main = new Scene(border, 600, 768);
    main.getStylesheets().add("gameplay/viewJFX/" + stylesheet);
    buildPlayerLabels(noPlayers);
    window.setScene(main);
    window.show();
  }
Exemple #26
0
  @Override
  public void start(Stage theStage) {
    this.tStage = theStage;
    theStage.setTitle("Ball of Duty");
    theStage.setHeight(WINDOW_START_HEIGHT);
    theStage.setWidth(WINDOW_START_WIDTH);
    theStage.centerOnScreen();
    theStage.setResizable(false);
    theStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          public void handle(WindowEvent we) {
            gameManager.quitGame();
            System.exit(0);
          }
        });

    BorderPane startMenuRoot = new BorderPane();
    startMenu = new Scene(startMenuRoot);

    gameBox = new BorderPane();
    Scene gameScene = new Scene(gameBox);

    BorderPane createAccountRoot = new BorderPane();
    BorderPane lohInRoot = new BorderPane();

    theStage.setScene(startMenu);

    gameManager = new GameClient(getRelativeSceneLocation(theStage));

    scale = new Scale();
    scale.xProperty().bind(gameScene.widthProperty().divide(WINDOW_START_WIDTH));
    scale.yProperty().bind(gameScene.heightProperty().divide(WINDOW_START_HEIGHT));
    scale.setPivotX(0);
    scale.setPivotY(0);
    // gameBox.getTransforms().add(scale);
    // gameBox.setBackground(null);
    // TODO scaling

    theStage
        .heightProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); // This
              // only
              // happens
              // once
              // for
              // some
              // reason.
            });
    theStage
        .widthProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    theStage
        .xProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    theStage
        .yProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    gameScene
        .xProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    gameScene
        .yProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    Image image = new Image("images/frontpage.png");
    BackgroundSize backgroundSize = new BackgroundSize(100, 100, true, true, true, false);
    // new BackgroundImage(image, repeatX, repeatY, position, size)
    BackgroundImage backgroundImage =
        new BackgroundImage(
            image,
            BackgroundRepeat.REPEAT,
            BackgroundRepeat.NO_REPEAT,
            BackgroundPosition.CENTER,
            backgroundSize);
    // new Background(images...)
    Background background = new Background(backgroundImage);
    startMenuRoot.setBackground(background);

    RadioButton chooseBlaster = new RadioButton("Blaster");
    RadioButton chooseRoller = new RadioButton("Roller");
    RadioButton chooseHeavy = new RadioButton("Heavy");

    final ToggleGroup specializationGroup = new ToggleGroup();

    chooseBlaster.setToggleGroup(specializationGroup);
    chooseRoller.setToggleGroup(specializationGroup);
    chooseHeavy.setToggleGroup(specializationGroup);

    chooseBlaster.setSelected(true);

    HBox specializationBox = new HBox();
    specializationBox.setSpacing(9);
    specializationBox.getChildren().add(chooseBlaster);
    specializationBox.getChildren().add(chooseRoller);
    specializationBox.getChildren().add(chooseHeavy);

    Label lblNickname = new Label("Nickname:");
    TextField tfNickname = new TextField();
    Button loginStart = new Button("Log in");
    Button createStart = new Button("Create Account");
    theStage.getIcons().add(new Image("images/ball_red.png"));
    VBox mainButtonBox = new VBox();
    mainButtonBox.setSpacing(5);
    Button joinBtn = new Button("Join game");

    Button viewLB = new Button("Leaderboard");
    viewLB.setPrefSize(150, 50);
    viewLB.setId("viewLB");
    viewLB.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    BorderPane lbBorder = new BorderPane();
    VBox lbBox = new VBox();
    Scene lbScene = new Scene(lbBorder);

    Button lbBack = new Button("Start menu");
    lbBox.getChildren().add(lbBack);
    lbBorder.setLeft(lbBox);
    lbBack.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    Label topText = new Label("Only shows scores higher than 100!");
    topText.setStyle("-fx-font-size: 20pt;-fx-font-family: Segoe UI Semibold;");

    viewLB.setOnAction(
        ActionEvent -> {
          HighscoreLeaderboard hBoard = gameManager.getHighscoreLeaderboard();
          hBoard.setFocusTraversable(false);
          lbBorder.setCenter(hBoard);
          if (gameManager.getPlayer() != null) {
            Player client = gameManager.getPlayer();
            Label you =
                new Label(
                    "YOU:    "
                        + client.getNickname()
                        + " ["
                        + client.getId()
                        + "]    | Score: "
                        + client.getHighscore());

            you.setStyle("-fx-font-size: 15pt;-fx-font-family: Segoe UI Semibold;");
            lbBorder.setBottom(you);
          }

          BorderPane.setMargin(hBoard, new Insets(12, 12, 12, 12));

          lbBorder.setTop(topText);
          theStage.setScene(lbScene);

          lbBack.setOnAction(
              ActionEvent1 -> {
                theStage.setScene(startMenu);
                startMenuRoot.setLeft(mainButtonBox);

                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    joinBtn.setPrefSize(150, 50);
    tfNickname.setPrefSize(150, 20);
    joinBtn.setId("joinBtn");
    joinBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    lblNickname.setId("lblNickname");
    lblNickname.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    createStart.setId("CreateStart");
    createStart.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    loginStart.setId("loginStart");
    loginStart.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    joinBtn.setOnAction(
        ActionEvent -> {
          Specializations spec;
          if (chooseRoller.isSelected()) {
            spec = Specializations.ROLLER;
          } else if (chooseHeavy.isSelected()) {
            spec = Specializations.HEAVY;
          } else // Blaster is default, if something goes wrong with radio
          // buttons
          {
            spec = Specializations.BLASTER;
          }

          theStage.setScene(gameScene);
          gameManager.joinAsGuest(gameBox, tfNickname.getText(), spec);
          gameManager.getMap().addObserver(this);
          gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
          gameBox.requestFocus();
        });
    tfNickname.setOnAction(
        ActionEvent -> {
          Specializations spec;
          if (chooseRoller.isSelected()) {
            spec = Specializations.ROLLER;
          } else if (chooseHeavy.isSelected()) {
            spec = Specializations.HEAVY;
          } else // Blaster is default, if something goes wrong with radio
          // buttons
          {
            spec = Specializations.BLASTER;
          }
          theStage.setScene(gameScene);
          gameManager.joinAsGuest(gameBox, tfNickname.getText(), spec);
          gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
          gameBox.requestFocus();
        });

    mainButtonBox.getChildren().add(lblNickname);
    mainButtonBox.getChildren().add(tfNickname);
    mainButtonBox.getChildren().add(specializationBox);
    mainButtonBox.getChildren().add(joinBtn);
    mainButtonBox.getChildren().add(loginStart);
    mainButtonBox.getChildren().add(createStart);
    mainButtonBox.getChildren().add(viewLB);
    startMenuRoot.setLeft(mainButtonBox);

    createStart.setOnAction(
        ActionEvent -> {
          VBox createAccountButtonBox = new VBox();
          Label lblNickname2 = new Label("Nickname:");
          TextField tfNickname2 = new TextField();
          Label lblUserName = new Label("Name:");
          TextField tfUserName = new TextField();
          Label lblPassword = new Label("Password:"******"Repeat password:"******"Create account");
          Button back = new Button("Start menu");

          createBtn.setId("join-yyyyy");
          createBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblUserName.setId("join-game");
          lblUserName.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblPassword.setId("join-game");
          lblPassword.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblPassword2.setId("join-game");
          lblPassword2.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          back.setId("join-game");
          back.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

          createAccountButtonBox.getChildren().add(lblNickname2);
          createAccountButtonBox.getChildren().add(tfNickname2);
          createAccountButtonBox.getChildren().add(lblUserName);
          createAccountButtonBox.getChildren().add(tfUserName);
          createAccountButtonBox.getChildren().add(lblPassword);
          createAccountButtonBox.getChildren().add(pf);
          createAccountButtonBox.getChildren().add(lblPassword2);
          createAccountButtonBox.getChildren().add(pf2);
          createAccountButtonBox.getChildren().add(createBtn);
          createAccountButtonBox.getChildren().add(back);

          startMenuRoot.setLeft(createAccountButtonBox);
          BorderPane.setMargin(createAccountButtonBox, new Insets(350, 0, 0, 150));

          createBtn.setOnAction(
              ActionEvent1 -> {
                gameManager.createAccount(
                    tfUserName.getText(),
                    tfNickname2.getText(),
                    pf.getText().toCharArray(),
                    pf2.getText().toCharArray());
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });

          back.setOnAction(
              ActionEvent1 -> {
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    loginStart.setOnAction(
        ActionEvent -> {
          VBox loginButtonBox = new VBox();
          Button logInBtn = new Button("Log in");
          Label lblUserName2 = new Label("Name:");
          TextField tfUserName2 = new TextField();
          Label lblPassword2 = new Label("Password:"******"Start Menu");

          logInBtn.setId("join-game");
          logInBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          back2.setId("join-game");
          back2.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

          loginButtonBox.getChildren().add(lblUserName2);
          loginButtonBox.getChildren().add(tfUserName2);
          loginButtonBox.getChildren().add(lblPassword2);
          loginButtonBox.getChildren().add(pf3);
          loginButtonBox.getChildren().add(logInBtn);
          loginButtonBox.getChildren().add(back2);

          startMenuRoot.setLeft(loginButtonBox);
          BorderPane.setMargin(loginButtonBox, new Insets(350, 0, 0, 150));

          logInBtn.setOnAction(
              ActionEvent1 -> {
                // TODO login
              });

          back2.setOnAction(
              ActionEvent1 -> {
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));

    Button quitBtn = new Button("Quit game");
    quitBtn.setPrefSize(80, 40);
    quitBtn.setId("quit-game");

    quitBtn.setOnAction(
        ActionEvent -> {
          gameManager.quitGame();
          theStage.setScene(startMenu);
        });

    canvas = new Canvas(CANVAS_START_WIDTH, CANVAS_START_HEIGHT);
    gameBox.setCenter(canvas);
    BorderPane.setAlignment(canvas, Pos.TOP_LEFT);

    gameBox.setBottom(quitBtn);
    BorderPane.setAlignment(quitBtn, Pos.TOP_LEFT);
    theStage.show();
  }
Exemple #27
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("JavaFX Demo");

    /* create the menu (for the top of the user interface) */
    Menu fileMenu = new Menu("File");
    MenuItem newMenuItem = new MenuItem("New", imageFile("images/new.png"));
    newMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+N"));
    fileMenu.getItems().add(newMenuItem);
    fileMenu.getItems().add(new SeparatorMenuItem());
    fileMenu.getItems().add(new MenuItem("Open...", imageFile("images/open.png")));
    fileMenu.getItems().add(new SeparatorMenuItem());
    fileMenu.getItems().add(new MenuItem("Save", imageFile("images/save.png")));
    fileMenu.getItems().add(new MenuItem("Save As...", imageFile("images/save_as.png")));
    fileMenu.getItems().add(new SeparatorMenuItem());
    MenuItem exitMenuItem = new MenuItem("Exit", imageFile("images/exit.png"));
    fileMenu.getItems().add(exitMenuItem);
    exitMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+Q"));
    exitMenuItem.setOnAction(e -> System.exit(0));

    Menu editMenu = new Menu("Edit");
    editMenu.getItems().add(new MenuItem("Cut", imageFile("images/cut.png")));
    editMenu.getItems().add(new MenuItem("Copy", imageFile("images/copy.png")));
    editMenu.getItems().add(new MenuItem("Paste", imageFile("images/paste.png")));

    Menu helpMenu = new Menu("Help");
    helpMenu.getItems().add(new MenuItem("About...", imageFile("images/about.png")));
    helpMenu.getItems().add(new SeparatorMenuItem());
    helpMenu.getItems().add(new MenuItem("Help...", imageFile("images/help.png")));

    MenuBar menuBar = new MenuBar();
    menuBar.getMenus().add(fileMenu);
    menuBar.getMenus().add(editMenu);
    menuBar.getMenus().add(helpMenu);

    /* create the table (for the center of the user interface) */
    table = new TableView<>();
    table.setItems(DataSource.getAllStudents());
    table.setEditable(true);

    /* create the table's columns */
    TableColumn<Student, Integer> sidColumn = null;
    sidColumn = new TableColumn<>("SID");
    sidColumn.setMinWidth(100);
    sidColumn.setCellValueFactory(new PropertyValueFactory<>("sid"));

    TableColumn<Student, String> firstNameColumn = null;
    firstNameColumn = new TableColumn<>("First Name");
    firstNameColumn.setMinWidth(200);
    firstNameColumn.setCellValueFactory(new PropertyValueFactory<>("firstName"));
    firstNameColumn.setCellFactory(TextFieldTableCell.<Student>forTableColumn());
    firstNameColumn.setOnEditCommit(
        (CellEditEvent<Student, String> event) -> {
          ((Student) event.getTableView().getItems().get(event.getTablePosition().getRow()))
              .setFirstName(event.getNewValue());
        });

    TableColumn<Student, String> lastNameColumn = null;
    lastNameColumn = new TableColumn<>("Last Name");
    lastNameColumn.setMinWidth(200);
    lastNameColumn.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    lastNameColumn.setCellFactory(TextFieldTableCell.<Student>forTableColumn());
    lastNameColumn.setOnEditCommit(
        (CellEditEvent<Student, String> event) -> {
          ((Student) event.getTableView().getItems().get(event.getTablePosition().getRow()))
              .setLastName(event.getNewValue());
        });

    TableColumn<Student, Double> gpaColumn = null;
    gpaColumn = new TableColumn<>("GPA");
    gpaColumn.setMinWidth(100);
    gpaColumn.setCellValueFactory(new PropertyValueFactory<>("gpa"));

    table.getColumns().add(sidColumn);
    table.getColumns().add(lastNameColumn);
    table.getColumns().add(firstNameColumn);
    table.getColumns().add(gpaColumn);

    /* create an edit form (for the bottom of the user interface) */
    GridPane editArea = new GridPane();
    editArea.setPadding(new Insets(10, 10, 10, 10));
    editArea.setVgap(10);
    editArea.setHgap(10);

    Label sidLabel = new Label("SID:");
    editArea.add(sidLabel, 0, 0);
    TextField sidField = new TextField();
    sidField.setPromptText("SID");
    editArea.add(sidField, 1, 0);

    Label fnameLabel = new Label("First name:");
    editArea.add(fnameLabel, 0, 1);
    TextField fnameField = new TextField();
    fnameField.setPromptText("First Name");
    editArea.add(fnameField, 1, 1);

    Label lnameLabel = new Label("Last name:");
    editArea.add(lnameLabel, 0, 2);
    TextField lnameField = new TextField();
    lnameField.setPromptText("Last Name");
    editArea.add(lnameField, 1, 2);

    Label gpaLabel = new Label("GPA:");
    editArea.add(gpaLabel, 0, 3);
    TextField gpaField = new TextField();
    gpaField.setPromptText("GPA");
    editArea.add(gpaField, 1, 3);

    Button addButton = new Button("Add");
    addButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            int sid = Integer.parseInt(sidField.getText());
            String firstName = fnameField.getText();
            String lastName = lnameField.getText();
            double gpa = Double.parseDouble(gpaField.getText());

            table.getItems().add(new Student(sid, firstName, lastName, gpa));

            sidField.setText("");
            fnameField.setText("");
            lnameField.setText("");
            gpaField.setText("");
          }
        });
    editArea.add(addButton, 1, 4);

    /* arrange all components in the main user interface */
    layout = new BorderPane();
    layout.setTop(menuBar);
    layout.setCenter(table);
    layout.setBottom(editArea);

    Scene scene = new Scene(layout, 600, 600);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Exemple #28
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    /* create the menu (for the top of the user interface) */
    Menu fileMenu = new Menu("File");
    MenuItem newMenuItem = new MenuItem("New", imageFile("images/new.png"));
    newMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+N"));
    fileMenu.getItems().add(newMenuItem);
    fileMenu.getItems().add(new SeparatorMenuItem());
    fileMenu.getItems().add(new MenuItem("Open...", imageFile("images/open.png")));
    fileMenu.getItems().add(new SeparatorMenuItem());
    MenuItem saveMenuItem = new MenuItem("Save", imageFile("images/save.png"));
    fileMenu.getItems().add(saveMenuItem);
    MenuItem saveAsMenuItem = new MenuItem("Save As...", imageFile("images/save_as.png"));
    fileMenu.getItems().add(saveAsMenuItem);
    fileMenu.getItems().add(new SeparatorMenuItem());
    MenuItem exitMenuItem = new MenuItem("Exit", imageFile("images/exit.png"));
    fileMenu.getItems().add(exitMenuItem);
    exitMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+Q"));
    exitMenuItem.setOnAction(e -> System.exit(0));

    Menu editMenu = new Menu("Edit");
    editMenu.getItems().add(new MenuItem("Cut", imageFile("images/cut.png")));
    editMenu.getItems().add(new MenuItem("Copy", imageFile("images/copy.png")));
    editMenu.getItems().add(new MenuItem("Paste", imageFile("images/paste.png")));

    Menu helpMenu = new Menu("Help");
    helpMenu.getItems().add(new MenuItem("About...", imageFile("images/about.png")));
    helpMenu.getItems().add(new SeparatorMenuItem());
    helpMenu.getItems().add(new MenuItem("Help...", imageFile("images/help.png")));

    MenuBar menuBar = new MenuBar();
    menuBar.getMenus().add(fileMenu);
    menuBar.getMenus().add(editMenu);
    menuBar.getMenus().add(helpMenu);
    primaryStage.setTitle("Lab08");
    // grid contains all of the textfeilds, labels , buttons, ect..
    GridPane grid = new GridPane();
    // the tableview puts all of our data into a exel like format
    TableView<StudentRecord> table = new TableView<>();
    table.setItems(DataSource.getAllMarks());
    table.setEditable(true);

    TableColumn<StudentRecord, String> IDColumn = null;
    IDColumn = new TableColumn<>("SID");
    IDColumn.setMinWidth(100);
    // the thing in quotes is what it will search for in the StudentRecords.java (MAKE SURE THERE IS
    // A GET FUNCTION FOR THAT VARIBALE)
    IDColumn.setCellValueFactory(new PropertyValueFactory<>("ID"));

    TableColumn<StudentRecord, Double> AssignmentColumn = null;
    AssignmentColumn = new TableColumn<>("Assignment");
    AssignmentColumn.setMinWidth(100);
    AssignmentColumn.setCellValueFactory(new PropertyValueFactory<>("Assign"));

    TableColumn<StudentRecord, Float> MidtermColumn = null;
    MidtermColumn = new TableColumn<>("Midterm");
    MidtermColumn.setMinWidth(100);
    MidtermColumn.setCellValueFactory(new PropertyValueFactory<>("Midterm"));

    TableColumn<StudentRecord, Float> FinalColumn = null;
    FinalColumn = new TableColumn<>("Final Exam");
    FinalColumn.setMinWidth(100);
    FinalColumn.setCellValueFactory(new PropertyValueFactory<>("Final"));

    TableColumn<StudentRecord, String> GradeColumn = null;
    GradeColumn = new TableColumn<>("Letter Grade");
    GradeColumn.setMinWidth(100);
    GradeColumn.setCellValueFactory(new PropertyValueFactory<>("Grade"));

    table.getColumns().add(IDColumn);
    table.getColumns().add(AssignmentColumn);
    table.getColumns().add(MidtermColumn);
    table.getColumns().add(FinalColumn);
    table.getColumns().add(GradeColumn);

    Label IDLabel = new Label("SID:");
    grid.add(IDLabel, 0, 0);
    TextField IDField = new TextField();
    IDField.setPromptText("SID");
    grid.add(IDField, 1, 0);

    Label AssignLabel = new Label("Assignments:");
    grid.add(AssignLabel, 2, 0);

    TextField AssignField = new TextField();
    AssignField.setPromptText("Assignment");
    grid.add(AssignField, 3, 0);

    Label MidLabel = new Label("Midterm:");
    grid.add(MidLabel, 0, 1);

    TextField midField = new TextField();
    midField.setPromptText("Midterm");
    grid.add(midField, 1, 1);

    Label FinalLabel = new Label("Final:");
    grid.add(FinalLabel, 2, 1);

    TextField FinalField = new TextField();
    FinalField.setPromptText("Final");
    grid.add(FinalField, 3, 1);

    Button AddButton = new Button("Add");
    AddButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            char Grade;
            String SID = IDField.getText();
            Float Assignment = Float.parseFloat(AssignField.getText());
            Float Midterm = Float.parseFloat(midField.getText());
            Float Final = Float.parseFloat(FinalField.getText());
            table.getItems().add(new StudentRecord(SID, Assignment, Midterm, Final));

            IDField.setText("");
            AssignField.setText("");
            midField.setText("");
            FinalField.setText("");
          }
        });
    grid.add(AddButton, 0, 2);

    layout = new BorderPane();
    layout.setTop(menuBar);
    layout.setCenter(table);
    layout.setBottom(grid);

    Scene scene = new Scene(layout);
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(10);
    grid.setHgap(10);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
  @Override
  public void start(Stage stage) throws Exception {

    this.mainBorderPane = new BorderPane();

    FlowPane toolbar = new FlowPane();

    Button btnClear = new Button("Clear");

    btnClear.setOnAction(
        event -> {
          root.getChildren().clear();
        });
    Button btnLoadFtof = new Button("FTOF");

    btnLoadFtof.setOnAction(
        event -> {
          loadDetector("FTOF");
        });

    toolbar.getChildren().add(btnClear);
    toolbar.getChildren().add(btnLoadFtof);

    SplitPane splitPane = new SplitPane();
    StackPane treePane = new StackPane();

    root = new Group();
    BorderPane pane = new BorderPane();

    treeView = new TreeView<String>();

    treePane.getChildren().add(treeView);

    this.content = new ContentModel(800, 800, 200);
    this.content.setContent(root);

    content.getSubScene().heightProperty().bind(pane.heightProperty());
    content.getSubScene().widthProperty().bind(pane.widthProperty());

    pane.setCenter(content.getSubScene());
    mainBorderPane.setTop(toolbar);
    splitPane.getItems().addAll(treePane, pane);
    splitPane.setDividerPositions(0.2);

    // this.addDetector("FTOF");
    // this.test();
    this.testFTOF();
    // this.testDC();
    // this.testBST();
    // final Scene scene = new Scene(pane, 880, 880, true);
    this.mainBorderPane.setCenter(splitPane);
    HBox statusPane = new HBox();

    ColorPicker colorPicker = new ColorPicker();
    colorPicker.setOnAction(
        new EventHandler() {
          @Override
          public void handle(Event event) {
            content.setBackgroundColor(colorPicker.getValue());
          }
        });
    statusPane.getChildren().add(colorPicker);
    this.mainBorderPane.setBottom(statusPane);

    final Scene scene = new Scene(mainBorderPane, 1280, 880, true);

    scene.setFill(Color.ALICEBLUE);
    stage.setTitle("CLAS12 Geometry Viewer - JavaFX3D");
    stage.setScene(scene);
    stage.show();
  }
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("Chapter 15-16 Adding Tabs to a UI");
    Group root = new Group();
    Scene scene = new Scene(root, 400, 250, Color.WHITE);

    TabPane tabPane = new TabPane();

    MenuBar menuBar = new MenuBar();

    EventHandler<ActionEvent> action = changeTabPlacement(tabPane);

    Menu menu = new Menu("Tab Side");
    MenuItem left = new MenuItem("Left");

    left.setOnAction(action);
    menu.getItems().add(left);

    MenuItem right = new MenuItem("Right");
    right.setOnAction(action);
    menu.getItems().add(right);

    MenuItem top = new MenuItem("Top");
    top.setOnAction(action);
    menu.getItems().add(top);

    MenuItem bottom = new MenuItem("Bottom");
    bottom.setOnAction(action);
    menu.getItems().add(bottom);

    menuBar.getMenus().add(menu);

    BorderPane borderPane = new BorderPane();

    // generate 10 tabs
    for (int i = 0; i < 10; i++) {
      Tab tab = new Tab();
      tab.setText("Tab" + i);
      HBox hbox = new HBox();
      hbox.getChildren().add(new Label("Tab" + i));
      hbox.setAlignment(Pos.CENTER);
      tab.setContent(hbox);
      tabPane.getTabs().add(tab);
    }

    // add tab pane
    borderPane.setCenter(tabPane);

    // bind to take available space
    borderPane.prefHeightProperty().bind(scene.heightProperty());
    borderPane.prefWidthProperty().bind(scene.widthProperty());

    // added menu bar
    borderPane.setTop(menuBar);

    // add border Pane
    root.getChildren().add(borderPane);

    primaryStage.setScene(scene);
    primaryStage.show();
  }