Basic Event Handling
The code listing below shows how basic events can be handled. When calling the AuthenticDesktopControl’s open method, or when trying to open a file via the menu or Project tree, the onOpenedOrFocused event is sent to the attached event handler. The basic handling for this event is opening the file by calling the Authentic DesktopDocumentControl’s open method.
01 // Open the PXF file when button is pressed
02 btnOpenPxf.addActionListener( new ActionListener() {
03 public void actionPerformed(ActionEvent e) {
04 try {
05 authenticDesktopControl.open( strExamplesFolder + "OrgChart.pxf" );
06 } catch (AutomationException e1) {
07 e1.printStackTrace();
08 }
09 }
10 } );
11 public void onOpenedOrFocused( String i_strFileName, boolean i_bOpenWithThisControl, boolean i_bFileAlreadyOpened ) throws AutomationException
12 {
13 // Handle the New/Open events coming from the Project tree or from the menus
14 if ( !i_bFileAlreadyOpened )
15 {
16 // This is basically an SDI interface, so open the file in the already existing document control
17 try {
18 AuthenticDesktopContainer.authenticDesktopDocument.open( i_strFileName );
19 AuthenticDesktopContainer.authenticDesktopDocument.requestFocusInWindow();
20 } catch (Exception e) {
21 e.printStackTrace();
22 }
23 }
24 }