public interface AlertListener
extends java.util.EventListener
| Modifier and Type | Method and Description |
|---|---|
void |
alert(AlertEvent event)
Notifies listeners about abnormal conditions in a
Dataview. |
void alert(AlertEvent event)
Dataview.
This method is called as soon as any abnormal condition is noticed.
For example,
if you call Graph.exportToGIF and any legend text
has been truncated, the exportToGIF method calls
this method.
Multiple notifications can occur as a graph reads data, so you
should save the information that you get from the AlertEvent
and wait to respond to the information until the graph completes
its data read.
One way to do this is to call the invokeLater method of
the javax.swing.SwingUtilities class, as shown in the
following example:
class AlertMe implements AlertListener{
public void alert(AlertEvent event){
String message;
switch (event.getID()){
case AlertEvent.DATA_ALL_DATA_NULL_NEG_ZERO:
message = "DATA_ALL_DATA_NULL_NEG_ZERO";
break;
case AlertEvent.DATA_ALL_AXIS_DATA_NULL_NEG_ZERO:
message = "DATA_ALL_AXIS_DATA_NULL_NEG_ZERO";
break;
default:
message = "Some other constant";
} // switch
final String finalMessage = message;
// Runnable is defined in java.lang
Runnable showMessage = new Runnable(){
public void run(){
JOptionPane.showMessageDialog(null, finalMessage);
} // run
}; // showMessage
// the message dialog will appear after the graph is painted
SwingUtilities.invokeLater(showMessage);
} // alert
} // AlertMe
event - Information about the alert.