
Display Text and Images in Java Graphics 10.9
Output
Line 5: creates a class and extends to JPanel public class IconDemo1 extends
JPanel {
Lines 9 and 10: create a frame for holding components and also define window func-
tionality such as exit operation
Line 13: creates an icon and specifies the location of the jpg file
creates a label and attaches the icon with the label
Line 21: displays the frame window
Line 24: as there is a need to safeguard the safety of the thread, it is advisable
to dispatch by event dispatch thread. This is achieved by lines 24, 25
and 26.
10.6.3 JText Field: JText Area
Swing API provides a TextField ...