how to add JFileChooser to the program

i have to add the JFileChooser at loadp button .....please help

"import java.awt.*;

import java.applet.*;

import java.util.*;

import java.lang.Math.*;

import javax.swing.*;

import java.awt.Toolkit;

import java.awt.BorderLayout;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

import java.awt.event.*;

import javax.swing.event.*;

import javax.swing.text.*;

import java.text.*;

public class tm extends JApplet implements ActionListener{

public void init()

{

JPanel contentPane = new JPanel();

contentPane.setLayout(new GridLayout(1,1));

JButton loadi = new JButton("LOAD INPUT STRING");

contentPane.add(loadi);

loadi.addActionListener(this);

JButton loadp = new JButton("LOAD PROGRAM");

contentPane.add(loadp);

loadp.addActionListener(this);

JButton run = new JButton("RUN");

contentPane.add(run);

run.addActionListener(this);

JButton step = new JButton("STEP");

contentPane.add(step);

step.addActionListener(this);

JPanel prog = new JPanel();

prog.setLayout(new GridLayout(10,1));

JTextField[] programtext = new JTextField[10];

for(int i=0;i<programtext.length;i++)

{

programtext= new JTextField(10);

prog.add(programtext);

}

JPanel state = new JPanel();

state.setLayout(new GridLayout(10,1));

JTextField[] statetext = new JTextField[10];

for(int i=0;i<statetext.length;i++)

{

statetext= new JTextField(10);

state.add(statetext);

}

JPanel tape = new JPanel();

tape.setLayout(new GridLayout(10,1));

JTextField[] tapetext = new JTextField[10];

for(int i=0;i<tapetext.length;i++)

{

tapetext= new JTextField(10);

tape.add(tapetext);

}

JPanel contentPane3 = new JPanel();

contentPane3.setBorder(BorderFactory.createEmptyBorder(50, 50, 50, 50));

contentPane3.setLayout(new BorderLayout());

contentPane3.add(state, BorderLayout.CENTER);

contentPane3.add(contentPane, BorderLayout.NORTH);

contentPane3.add(prog, BorderLayout.WEST);

contentPane3.add(tape, BorderLayout.EAST);

setContentPane(contentPane3);

}

public void actionPerformed(ActionEvent e)

{

}

}">

[2438 byte] By [ping.sumita] at [2007-11-26 15:10:01]
# 1

You can learn how to use a JFileChooser here [url=http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html]How to Use File Choosers[/url].

Accessing files from an applet is a problem because of security restrictions. For more on this subject see [url=http://faq.javaranch.com/view?HowCanAnAppletReadFilesOnTheLocalFileSystem]How can an applet read files on the local file system[/url].

crwooda at 2007-7-8 9:00:44 > top of Java-index,Security,Cryptography...