Java Reference
In-Depth Information
// If we can't get the root container,
// abort the initialization
throw new XletStateChangeException( "Start aborted -- no
container: "
+ e.getMessage() );
}
}
}
public void startXlet() throws XletStateChangeException {
// Note: Swing thread constraints still apply in an Xlet... most
operations
// need to be on the event thread, and this invokeLater does that.
try {
// using invokeAndWait to avoid writing synchronization code.
// invokeLater would work just as well in most cases.
EventQueue.invokeAndWait(new Runnable() {
public void run() {
WeatherXlet.this.setVisible(true);
rootContainer.add(WeatherXlet.this);
// This is needed - or nothing will be displayed.
rootContainer.setVisible(true);
}
});
} catch (Exception e) {
System.out.println("Ouch - exception in invokeAndWait()");
e.printStackTrace();
exit();
}
}
public void pauseXlet() {
//This is pure overkill for this application, but is done to demonstate
the point.
//We are freeing up our only resources (the screen), and we will rebuild
it when
//we get started again. If you took out this block - the application
should still
//run perfectly, and the screen should only be created once.
try {
// using invokeAndWait to avoid writing synchronization code.
// invokeLater would work just as well in most cases.
 
Search WWH ::




Custom Search