示例#1
0
文件: Main.java 项目: garzoc/group17
  @Override
  public void start(Stage primaryStage) {
    try {
      TabPane page = (TabPane) FXMLLoader.load(Main.class.getResource("simple.fxml"));
      Scene scene = new Scene(page);
      primaryStage.setScene(scene);
      primaryStage.setTitle("Hotels");
      primaryStage.show();

      textf = (TextField) scene.lookup("#HotelNameTextb");
      Button create = (Button) scene.lookup("#CreateButton");
      create.setOnAction(this::handleButtonAction);

    } catch (Exception ex) {
      Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
示例#2
0
  /**
   * ************************************************************************* * Lookup related
   * tests * * ************************************************************************
   */
  @Test
  public void testLookupCorrectId() {
    Node n;
    Group root = new Group();
    Scene scene = new Scene(root);
    Rectangle a = new Rectangle();
    a.setId("a");
    Rectangle b = new Rectangle();
    a.setId("b");
    Rectangle c = new Rectangle();
    a.setId("c");
    Group g = new Group();
    g.setId("d");

    Rectangle r1 = new Rectangle();
    a.setId("1");
    Rectangle r2 = new Rectangle();
    a.setId("2");
    Rectangle r3 = new Rectangle();
    a.setId("3");
    n = new Rectangle();
    n.setId("4");
    Rectangle r5 = new Rectangle();
    a.setId("5");
    Rectangle r6 = new Rectangle();
    a.setId("6");

    Rectangle e = new Rectangle();
    a.setId("e");
    Rectangle f = new Rectangle();
    a.setId("f");

    g.getChildren().addAll(r1, r2, r3, n, r5, r6);

    root.getChildren().addAll(a, b, c, g, e, f);

    assertEquals(n, scene.lookup("#4"));
  }