Difference between revisions of "Documentation/DevGuide/GUI/Message Box"
From Apache OpenOffice Wiki
< Documentation | DevGuide
m (1 revision(s)) |
m |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
|NextPage=Documentation/DevGuide/GUI/The Toolkit Service | |NextPage=Documentation/DevGuide/GUI/The Toolkit Service | ||
}} | }} | ||
− | {{DISPLAYTITLE:Message Box}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/GUI/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Message Box}} | ||
Message boxes contain a defined message and title that may be combined with predefined icons and buttons. Again the central instance to create a Message box is the service <idl>com.sun.star.awt.Toolkit</idl>. It serves as a factory that exports the interface <idl>com.sun.star.awt.XMessageBoxFactory</idl>. Its method <code>createMessageBox()</code> allows the creation of message boxes in various defined facets. | Message boxes contain a defined message and title that may be combined with predefined icons and buttons. Again the central instance to create a Message box is the service <idl>com.sun.star.awt.Toolkit</idl>. It serves as a factory that exports the interface <idl>com.sun.star.awt.XMessageBoxFactory</idl>. Its method <code>createMessageBox()</code> allows the creation of message boxes in various defined facets. | ||
− | * The first parameter of <code>createMessageBox()</code> denotes the peer of the parent window. In analogy to all {{ | + | * The first parameter of <code>createMessageBox()</code> denotes the peer of the parent window. In analogy to all {{AOo}} windows the peer of the window parent must be conveyed. |
* The second parameter <code>aPosSize</code> may be empty (but not null). | * The second parameter <code>aPosSize</code> may be empty (but not null). | ||
* The third parameter <code>aType</code> describes the special usecase of the message box. The interface description lists a bunch of defined strings like "<code>errorbox</code>" or "<code>querybox</code>". The message box type is than differentiated by its contained icon. | * The third parameter <code>aType</code> describes the special usecase of the message box. The interface description lists a bunch of defined strings like "<code>errorbox</code>" or "<code>querybox</code>". The message box type is than differentiated by its contained icon. | ||
Line 16: | Line 17: | ||
This example creates and executes a message box. | This example creates and executes a message box. | ||
− | + | <syntaxhighlight lang="java"> | |
/** shows an error messagebox | /** shows an error messagebox | ||
* @param _xParentWindowPeer the windowpeer of the parent window | * @param _xParentWindowPeer the windowpeer of the parent window | ||
Line 43: | Line 44: | ||
} | } | ||
}} | }} | ||
+ | </syntaxhighlight> | ||
+ | {{PDL1}} | ||
− | + | [[Category:Documentation/Developer's Guide/Graphical User Interfaces]] | |
− | + | ||
− | [[Category: Graphical User Interfaces]] | + |
Latest revision as of 13:32, 22 December 2020
- Common Properties
- Font-specific Properties
- Other Common Properties
- Property Propagation Between Model and Control
- Common Workflow to add Controls
- The Example Listings
- Label Field
- Command Button
- Image Control
- Check Box
- Radio Button
- Scroll Bar
- List Box
- Combo Box
- Progress Bar
- Horizontal/Vertical Line Control
- Group Box
- Text Field
- Text Field Extensions
- Formatted Field
- Numeric Field
- Currency Field
- Date Field
- Time Field
- Pattern Field
- Roadmap Control
- File Control
- File Picker
- Message Box
Message boxes contain a defined message and title that may be combined with predefined icons and buttons. Again the central instance to create a Message box is the service com.sun.star.awt.Toolkit. It serves as a factory that exports the interface com.sun.star.awt.XMessageBoxFactory. Its method createMessageBox()
allows the creation of message boxes in various defined facets.
- The first parameter of
createMessageBox()
denotes the peer of the parent window. In analogy to all Apache OpenOffice windows the peer of the window parent must be conveyed. - The second parameter
aPosSize
may be empty (but not null). - The third parameter
aType
describes the special usecase of the message box. The interface description lists a bunch of defined strings like "errorbox
" or "querybox
". The message box type is than differentiated by its contained icon. - Depending on the use case, different combinations of buttons in the message box are possible and reflected by a value of the constants group com.sun.star.awt.MessageBoxButtons. This is the fourth parameter
aButtons
. - The last two parameters reflect the title (
aTitle
) and the message (aMessage
) of the message box.
This example creates and executes a message box.
/** shows an error messagebox * @param _xParentWindowPeer the windowpeer of the parent window * @param _sTitle the title of the messagebox * @param _sMessage the message of the messagebox */ public void showErrorMessageBox(XWindowPeer _xParentWindowPeer, String _sTitle, String _sMessage){ XComponent xComponent = null; try { Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); XMessageBoxFactory xMessageBoxFactory = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit); // rectangle may be empty if position is in the center of the parent peer Rectangle aRectangle = new Rectangle(); XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xParentWindowPeer, aRectangle, "errorbox", com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, _sTitle, _sMessage); xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMessageBox); if (xMessageBox != null){ short nResult = xMessageBox.execute(); } } catch (com.sun.star.uno.Exception ex) { ex.printStackTrace(System.out); } finally{ //make sure always to dispose the component and free the memory! if (xComponent != null){ xComponent.dispose(); } }}
Content on this page is licensed under the Public Documentation License (PDL). |