3

I want to open a popup dialog when a 'signup' button is clicked. I want to add elements like textfield, password field on the pop up dialog. It would be better if you can suggest me how to add components to a popup window and then add the pop window to a pane and show it. Thank you!.

oldvipera
  • 305
  • 4
  • 8
  • 16
  • 1
    possible duplicate of [JavaFX 2 custom popup pane](http://stackoverflow.com/questions/12717969/javafx-2-custom-popup-pane) – jewelsea Jan 07 '14 at 10:29
  • I solved the problem. I made a Popup object and added it to a pane having the form components which was made using scenebuilder. This is what I had done at the fxml controller file:- `code` public void popup() { @FXML Pane popup_pane; //id of the pane which is created at scene builder Popup popup = new Popup(); popup.show(popup_pane,500,500); //providing x and y points are manditory popup_pane.setVisible(true); } `code` – oldvipera Jan 07 '14 at 11:39

2 Answers2

6

Just make a new Stage, then add desired components to it. For example:

public static void showStage(){
Stage newStage = new Stage();
VBox comp = new VBox();
TextField nameField = new TextField("Name");
TextField phoneNumber = new TextField("Phone Number");
comp.getChildren().add(nameField);
comp.getChildren().add(phoneNumber);

Scene stageScene = new Scene(comp, 300, 300);
newStage.setScene(stageScene);
newStage.show();
}

Call the method from the main and see that a new stage pops up.

Stevantti
  • 494
  • 2
  • 6
  • 13
1

You can make one :

Popup pop = PopupBuilder.create().content(contentNode).width(50).height(100).autoFix(true).build();
pop.show(stage);
user3224416
  • 522
  • 5
  • 15