Showing posts with label JApplet. Show all posts
Showing posts with label JApplet. Show all posts
Tuesday, January 16, 2007
JApplet Code
import javax.swing.JApplet; // remind u that JApplet is from this package
import javax.swing.*; // step 1: needed for GUI components
import java.awt.*; // layouts
public class MyApplet extends JApplet /*step2*/{
private JButton btn1;
private JLabel lblPic;
private ImageIcon icon;
// step 3:over-riding the init method in Applet class
public void init(){
btn1 = new JButton("Pic 1");
icon = new ImageIcon(getImage(getCodeBase(), "pic1.jpg"));
lblPic = new JLabel(icon);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(btn1);
getContentPane().add(lblPic);
}
//step 4: write the html code
}//end class
Subscribe to:
Posts (Atom)
