my environment: Linux Suse 12.3, JDK 1.7.0_45, JavaFX 2.2, Compiler Compliance level 1.7.
on ButtonAction a modal Dialog is opened, the Dialog Stage has an owner Stage.
now dialog is opened but if i iconified the Owner and show it again, the Dialog is not visible. (thats happen only if i set dialog.initModality(Modality.WINDOW_MODAL);
or dialog.initModality(Modality.APPLICATION_MODAL);
) if i remove the Modality, its working just fine. UPDATE (modality is not the cause too, see my second update)
UPDATE: i have this Problem ONLY if the application is maximized. if i click the window maximize icon and then show the dialog, then iconify the Owner, now if i show the Owner application again, dialog isn't visible!
here is the Code:
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import you.faces.resources.YF;
public class Alert {
private String title = new String();
private String message = new String();
public Alert(Stage owner){
final Stage dialog = new Stage();
dialog.initOwner(owner);
dialog.initModality(Modality.WINDOW_MODAL);
dialog.initStyle(StageStyle.TRANSPARENT);
// i tried to redisplay the dialog like this, but still not working
owner.iconifiedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(
final ObservableValue<? extends Boolean> paramObservableValue,
final Boolean oldValue,
final Boolean newValue) {
if(newValue){
}else{ // none of these affect anything, dialog still not visible
dialog.setIconified(false);
dialog.show();
dialog.toFront();
}
}
});
StackPane root = new StackPane();
root.getStyleClass().add("YOU-FACES-MODAL-DIALOG");
root.getChildren().add(new Text(25, 25, "Hello World!"));
Scene scene = new Scene(root,200, 100);
scene.getStylesheets().add(YF.INSTANCE.getFile("clientUI.css"));
scene.setFill(Color.TRANSPARENT);
dialog.setScene(scene);
//relativeToOwner(dialog,owner);
dialog.show();
}
private void relativeToOwner(Stage stage, Stage owner) {
stage.setX(owner.getX() + owner.getWidth() / 2 - stage.getWidth() / 2);
stage.setY(owner.getY() + owner.getHeight() / 2 - stage.getHeight() / 2);
}
}
any idea how to deal with this Problem? Thanks