The Source for Java Technology Collaboration

Home » java.net Forums » Mobile & Embedded » LWUIT

Thread: How to automatically dispose a modeless Dialog when new Form is shown

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 17 - Last Post: Aug 26, 2008 9:24 PM by: sawal_xp
egon_olsen

Posts: 7
How to automatically dispose a modeless Dialog when new Form is shown
Posted: Aug 12, 2008 4:32 AM
  Click to reply to this thread Reply

Hello,
I want to place a progress bar into a modeless Dialog in order to get this great effect of repainting the previous Form in the background.
The problem I have got with this is that a progress bar doesn't have a Command which could be used to dispose it. Instead the next Form is Displayed.

Is there a way to automatically dispose the progress bar Dialog? Or is a way of creating a Form that is painted in the same way as the Dialog, i.e. with the previous Screen in the background?

Thanks.

Message was edited by: egon_olsen

Shai Almog
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 12, 2008 6:05 AM   in response to: egon_olsen
  Click to reply to this thread Reply

Hi,
since a modeless dialog is modeless it would be disposed
automatically when you show() any other form.

If you want to add a command to a modeless dialog just use
"addCommand" and place any command that you want (such as Cancel)
onto the dialog.


> Hello,
> I want to place a progress bar into a modeless Dialog in order to
> get this great effect of repainting the previous Form in the
> background.
> The problem I have got with this is that a progress bar doesn't
> have a Command which could be used to dispose it. Instead the next
> Form is Displayed.
>
> Is there a way to automatically dispose the progress bar Dialog? Or
> is a way of creating a Form that is painted in the same way as the
> Dialog, i.e. with the previous Screen in the background?
>
> Thanks.
> [Message sent by forum member 'egon_olsen' (egon_olsen)]
>
> http://forums.java.net/jive/thread.jspa?messageID=292823
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


egon_olsen

Posts: 7
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 12, 2008 9:54 PM   in response to: Shai Almog
  Click to reply to this thread Reply

Hi Shai,

> since a modeless dialog is modeless it would be disposed
> automatically when you show() any other form.

This is only the case if a Form is displayed after the modeless Dialog.
In case a mode-full Dialog is shown after the modeless one, then the modeless Dialog is not automatically disposed by showing a Form.

I presume, there is a static field, indicating the type of Dialog in the navigation manager, which is overwritten by the mode-full Dialog.

Here is an example. In the code below, I
1. create a modeless Dialog.
2. Then show a mode-full Dialog, which, upon disposal, shows a new Form.

According to you, the mode-full Dialog should automatically dispose the modeless one. Therefore, after disposal of the mode-full Dialog the new Form should be displayed. What I observe, though, is that the modeless Dialog reappears after the mode-full Dialog was closed. Debugging shows that the show method of the form is getting called.
-------------
new Dialog("wait screen").showModeless();

//make sure, the modeless dialog is shown first
try { Thread.sleep(2000);
} catch (InterruptedException ex) {
System.out.println(ex.getMessage());
}

Dialog.show(
"Hallo",
new Label("go back from here"),
new Command[]{new Command("back")

{
public void actionPerformed(
ActionEvent arg0) {
Form f = new Form();
f.addComponent(new Label("me;"));
Command destroy =
new Command("quit") {
public void actionPerformed(
ActionEvent arg0) {
notifyDestroyed();
}
};
f.addCommand(destroy);
f.show();
}
}
});
------------

The option of providing a dispose Command to the modeless Dialog is not feasable for me as I want to use modeless Dialog as a progress indicator. A use case for showing a modefull Dialog after a modeless one, is when the user needs to be notified about the result of the transaction.

Kind regards

Message was edited by: egon_olsen

Message was edited by: egon_olsen

Message was edited by: egon_olsen

Shai Almog
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 12, 2008 9:54 PM   in response to: egon_olsen
  Click to reply to this thread Reply

> //make sure, the modeless dialog is shown first
> try { Thread.sleep(2000); } catch (InterruptedException ex)
> { System.out.println(ex.getMessage());
> }
>

Hi,
in the code above you are blocking the EDT which is illegal. Use
timers, animations or threads to produce the same effect and never
use sleep on the event dispatch thread.


> http://forums.java.net/jive/thread.jspa?messageID=292947
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


egon_olsen

Posts: 7
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 12, 2008 10:14 PM   in response to: Shai Almog
  Click to reply to this thread Reply

> Hi,
> in the code above you are blocking the EDT which is
> illegal. Use
> timers, animations or threads to produce the same
> effect and never
> use sleep on the event dispatch thread.

