Difference between revisions of "Documentation/DevGuide/JavaBean/The OOoBean by Example"
OOoWikiBot (talk | contribs) m (FINAL VERSION FOR L10N) |
|||
Line 6: | Line 6: | ||
{{Documentation/DevGuideLanguages|Documentation/DevGuide/JavaBean/{{SUBPAGENAME}}}} | {{Documentation/DevGuideLanguages|Documentation/DevGuide/JavaBean/{{SUBPAGENAME}}}} | ||
{{DISPLAYTITLE:The OOoBean by Example}} | {{DISPLAYTITLE:The OOoBean by Example}} | ||
− | The <code>OOoBeanViewer</code> is a Java application that displays {{ | + | The <code>OOoBeanViewer</code> is a Java application that displays {{AOo}} documents in a Java AWT applet, which allows for the control of some toolboxes, the menu bar and the status bar, as well as storing and loading the document content to/from an internal buffer. |
[[Image:OOBean_example.png|none|thumb|400px|The OOoBean Viewer]] | [[Image:OOBean_example.png|none|thumb|400px|The OOoBean Viewer]] | ||
The <code>OOoBeanViewer</code> <!--(see [SOURCE:OfficeBean/OOoBeanViewer.java])--> utilizes the class <code>OOoBean</code> directly without subclassing it: | The <code>OOoBeanViewer</code> <!--(see [SOURCE:OfficeBean/OOoBeanViewer.java])--> utilizes the class <code>OOoBean</code> directly without subclassing it: | ||
− | + | <syntaxhighlight lang="java"> | |
public class OOoBeanViewer extends java.applet.Applet | public class OOoBeanViewer extends java.applet.Applet | ||
{ | { | ||
Line 28: | Line 28: | ||
} | } | ||
} | } | ||
− | + | </syntaxhighlight> | |
Initially, the OOoBean component does not contain a document. A document can be created with the loadFromURL method: | Initially, the OOoBean component does not contain a document. A document can be created with the loadFromURL method: | ||
− | + | <syntaxhighlight lang="java"> | |
private void createBlankDoc(String url, String desc) | private void createBlankDoc(String url, String desc) | ||
{ | { | ||
Line 55: | Line 55: | ||
} | } | ||
} | } | ||
− | + | </syntaxhighlight> | |
Some tool windows of the document window within the Java Bean can be controlled directly by the OOoBean API. For example, to toggle visibility of the menu bar: | Some tool windows of the document window within the Java Bean can be controlled directly by the OOoBean API. For example, to toggle visibility of the menu bar: | ||
− | + | <syntaxhighlight lang="java"> | |
aBean.setMenuBarVisible( !aBean.isMenuBarVisible() ); | aBean.setMenuBarVisible( !aBean.isMenuBarVisible() ); | ||
− | + | </syntaxhighlight> | |
The examples above provide an overview of how the <code>OOoBean</code> API is used to create Java Beans that can be used in Java applications and applets. For concrete Java Beans, you usually subclass <code>OOoBean</code> and create appropriate BeanInfo classes for integrating within an IDE (Integrated Development Environment), such as the Bean Development Kit or Forte for Java. Developers can use the examples as a guideline when using the <code>OOoBean</code> API to write new beans, or use or extend the example beans. | The examples above provide an overview of how the <code>OOoBean</code> API is used to create Java Beans that can be used in Java applications and applets. For concrete Java Beans, you usually subclass <code>OOoBean</code> and create appropriate BeanInfo classes for integrating within an IDE (Integrated Development Environment), such as the Bean Development Kit or Forte for Java. Developers can use the examples as a guideline when using the <code>OOoBean</code> API to write new beans, or use or extend the example beans. | ||
Latest revision as of 17:27, 21 December 2020
The OOoBeanViewer
is a Java application that displays Apache OpenOffice documents in a Java AWT applet, which allows for the control of some toolboxes, the menu bar and the status bar, as well as storing and loading the document content to/from an internal buffer.
The OOoBeanViewer
utilizes the class OOoBean
directly without subclassing it:
public class OOoBeanViewer extends java.applet.Applet
{
...
private OOoBean aBean;
...
public void init()
{
aBean = new OOoBean();
}
...
{
add( aBean );
}
}
Initially, the OOoBean component does not contain a document. A document can be created with the loadFromURL method:
private void createBlankDoc(String url, String desc)
{
//Create a blank document
try
{
aBean.loadFromURL( url, null );
....
}
catch ( com.sun.star.comp.beans.SystemWindowException aExc )
{
// this exception will be thrown when no system window parent can be found
...
}
catch ( com.sun.star.comp.beans.NoConnectionException aExc )
{
// this exception is thrown
// when no connection to a [PRODUCTNAME] instance can be established
...
}
catch ( Exception aExc )
{
...
}
}
Some tool windows of the document window within the Java Bean can be controlled directly by the OOoBean API. For example, to toggle visibility of the menu bar:
aBean.setMenuBarVisible( !aBean.isMenuBarVisible() );
The examples above provide an overview of how the OOoBean
API is used to create Java Beans that can be used in Java applications and applets. For concrete Java Beans, you usually subclass OOoBean
and create appropriate BeanInfo classes for integrating within an IDE (Integrated Development Environment), such as the Bean Development Kit or Forte for Java. Developers can use the examples as a guideline when using the OOoBean
API to write new beans, or use or extend the example beans.
Content on this page is licensed under the Public Documentation License (PDL). |