OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

HowTo Pop Up a Window message (DialogBox) from Java

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
eitan_fr
Newbie
Newbie


Joined: 08 Mar 2004
Posts: 3

PostPosted: Mon Mar 08, 2004 4:14 am    Post subject: HowTo Pop Up a Window message (DialogBox) from Java Reply with quote

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
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon Mar 08, 2004 6:21 am    Post subject: Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Thu Apr 08, 2004 1:47 pm    Post subject: Re: HowTo Pop Up a Window message (DialogBox) from Java Reply with quote

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
Newbie


Joined: 08 Jan 2005
Posts: 1

PostPosted: Tue Jan 11, 2005 10:08 am    Post subject: re: Reply with quote

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
View user's profile Send private message Send e-mail
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Jan 12, 2005 9:10 am    Post subject: Reply with quote

In
<OpenOffice.org1.1_SDK>/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java
i see a method :

private void showInfoModal( com.sun.star.awt.XWindow xParent ,
java.lang.String sTitle ,
java.lang.String sMessage )

which i think do what you ask ? (I am not a Java programmer)
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
zaphod
Power User
Power User


Joined: 04 Nov 2004
Posts: 51
Location: Magdeburg, Germany

PostPosted: Thu Jan 13, 2005 12:50 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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