I think that you will understand more after looking at the following code. The following code explains the internal frame event handling. So have a look on the code below :
Code:
public class InternalFrameEventTrial ...
implements InternalFrameListener ... {
...
public void internalFrameClosing(InternalFrameEvent ie) {
displayMessage("Internal frame closing", ie);
}
public void internalFrameClosed(InternalFrameEvent ie) {
displayMessage("Internal frame closed", ie);
listenedToWindow = null;
}
public void internalFrameOpened(InternalFrameEvent ie) {
displayMessage("Internal frame opened", ie);
}
public void internalFrameIconified(InternalFrameEvent ie) {
displayMessage("Internal frame iconified", ie);
}
public void internalFrameDeiconified(InternalFrameEvent ie) {
displayMessage("Internal frame deiconified", ie);
}
public void internalFrameActivated(InternalFrameEvent ie) {
displayMessage("Internal frame activated", ie);
}
public void internalFrameDeactivated(InternalFrameEvent ie) {
displayMessage("Internal frame deactivated", ie);
}
void displayMessage(String prefix, InternalFrameEvent ie) {
String str = prefix + ": " + ie.getSource();
display.append(str + newline);
}
public void actionPerformed(ActionEvent ie) {
if (SHOW.equals(ie.getActionCommand())) {
...
if (listenedToWindow == null) {
listenedToWindow = new JInternalFrame("Event Generator",
true,
true,
true,
true);
listenedToWindow.setDefaultCloseOperation(
WindowConstants.HIDE_ON_CLOSE);
listenedToWindow.addInternalFrameListener(this);
...
}
}
...
}
}
Bookmarks