problem with opening multiple modal windows

hi

I have a problem with opening multiple modal windows. I create the main shell window and then a second (modal) window that does some processing. at a certain point the second window launches a third window that I need for some additional user input (which I don't what in the second window). the third window is also modal but the processing in window number 2 is not stopped for the time window number 3 is running - how can I do this?

(in other words - how can i stop B from running while C is open?)

below is the code to show my problem

class A:

=======

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Shell;

publicclass A{

privatestatic Display display =null;

private Shell shell =null;

publicstaticvoid main(String[] args){

display = Display.getDefault();

A thisClass =new A();

thisClass.createWindow();

thisClass.shell.open();

while (!thisClass.shell.isDisposed()){

if (!display.readAndDispatch())

display.sleep();

}

display.dispose();

}

privatevoid createWindow()

{

shell =new Shell();

shell.setText("First Window");

shell.setSize(640, 430);

openSecondWindow();

}

privatevoid openSecondWindow()

{

new B(shell);

}

}

class B:

=======

import org.eclipse.swt.SWT;

import org.eclipse.swt.widgets.Shell;

import org.eclipse.swt.widgets.Text;

publicclass B{

private Shell parent =null;

public B(Shell parent)

{

this.parent = parent;

createWindow();

}

privatevoid createWindow()

{

Shell dialog =new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

dialog.setText("Second Window");

dialog.setSize(330, 200);

Text t =new Text(dialog, SWT.MULTI);

t.setBounds(0,0, 330, 200);

dialog.open();

t.append("dialog opened\n");

t.append("opening third window\n");

C c =new C(dialog);

//I want this window to wait for C !!!

t.append("third window is open\n");

t.append("this windows doesn't wait for the third one to finish\n");

t.append("the value of c.shouldClose() is " + c.shouldClose() +"\n");

}

}

class C:

=======

import org.eclipse.swt.SWT;

import org.eclipse.swt.widgets.Button;

import org.eclipse.swt.widgets.Event;

import org.eclipse.swt.widgets.Listener;

import org.eclipse.swt.widgets.Shell;

publicclass C{

private Shell parent =null;

privateboolean shouldClose =false;

public C(Shell parent)

{

this.parent = parent;

createWindow();

}

privatevoid createWindow()

{

final Shell dialog =new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

dialog.setText("Third Window");

dialog.setSize(200, 100);

dialog.open();

Button ok =new Button(dialog, SWT.NORMAL);

ok.setText("OK");

ok.setBounds(10, 10, 75, 23);

ok.addListener(SWT.Selection,new Listener(){

publicvoid handleEvent(Event e){

shouldClose =false;

dialog.close();

}

});

Button cancel =new Button(dialog, SWT.NORMAL);

cancel.setText("Anuluj");

cancel.setBounds(100, 10, 75, 23);

cancel.addListener(SWT.Selection,new Listener(){

publicvoid handleEvent(Event e){

shouldClose =true;

dialog.close();

}

});

}

publicboolean shouldClose()

{

return shouldClose;

}

}

thank you very much in advance

[6923 byte] By [reverencea] at [2007-11-27 0:40:55]
# 1
Why not close B before opening C and opening B again after closing C? (Or can you make a dialog modal to another dialog? The Swing people in the Swing forum might know.)
CeciNEstPasUnProgrammeura at 2007-7-11 22:54:06 > top of Java-index,Java Essentials,Java Programming...
# 2
Yes you can make one dialog box the child of another and modal at the same time.
TimRyanNZa at 2007-7-11 22:54:06 > top of Java-index,Java Essentials,Java Programming...
# 3

I thought I was making A the parent of B (which is modal) and B the parent of C (which is also modal)

in A:

===

private void openSecondWindow()

{

new B(shell);

}

in B:

===

private void createWindow()

{

Shell dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

...

C c = new C(dialog);

...

}

is it not happening like that?

and I can't close B and reopen it because I need a result of some processing in C before I can finnish processing B (that's why I'm even opening C in the first place)

any help much appreciated

reverencea at 2007-7-11 22:54:06 > top of Java-index,Java Essentials,Java Programming...