<< Click to Display Table of Contents >> Events Generated by the Java Control |
The Java Control fires several events to your application, so you have always total control about what's happening.
NOTE: | You may not call CloseDoc() while processing any event fired by VPE - except it is explicitly said in the decription of a particular event that it is allowed. |
The event handling follows the Java standard. You need to implement an event listener class, which must be derived from VpeEventAdapter.
Depending on the edition of VPE, VpeEventAdapter is defined as follows:
// Community, Standard and Enhanced Edition
public class VpeEventAdapter implements VpeEventListener {
public VpeEventAdapter() {}
// GUI and Non-GUI
public void AfterAutoPageBreak(EventObject e) {}
// GUI only: The following methods are only present in the GUI version
public void AfterDestroyWindow(EventObject e) {}
public void AfterCloseWindow(EventObject e) {}
public void AfterOpenFile(EventObject e) {}
public void AfterSaveFile(EventObject e) {}
public void AfterMail(EventObject e) {}
public void Closing(CancelEvent e) {}
public void BeforeOpenFile(CancelEvent e) {}
public void BeforeSaveFile(CancelEvent e) {}
public void BeforeMail(CancelEvent e) {}
public void HelpRequested(EventObject e) {}
public void RequestPrint(RequestPrintEvent e) {}
public void BeforePrintNewPage(PrintEvent e) {}
public void PrintDevData(PrintEvent e) {}
}
// Professional and Enterprise Edition
public class VpeEventAdapter implements VpeEventListener {
public VpeEventAdapter() {}
// GUI and Non-GUI
public void AfterAutoPageBreak(EventObject e) {}
// GUI only: The following methods are only present in the GUI version
public void AfterDestroyWindow(EventObject e) {}
public void AfterCloseWindow(EventObject e) {}
public void AfterOpenFile(EventObject e) {}
public void AfterSaveFile(EventObject e) {}
public void AfterMail(EventObject e) {}
public void Closing(CancelEvent e) {}
public void BeforeOpenFile(CancelEvent e) {}
public void BeforeSaveFile(CancelEvent e) {}
public void BeforeMail(CancelEvent e) {}
public void HelpRequested(EventObject e) {}
public void RequestPrint(RequestPrintEvent e) {}
public void BeforePrintNewPage(PrintEvent e) {}
public void PrintDevData(PrintEvent e) {}
// GUI only, Professional Edition
public void ObjectClicked(ObjectClickedEvent e) {}
}
// Interactive Edition
public class VpeEventAdapter implements VpeEventListener {
public VpeEventAdapter() {}
// GUI and Non-GUI
public void AfterAutoPageBreak(EventObject e) {}
// GUI only: The following methods are only present in the GUI version
public void AfterDestroyWindow(EventObject e) {}
public void AfterCloseWindow(EventObject e) {}
public void AfterOpenFile(EventObject e) {}
public void AfterSaveFile(EventObject e) {}
public void AfterMail(EventObject e) {}
public void Closing(CancelEvent e) {}
public void BeforeOpenFile(CancelEvent e) {}
public void BeforeSaveFile(CancelEvent e) {}
public void BeforeMail(CancelEvent e) {}
public void HelpRequested(EventObject e) {}
public void RequestPrint(RequestPrintEvent e) {}
public void BeforePrintNewPage(PrintEvent e) {}
public void PrintDevData(PrintEvent e) {}
// GUI only, Professional Edition
public void ObjectClicked(ObjectClickedEvent e) {}
// GUI only, Interactive Edition
public void AfterControlEnter(VPEObjectEvent e) {}
public void AfterControlExit(VPEObjectEvent e) {}
public void AfterControlChange(VPEObjectEvent e) {}
public void RequestControlExit(ControlExitEvent e) {}
public void AfterFieldChange(VPEFieldEvent e) {}
}
Each event is explained in detail throughout the following sections.
The event handling is shown in practice in the Java demo source codes, which are installed together with VPE. Basically, derive a class from VpeEventAdapter and overload the methods for which you want to receive events.
Assuming your application is a class named MyApplication, your event listener could be:
class MyApplication_Listener extends VpeEventAdapter {
MyApplication adaptee;
MyApplication_Listener(MyApplication adaptee) {
this.adaptee = adaptee;
}
// In this example we are only interested in the
// AfterDestroyWindow event
public void AfterDestroyWindow(EventObject e) {
super.AfterDestroyWindow(e);
adaptee.AfterDestroyWindow(e);
}
}
Next, implement for your class MyApplication the method:
void AfterDestroyWindow(EventObject e)
which is your event handler.
After creating an instance of the VPE Control, you need to set the event listener (if an event listener is required):
Doc = new VpeControl();
Doc.setVpeListener(new MyApplication_Listener(this));
The VPE Control also implements an adapter class to test events:
public class VpeEventTestAdapter implements VpeEventListener
This class dumps the names of occurring events to System.out. To use this class, implement your event listener as follows:
class MyApplication_Listener extends VpeEventTestAdapter
For practical examples, please see the Java demo source codes, which are installed together with VPE.