Forum Stats

  • 3,872,511 Users
  • 2,266,437 Discussions
  • 7,911,236 Comments

Discussions

cannot resolve symbol error

800328
800328 Member Posts: 248
the program is showing an error .....
cannot resolve symbol......
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.*;
import javax.swing.filechooser.*;
import java.io.*;


public class tm extends JApplet implements ActionListener{
File fileName;
String[] data;
int numLines;
private BufferedReader fileInput;
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 event) {
if (event.getActionCommand().equals("loadp")) getFileName();
}

private void getFileName() {
// Display file dialog so user can select file to open
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

int result = fileChooser.showOpenDialog(this);

// If cancel button selected return
if (result == JFileChooser.CANCEL_OPTION) return;

// Obtain selected file

fileName = fileChooser.getSelectedFile();
}

private void readFile() {
// Dimension data structure
getNumberOfLines();
data = new String[numLines];

// Read file
readTheFile();

// Output to text area
programtext[0].setText(data[0] + "\n");
for(int index=1;index >< data.length;index++)
programtext[index].append(data[index] + "\n");
}

private void getNumberOfLines() {
int counter = 0;

// Open the file
openFile();

// Loop through file incrementing counter
try {
String line = fileInput.readLine();
while (line != null) {
counter++;
System.out.println("(" + counter + ") " + line);
line = fileInput.readLine();
}
numLines = counter;
closeFile();
}
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error reading File",
"Error 5: ",JOptionPane.ERROR_MESSAGE);
closeFile();
System.exit(1);
}
}


private void readTheFile() {
// Open the file
openFile();
System.out.println("Read the file");
// Loop through file incrementing counter
try {
for (int index=0;index < data.length;index++) {
data[index] = fileInput.readLine();
System.out.println(data[index]);
}
closeFile();
}
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error reading File",
"Error 5: ",JOptionPane.ERROR_MESSAGE);
closeFile();
System.exit(1);
}
}

private void openFile() {
try {
// Open file
FileReader file = new FileReader(fileName);
fileInput = new BufferedReader(file);
}
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error Opening File",
"Error 4: ",JOptionPane.ERROR_MESSAGE);
}
System.out.println("File opened");
}

/* CLOSE FILE */

private void closeFile() {
if (fileInput != null) {
try {
fileInput.close();
}
catch (IOException ioException) {
JOptionPane.showMessageDialog(this,"Error Opening File",
"Error 4: ",JOptionPane.ERROR_MESSAGE);
}
}
System.out.println("File closed");
}


} "

Comments

This discussion has been closed.