Closing Event - Java

<< Click to Display Table of Contents >>

Navigation:  Events Generated by the Java Control >

Closing Event - Java

Previous pageReturn to chapter overviewNext page

[GUI version only]

VPE requests confirmation from your application, if the preview can be closed.

public void Closing(

CancelEvent e

)

CancelEvent e

The cancel event is defined as:

public class CancelEvent extends java.util.EventObject {

private boolean cancel = false;

 

public boolean getCancel() {

  return cancel;

 }

 

public void setCancel(boolean cancel) {

  this.cancel = cancel;

 }

 

public CancelEvent(VpeControl source) {

  super(source);

 }

}

 

You can call e.setCancel(true) if you want to cancel the event, i.e. deny that the preview is closed

Example:

public void Closing(CancelEvent e) {

 if (!myDataIsSaved) {

         e.setCancel(true);

         JOptionPane.showMessageDialog(frame, "You must save first.");

 }

 else {

         e.setCancel(false);

         JOptionPane.showMessageDialog(frame, "Goodbye.");

 }

}