Thanks Shai, good to know.
But do I fear, the original problem is not an effect of this.
If I wrap the creation of the mode-full Dialog into a new Thread, I still observe the same phenomena.
------------------
new Dialog("wait screen").showModeless();



//make sure, the modeless dialog is shown first
new Thread() {

public void run() {
try {
Thread.sleep(200);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
Dialog.show("Hallo", new Label("go back from here"), new Command[]{new Command("back") {

public void actionPerformed(ActionEvent arg0) {
Form f = new Form();
f.addComponent(new Label("me;"));
Command destroy = new Command("quit") {

public void actionPerformed(ActionEvent arg0) {
notifyDestroyed();
}
};
f.addCommand(destroy);
f.show();
}
}
});
}
}.start();
---------------

Message was edited by: egon_olsen

Shai Almog
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 12, 2008 11:34 PM   in response to: egon_olsen
  Click to reply to this thread Reply

> Thanks Shai, good to know.
> But do you believe, the original problem is an effect of this?

Yes.

> [Message sent by forum member 'egon_olsen' (egon_olsen)]
>
> http://forums.java.net/jive/thread.jspa?messageID=292951
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


egon_olsen

Posts: 7
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 13, 2008 12:19 AM   in response to: Shai Almog
  Click to reply to this thread Reply

Hi Shai,

Somehow assuming that you would be in a very different time zone from the one I am in, I had edited my posts which obviously has caused confusion.

I strongly believe that if you push a modefull Dialog B on top of a modeless Dialog A and then dispose the modefull dialog B then A is back on top of the stack but now modefull.

This does not happen if I push a plain Form before the modefull Dialog which makes the workaround tedious.

Kind regards

sawal_xp

Posts: 83
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 13, 2008 12:42 AM   in response to: egon_olsen
  Click to reply to this thread Reply

hi..
i want to show dialog like egon_olsen, show dialog to display progres, may be like animating an image.

i make simple dialog at start when the next form will show();
like this :

//show simple dialog wait
Dialog proDG = new Dialog();
proDG.addComponent(new Label("Please Wait...");
proDG.showModeless();

//show the next form
(new Nextform()).show();

--
why my dialog proDG not display or not show..???

Shai Almog
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 13, 2008 2:04 AM   in response to: egon_olsen
  Click to reply to this thread Reply

Hi,
yes I missed the portion where you covered the modeless dialog with a
modal dialog. This is a bug in our current drop that will be fixed in
the next drop.

> Hi Shai,
>
> Somehow assuming that you would be in a very different time zone
> from the one I am in, I had edited my posts which obviously has
> caused confusion.
>
> I strongly believe that if you push a modefull Dialog B on top of a
> modeless Dialog A and then dispose the modefull dialog B then A is
> back on top of the stack but now modefull.
>
> This does not happen if I push a plain Form before the modefull
> Dialog which makes the workaround tedious.
>
> Kind regards
> [Message sent by forum member 'egon_olsen' (egon_olsen)]
>
> http://forums.java.net/jive/thread.jspa?messageID=292968
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


sawal_xp

Posts: 83
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 13, 2008 3:01 AM   in response to: Shai Almog
  Click to reply to this thread Reply

hi shai..

>>shai
>>Hi,
>>yes I missed the portion where you covered the modeless dialog with a
>>modal dialog. This is a bug in our current drop that will be fixed in
>>the next drop.

it mean, the dialog.showModeless() can't work..?
so my code is rigth, but becouse a bug in dialog component, so my dialog not show..
is it true..?

egon_olsen

Posts: 7
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 13, 2008 3:16 AM   in response to: Shai Almog
  Click to reply to this thread Reply

Thanks Shai.

This is good news.
I have got another problem which is also related to disposable of Dialogs. It is the following: if I choose to show another Form upon disposal of a Dialog, i have to explicitly call dispose on the Dialog or the new Form will not be shown but the form that was shown before the Dialog will.

Here is an example:
--------------------
new Form("initial").show();

final Dialog d = new Dialog("Dialog");
d.addCommand(new Command("cont.") {

public void actionPerformed(ActionEvent arg0) {
// why do we need this?
d.dispose();
Form f = new Form("new form");
f.show();
}
});
d.show();
---------------------
If you omit the explicit disposal of the Dialog, the new Form will not be shown but the initial Form will.

Kind regards

sawal_xp

Posts: 83
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 24, 2008 7:32 PM   in response to: egon_olsen
  Click to reply to this thread Reply

In LWUIT_20080814, i try the dialog in show modeless,
and i get the trouble again, is the show modelss bug repair?
or my code for display modess is wrong, please help me...

my code is like this...

public void actionPerformed(ActionEvent evt) {
loginVerify();
}

public void loginVerify(){
new Thread(new Runnable() {
public void run() {
MyApp.showProgressDialogInModeless();
}
});

// next code is progressing the verifying to the server
// when finish, show new form();
}


with that code, the dialog was not display...why...?

Shai Almog
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 25, 2008 1:43 AM   in response to: sawal_xp
  Click to reply to this thread Reply

Hi,
you don't need a thread to show the modeless dialog since its non-
blocking.
You seem to create a thread without invoking start().

> In LWUIT_20080814, i try the dialog in show modeless,
> and i get the trouble again, is the show modelss bug repair?
> or my code for display modess is wrong, please help me...
>
> my code is like this...
>
> public void actionPerformed(ActionEvent evt) {
> loginVerify();
> }
>
> public void loginVerify(){
> new Thread(new Runnable() {
> public void run() {
> MyApp.showProgressDialogInModeless();
> }
> });
>
> // next code is progressing the verifying to the server
> // when finish, show new form();
> }
>
>
> with that code, the dialog was not display...why...?
> [Message sent by forum member 'sawal_xp' (sawal_xp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=295047
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


sawal_xp

Posts: 83
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 25, 2008 7:20 PM   in response to: Shai Almog
  Click to reply to this thread Reply

hi shai...
ok..i repair my code, so this my simple code..

public void actionPerformed(ActionEvent evt) {
loginVerify();
}
public void loginVerify(){
Dialog testDG = new Dialog("Progress");
testDG.setLayout(new BoxLayout(BoxLayout.X_AXIS));
testDG.addComponent(new Label("Please wait.."));

testDG.show(10, 10, 10, 10, true, false); //show dialog with modeless mode...

//next code is verifying the username n password
// if true, then show new form();
}

the dialog modeless that i want to show progress "please wait", is not show....:(

Shai Almog
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 26, 2008 1:39 AM   in response to: sawal_xp
  Click to reply to this thread Reply

Hi,
This still won't work since you are holding the EDT. Open a new thread:

> public void actionPerformed(ActionEvent evt) {
> loginVerify();
> }
> public void loginVerify(){
> Dialog testDG = new Dialog("Progress");
> testDG.setLayout(new BoxLayout(BoxLayout.X_AXIS));
> testDG.addComponent(new Label("Please wait.."));
>
> testDG.show(10, 10, 10, 10, true, false); //show dialog
> with modeless mode...
> new Thread(this).start();
> }
public void run() {
>> //next code is verifying the username n password
>> // if true, then show new form();
>>

}


> hi shai...
> ok..i repair my code, so this my simple code..
>
> public void actionPerformed(ActionEvent evt) {
> loginVerify();
> }
> public void loginVerify(){
> Dialog testDG = new Dialog("Progress");
> testDG.setLayout(new BoxLayout(BoxLayout.X_AXIS));
> testDG.addComponent(new Label("Please wait.."));
>
> testDG.show(10, 10, 10, 10, true, false); //show dialog
> with modeless mode...
>
> //next code is verifying the username n password
> // if true, then show new form();
> }
>
> the dialog modeless that i want to show progress "please wait", is
> not show....:(
> [Message sent by forum member 'sawal_xp' (sawal_xp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=295246
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


sawal_xp

Posts: 83
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 26, 2008 8:45 PM   in response to: Shai Almog
  Click to reply to this thread Reply

hai shai..
i modify my code and this is with thread...

public void actionPerformed(ActionEvent evt) {
loginVerify();
}

public void loginVerify(){
new Thread(new Runnable() {
public void run() {
MyApp.showProgressDialogInModeless();
}
}).start();

// next code is progressing the verifying to the server
// when finish, show new form();
}

the dialog modelss is show, but not the time where my app connecting to the server or before verifying code is run,
the dialog modelss will show after new form display...why?

sawal_xp

Posts: 83
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 26, 2008 9:03 PM   in response to: sawal_xp
  Click to reply to this thread Reply

sorry shai..my post before is wrong,
the dialog is show after my code to verify login run...and the new form isn't show...why..?

how to display my dialog modelss before my code to verify login or before connect to server..?

sawal_xp

Posts: 83
Re: How to automatically dispose a Dialog when new Form is shown
Posted: Aug 26, 2008 9:24 PM   in response to: sawal_xp
  Click to reply to this thread Reply

hi, i get it, and my dialog progress show...:)
this my code..:

public void actionPerformed(ActionEvent evt) {
new Thread(new Runnable() {
public void run() {
MyApp.showProgressDialogInModeless();
loginVerify();
}
}).start();
}

public void loginVerify(){
// code to progressing the verifying to the server
// when finish, show new form();
}

it's true...:)




 XML java.net RSS