Difference between revisions of "Documentation/DevGuide/JavaBean/The OOoBean by Example"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m (FINAL VERSION FOR L10N)
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
|NextPage=Documentation/DevGuide/JavaBean/API Overview
 
|NextPage=Documentation/DevGuide/JavaBean/API Overview
 
}}
 
}}
{{DISPLAYTITLE:The OOoBean by Example}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/JavaBean/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:The OOoBean by Example}}
 
The <code>OOoBeanViewer</code> is a Java application that displays {{PRODUCTNAME}} 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 <code>OOoBeanViewer</code> is a Java application that displays {{PRODUCTNAME}} 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.  
  
Line 62: Line 63:
  
 
{{PDL1}}
 
{{PDL1}}
[[Category: JavaBean for Office Components]]
+
 
 +
[[Category:Documentation/Developer's Guide/JavaBean for Office Components]]

Revision as of 13:12, 15 May 2009



The OOoBeanViewer is a Java application that displays OpenOffice.org 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 OOoBean Viewer

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).
Personal tools
In other languages