Could you please post a complete, small example of this?

How is the Frame closed?  Are you talking about closing the
org.apache.pivot.wtk.Frame or the operating system window (which is a
java.awt.Frame I think) in a desktop application?

Chris

On 24 March 2012 10:10, ccp999 <[email protected]> wrote:
> Hi,
>
> I want to do a check before a frame is closed, so that for unsaved content,
> I can veto the closing.
>
> and here is my code:
>
> ......
>
>      private Vote vote = Vote.APPROVE;
>
>        @Override
>        public void initialize(Map<String, Object> namespace, URL location,
>                        Resources resources) {
>
>                this.getWindowStateListeners().add(new 
> WindowStateListener.Adapter() {
>
>                        @Override
>                        public Vote previewWindowClose(Window window) {
>
>                                if (Compose.this.isEdited()) {
>                                        closeConfirmPrompt.open(window, new 
> SheetCloseListener() {
>
>                                                @Override
>                                                public void sheetClosed(Sheet 
> sheet) {
>                                                        if 
> (closeConfirmPrompt.getResult()
>                                                                        && 
> closeConfirmPrompt
>                                                                               
>          .getSelectedOptionIndex() == 1) {
>                                                                vote = 
> Vote.APPROVE;
>                                                        } else
>                                                                vote = 
> Vote.DENY;
>                                                }
>                                        });
>                                        return vote;
>                                } else
>                                        return Vote.APPROVE;
>
>                        }
>
>                });
>
> However, the result is the window is closed before the prompt show up.
> why prompt is bypassed ?
>
> Brendan
>
>
> --
> View this message in context: 
> http://apache-pivot-users.399431.n3.nabble.com/How-to-use-windowStateListener-tp3853550p3853550.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Reply via email to