Example usage for javafx.scene Group Group

List of usage examples for javafx.scene Group Group

Introduction

In this page you can find the example usage for javafx.scene Group Group.

Prototype

public Group() 

Source Link

Document

Constructs a group.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(450);//from  w w  w. j  av  a 2 s.com
    stage.setHeight(550);

    TableColumn firstNameCol = new TableColumn("First Name");
    firstNameCol.setMinWidth(100);
    firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));

    TableColumn lastNameCol = new TableColumn("Last Name");
    lastNameCol.setMinWidth(100);
    lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol);

    firstNameCol.setSortType(TableColumn.SortType.DESCENDING);
    lastNameCol.setSortable(false);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(450);/*ww  w  . j  a va2 s  .  co m*/
    stage.setHeight(550);

    TableColumn firstNameCol = new TableColumn("First Name");
    firstNameCol.setMinWidth(100);
    firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));

    TableColumn lastNameCol = new TableColumn("Last Name");
    lastNameCol.setMinWidth(100);
    lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol);

    final Button addButton = new Button("Add");
    addButton.setOnAction((ActionEvent e) -> {
        data.add(new Person("Z", "X"));
    });

    hb.getChildren().addAll(addButton);
    hb.setSpacing(3);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table, hb);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(450);/*from w  ww  .  j  a  v a2s .  c om*/
    stage.setHeight(550);

    table.setEditable(true);

    TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name");
    firstNameCol.setMinWidth(100);
    firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));

    firstNameCol.setCellFactory(TextFieldTableCell.<Person>forTableColumn());
    firstNameCol.setOnEditCommit((CellEditEvent<Person, String> t) -> {
        ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setFirstName(t.getNewValue());
    });

    TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name");
    lastNameCol.setMinWidth(100);
    lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    lastNameCol.setCellFactory(TextFieldTableCell.<Person>forTableColumn());
    lastNameCol.setOnEditCommit((CellEditEvent<Person, String> t) -> {
        ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setLastName(t.getNewValue());
    });
    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(400);//from   w w  w. j  a va 2s  . c  o  m
    stage.setHeight(550);

    table.setEditable(true);

    TableColumn firstNameCol = new TableColumn("First Name");
    firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));

    TableColumn lastNameCol = new TableColumn("Last Name");
    lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));

    TableColumn emailCol = new TableColumn("Email");
    emailCol.setMinWidth(200);
    emailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email"));

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

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

From source file:Main.java

public MyDialog(Stage owner) {
    super();//from  w  w  w . j  a  va2 s.co  m
    initOwner(owner);
    setTitle("title");
    Group root = new Group();
    Scene scene = new Scene(root, 250, 150, Color.WHITE);
    setScene(scene);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(5);
    gridpane.setVgap(5);

    Label userNameLbl = new Label("User Name: ");
    gridpane.add(userNameLbl, 0, 1);

    Label passwordLbl = new Label("Password: ");
    gridpane.add(passwordLbl, 0, 2);
    final TextField userNameFld = new TextField("Admin");
    gridpane.add(userNameFld, 1, 1);

    final PasswordField passwordFld = new PasswordField();
    passwordFld.setText("password");
    gridpane.add(passwordFld, 1, 2);

    Button login = new Button("Change");
    login.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent event) {
            close();
        }
    });
    gridpane.add(login, 1, 3);
    GridPane.setHalignment(login, HPos.RIGHT);
    root.getChildren().add(gridpane);
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(400);// w ww.  jav a2  s .  c o  m
    stage.setHeight(550);

    table.setEditable(true);

    TableColumn firstNameCol = new TableColumn("First Name");
    firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));

    TableColumn lastNameCol = new TableColumn("Last Name");
    lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));

    TableColumn emailCol = new TableColumn("Email");
    emailCol.setMinWidth(200);
    emailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email"));

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);

    final Button addButton = new Button("Add");
    addButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            data.add(new Person("new", "new", "new"));
        }
    });

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table, addButton);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    WebEngine webEngine = new WebEngine();
    webEngine.getLoadWorker().stateProperty().addListener((obs, oldValue, newValue) -> {
        System.out.println(newValue);
        if (newValue == State.SUCCEEDED) {
            System.out.println("finished loading");
            try {
                TransformerFactory transformerFactory = TransformerFactory.newInstance();
                Transformer transformer = transformerFactory.newTransformer();
                StringWriter stringWriter = new StringWriter();
                transformer.transform(new DOMSource(webEngine.getDocument()), new StreamResult(stringWriter));
                String xml = stringWriter.getBuffer().toString();
                System.out.println(xml);
            } catch (Exception e) {
                e.printStackTrace();/*from  w  w  w . ja v a  2s  . com*/
            }

        }
    }); // addListener()

    // begin loading...
    webEngine.load("http://www.java2s.com");

    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 260);

    // circles//  w ww  .  j a va  2  s .  c  o  m
    Circle redCircle = createCircle(100, 50, 30, Color.RED);
    Circle blueCircle = createCircle(20, 150, 20, Color.BLUE);
    Circle greenCircle = createCircle(40, 100, 40, Color.GREEN);

    Line line1 = connect(redCircle, blueCircle);
    Line line2 = connect(redCircle, greenCircle);
    Line line3 = connect(greenCircle, blueCircle);

    // add the circles
    root.getChildren().add(redCircle);
    root.getChildren().add(blueCircle);
    root.getChildren().add(greenCircle);

    // add the lines
    root.getChildren().add(line1);
    root.getChildren().add(line2);
    root.getChildren().add(line3);

    // bring the circles to the front of the lines
    redCircle.toFront();
    blueCircle.toFront();
    greenCircle.toFront();

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