/***//**
* @ (#) C10_1.java
*
*
* @ Author
* @ Version 1.00
*/
Import java. AWT .*;
Import javax. Swing .*;
Import java. AWT. event .*;
Public class c10_1 extends japplet implements actionlistener ...{
Container CP = getcontentpane ();
Icon Pa = new imageicon ("G:/javadocs/a1.gif ");
Icon Pb = new imageicon ("G:/javadocs/a2.gif ");
Icon Pc = new imageicon ("G:/javadocs/a3.gif ");
Jbutton bt = new jbutton ();
Icon Pd = new imageicon ("G:/javadocs/a4.gif ");
Jlabel lB = new jlabel ("hello", PD, jlabel. center );
/*** // *** Initialization method that will be called after the applet is loaded
* Into the browser.
*/
Public void Init ()...{
// Todo start asynchronous download of heavy resources
Bt. setroloverenabled (true );
Bt. settext ("click ");
Bt. sethorizontaltextposition (jbutton. center );
Bt. setverticaltextposition (jbutton. Bottom );
LB. sethorizontaltextposition (jlabel. center );
LB. setverticaltextposition (jlabel. Bottom );
CP. Add (LB, borderlayout. North );
CP. Add (BT, borderlayout. South );
Bt. seticon (PA );
Bt. setrololovericon (PB );
Bt. setpressedicon (PC );
Bt. addactionlistener (this );
}
Public void actionreceivmed (actionevent e )...{
If (E. getsource () = BT)
... {If (Lb. gettext () = "hello ")
LB. settext ("hello ");
Else
LB. settext ("hello ");
If (Bt. gettext () = "click ")
Bt. settext ("click ");
Else
Bt. settext ("click ");}
}
}
About imageicon (string filename)... it seems that you want to specify the absolute path .. Because I didn't specify the absolute path at first, even if I put the image file and. class in the same folder, it cannot be displayed normally ..
Supported images include GIF. jpg. JPEG and PNG versions starting from 1.3. ICO is not supported.