hi, im new to java...and the rest like swing and all that stufss. i got a code but i want to change the applet a bit , i mean the way it is diplayed. ken u help. and yes i want wen i click exit button the applets closes and the browser too.
mport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Graphics.*;
import java.applet.Applet;
public class Task1 extends JApplet implements ActionListener
{
JLabel lab1;
JComboBox comb1;
JButton but1;
public void init()
{
Container con=getContentPane();
con.setLayout(new FlowLayout());
lab1=new JLabel("Please choose an image here:::>/t");
con.add(lab1);
comb1=new JComboBox();
comb1.addItem("Lake");
comb1.addItem("Wood");
comb1.addItem("Tree");
con.add(comb1);
ImageIcon image = new ImageIcon("ajay.jpg");
but1=new JButton("Exit",image);
getContentPane().add(but1);
but1.addActionListener(this);
comb1.addActionListener(this);
}
public void paint( Graphics g )
{
super.paint( g );
Image image = getImage( getCodeBase(), comb1.getSelectedItem().toString() + ".jpg");
g.drawImage( image,100,100,100,100, this );
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource() == but1)
{
//lab1.setText("Thanks for using this program, close the browser! ");
//repaint();
destroy();
}
else if(ae.getSource() == comb1)
{
repaint();
}
}
}
tkx