Controlsfx Popover is not displaying at right location

217 views Asked by At

I'm designing a desktop app using java & javafx (UI Library). When a user clicks on his image in the app, a list of options will be shown to him in a popover (A class from the controlsfx library) relative to his parent but the problem is when the user clicks first time then it displays at wrong place and after second click it goes to its original place where it should be displayed. Could someone please point out the problem.

Code:

public class PrimaryWindowController implements Initializable {
    @FXML private Circle userIcon;
    private AnchorPane userAccountPopup;

    public void showUserAccountPopOver(MouseEvent mouseEvent) {
        if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_CLICKED)) {
            if (!popOver.isShowing()) {
                popOver.setAutoFix(false);
                popOver.setArrowLocation(PopOver.ArrowLocation.TOP_RIGHT);
                popOver.setArrowSize(0);
                popOver.show(userIcon);
                popOver.cornerRadiusProperty().setValue(0);
            } else {
                popOver.hide();
            }
        }
    }
}

App Images:

PopOver Wrong Position PopOver Right Position

0

There are 0 answers