Java Reference
In-Depth Information
In addition, like the WindowAdapter class that has all the WindowListener methods stubbed
out, there is an InternalFrameAdapter class with all the InternalFrameListener methods stubbed
out. If you're not interested in all the event happenings of a JInternalFrame , you can subclass
InternalFrameAdapter and override only those methods you're interested in. For instance, the
listener shown in Listing 8-5 is interested in only the iconification methods. Instead of providing
stubs for the other five methods of InternalFrameListener , you would need to subclass only
InternalFrameAdapter and override the two relevant methods.
Listing 8-5. Custom InternalFrameListener
import javax.swing.*;
import javax.swing.event.*;
public class InternalFrameIconifyListener extends InternalFrameAdapter {
public void internalFrameIconified(InternalFrameEvent internalFrameEvent) {
JInternalFrame source = (JInternalFrame)internalFrameEvent.getSource();
System.out.println ("Iconified: " + source.getTitle());
}
public void internalFrameDeiconified(InternalFrameEvent internalFrameEvent) {
JInternalFrame source = (JInternalFrame)internalFrameEvent.getSource();
System.out.println ("Deiconified: " + source.getTitle());
}
}
The InternalFrameEvent class is a subclass of AWTEvent . To define the values returned by
the public int getID() method of AWTEvent , the InternalFrameEvent class defines a constant
for each of the specific event subtypes that can be used. In addition, two other constants desig-
nate the range of valid values. Table 8-11 lists the nine constants. You can also get the actual
JInternalFrame from the event with getInternalFrame() .
Table 8-11. InternalFrameEvent Event Subtypes
Event Subtype ID
Associated Interface Method
INTERNAL_FRAME_ACTIVATED
internalFrameActivated
INTERNAL_FRAME_CLOSED
internalFrameClosed
INTERNAL_FRAME_CLOSING
internalFrameClosing
INTERNAL_FRAME_DEACTIVATED
internalFrameDeactivated
INTERNAL_FRAME_DEICONIFIED
internalFrameDeiconified
INTERNAL_FRAME_FIRST
N/A
INTERNAL_FRAME_ICONIFIED
internalFrameIconified
INTERNAL_FRAME_LAST
N/A
INTERNAL_FRAME_OPENED
internalFrameOpened
Customizing a JInternalFrame Look and Feel
Because the JInternalFrame is a lightweight component, it has an installable look and feel.
Each installable Swing look and feel provides a different JInternalFrame appearance and set of
 
Search WWH ::




Custom Search