recently,I set out to do project with javafX,I'm a freshman.I need popupWindow and HTTP communication.Before the communication,I want to popup a window to alert for waiting.Hide the window When communication is end.But it can not popup the window ahead,who can help me.Sorry for my poor English.
This is the handler when I enter the textField.
txtinput.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
if (event.getCode() == KeyCode.ENTER) {
Platform.runLater(() -> {
//Popup The window
popupTransparentWindow.alertWindow(AlertWindowEnum.TYPE_NONE.getControllerClass(),
ShowConstants.ORDER_WAITING_FOR_RESPONSE, ShowConstants.TIP, ShowConstants.COMFIRM);
//HTTP Communication
OrderConfirmResponse orderConfirmResponse = confirmOrderService.confirmOrderInfo(posWindowController.getOrderList());
//Hide the popupWindow
popupTransparentWindow.close();
if (orderConfirmResponse.isSuccess()) {
TradeConstants.billNumber = orderConfirmResponse.getData().getTradeNumber();
} else {
popupTransparentWindow.alertWindow(AlertWindowEnum.TYPE_BUTTON.getControllerClass(),
orderConfirmResponse.getMessage(), ShowConstants.TIP, ShowConstants.COMFIRM);
}
});
}
});
public void alertWindow(Class<?> t, String title, String tip, String btn) {
AnchorPane paneWindow = new AnchorPane();
ObservableList<Stage> stage = FXRobotHelper.getStages();
paneWindow.setPrefWidth(1024);
paneWindow.setMinHeight(220);
//TODO 正式
Parent parent = paneWindow;
previousScene = PosApplication.homePage.getScene();
pop = new Popup();
pop.getContent().add(paneWindow);
pop.setAutoFix(true);
pop.setY(250);
pop.centerOnScreen();
pop.show(previousScene.getWindow());
//alertMethod(t, title, tip, btn);
}
The http response need about five seconds,but window can't popup ahead.if I hide the code
//popupTransparentWindow.close();
The window will be popup with the Http communication response together. Thanks