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

1) learn to use a spell checker
2) learn Java

Member Avatar for electron33

Hi. Try with System.exit(0) after you call destroy in your code.
Mark: You will need Security rights to do so.

Visit Sun to find out more about this topic.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.