| View previous topic :: View next topic |
| Author |
Message |
eitan_fr Newbie

Joined: 08 Mar 2004 Posts: 3
|
Posted: Mon Mar 08, 2004 4:14 am Post subject: HowTo Pop Up a Window message (DialogBox) from Java |
|
|
When I receive notifyEvent onSave event of a text document, I do some validation on the document, then I may need to pop up a window and prompt the user with a message (that instructs the user what should be corrected).
Can you suggest directions how to Pop Up a Window message (DialogBox) from Java, and point me to Java examples that do similar processing?
I am looking for the simplest way to invoke a dialog box with a message from Java. I assume that UNO supports it, but I cannot find such a service.
Option A - Probably the simplest way to do it, is to use AWT directly from my java application regardless the fact that the application interacts with OpenOffice via UNO.
Option B - I can use the SampleDialog ~OpenOffice.org1.1_SDK\examples\DevelopersGuide\BasicAndDialogs\CreatingDialogs\SampleDialog.java (Section 11.6 Creating Dialogs at Runtime in the Developer Guide v1.1 p772-774)
Can you help on this issue?
BTW - I also psoted a query: HowTo STOP the SAVING process when notifyEvent onSave.
Regards
Eitan |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Mon Mar 08, 2004 6:21 am Post subject: |
|
|
| Quote: | | Can you suggest directions how to Pop Up a Window message (DialogBox) from Java |
Here is a link to a Basic example of how to use the API to create and display a dialog box.
http://www.oooforum.org/forum/viewtopic.php?t=3130
I use similar code in Python. I have not ported the example to Java.
What happens is that using the API, you create a dialog box. You add controls to it, specifying the coordinates of each control. You attach event listeners to controls. Finally, you "execute" the dialog box. When a certian event listener is called, such as the OK or Cancel button, then you end the dialog box so that it disappears.
| Quote: | | Probably the simplest way to do it, is to use AWT directly from my java application regardless the fact that the application interacts with OpenOffice via UNO. |
Problem with this approach: the AWT dialog will appear on the computer that is running the Java application, not on the computer that is running the OOo. The AWT dialog won't have the "look and feel" of an OOo dialog. As far as I know, it also won't be modal with regard to OOo. That is, the AWT dialog will be modeless, or at least only modal to the java thread. I know of no reason the user couldn't move your dialog and continue working with OOo documents ignoring the dialog box.
Try copy & paste the above linked code example into the Basic IDE and run it. You would have to port it to Java. I would suggest the following design in Java...
1. create a new object, of some class, OOoDialogBox.
2. then call methods on that object, createButton, createLabel, createCheckbox, etc.
3. each call to createButton, etc. requires an event listener, or null. (The event listener could be of an Interface of your own design, and then defined inline.)
4. Then execute the dialog object.
Once you create a toolkit to display dialog boxes in Java, you would actually use such a toolkit like this....
| Code: |
OOoDialogBox oDialog = new OOoDialogBox( "Dialog title" );
oDialog.createButton( 10, 20, 30, 40, "OK", new OOoDialogEventListener() { ........ } );
oDialog.createButton( 30, 40, 50, 60, "Cancel, new OOoDialogEventListener() { ....... } );
oDialog.execute();
|
_________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Apr 08, 2004 1:47 pm Post subject: Re: HowTo Pop Up a Window message (DialogBox) from Java |
|
|
| eitan_fr wrote: | When I receive notifyEvent onSave event of a text document, I do some validation on the document, then I may need to pop up a window and prompt the user with a message (that instructs the user what should be corrected).
Can you suggest directions how to Pop Up a Window message (DialogBox) from <B style="color:black;background-color:#A0FFFF">Java</B>, and point me to <B style="color:black;background-color:#A0FFFF">Java </B><B style="color:black;background-color:#99ff99">examples</B> that do similar processing?
I am looking for the simplest way to invoke a dialog box with a message from <B style="color:black;background-color:#A0FFFF">Java</B>. I assume that UNO supports it, but I cannot find such a service.
Option A - Probably the simplest way to do it, is to use AWT directly from my <B style="color:black;background-color:#A0FFFF">java</B> application regardless the fact that the application interacts with <B style="color:black;background-color:#ffff66">OpenOffice</B> via UNO.
Option B - I can use the SampleDialog ~<B style="color:black;background-color:#ffff66">OpenOffice</B>.org1.1_SDK\<B style="color:black;background-color:#99ff99">examples</B>\DevelopersGuide\BasicAndDialogs\CreatingDialogs\SampleDialog.<B style="color:black;background-color:#A0FFFF">java</B> (Section 11.6 Creating Dialogs at Runtime in the Developer Guide v1.1 p772-774)
Can you help on this issue?
BTW - I also psoted a query: HowTo STOP the SAVING process when notifyEvent onSave.
Regards
Eitan |
|
|
| Back to top |
|
 |
NeshoD Newbie

Joined: 08 Jan 2005 Posts: 1
|
Posted: Tue Jan 11, 2005 10:08 am Post subject: re: |
|
|
I have the same problem if someone knows how-to solve it
after recived notify of onSave event I need to stop the saving and pop up a java window massage and after confirmation ... determine weather or not to save or not the document |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
zaphod Power User


Joined: 04 Nov 2004 Posts: 51 Location: Magdeburg, Germany
|
Posted: Thu Jan 13, 2005 12:50 am Post subject: |
|
|
Hello
If anybody knows, how to make a dialog, wich is not
blocking other OOo-Windows with already opened
dialogs, please let me know.
It's a really annoying problem.
thx |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|