Created
November 10, 2014 11:25
-
-
Save oddbjornkvalsund/2c3cf8360973ec70885a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package focusbug; | |
import javafx.application.Application; | |
import javafx.event.ActionEvent; | |
import javafx.event.EventHandler; | |
import javafx.scene.Parent; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Button; | |
import javafx.scene.control.Label; | |
import javafx.scene.control.TextField; | |
import javafx.scene.layout.HBoxBuilder; | |
import javafx.scene.layout.VBoxBuilder; | |
import javafx.stage.Stage; | |
public class FocusBug extends Application { | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override | |
public void start(Stage mainStage ) { | |
mainStage.setScene(new Scene(getRootNode())); | |
mainStage.show(); | |
} | |
public Parent getRootNode() { | |
final TextField textField = new TextField(); | |
textField.setId("mainTextField"); | |
final Button clickMeButton = new Button("Click me to show popup"); | |
clickMeButton.setId("clickMeButton"); | |
clickMeButton.setOnAction(showPopupWindow()); | |
return VBoxBuilder.create().children(textField, clickMeButton).build(); | |
} | |
private EventHandler<ActionEvent> showPopupWindow() { | |
return new EventHandler<ActionEvent>() { | |
@Override | |
public void handle(ActionEvent actionEvent) { | |
final Label label = new Label("Enter text:"); | |
label.setId("popupLabel"); | |
final TextField textField = new TextField(); | |
textField.setId("popupTextField"); | |
final Stage stage = new Stage(); | |
stage.setTitle("Popup"); | |
stage.setScene(new Scene(HBoxBuilder.create().children(label, textField).build())); | |
stage.show(); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment