identifier expected error

here is the code .....it is showing error in line 18 and 20 as identifier expected

their i am trying to make JTextField editable....

plz have a look

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import javax.swing.*;

import javax.swing.filechooser.*;

import javax.swing.SwingUtilities.*;

import javax.swing.filechooser.FileFilter;

//import javax.swing.JEditorPane;

import java.net.URL;

publicclass tmextends JFrameimplements ActionListener

{

public JTextField[] programtext =new JTextField[30];

public JTextField[] tapetext =new JTextField[30];

tapetext.setEditable(true);

public JTextField[] statetext =new JTextField[30];

statetext.setEditable(true);

int count =0;

publicstaticvoid main (String arg[]){

tm m=new tm();

m.setSize(1000,500);

m.show();

}

JButton loadp, run, step,loadi,loads;

public tm()

{

Container c ;

c = getContentPane();

c.setLayout(new FlowLayout());

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

c.add(loadi);

loadi.addActionListener(this);

loadi.setBounds(200,25,100,50);

loadp =new JButton("LOAD PROGRAM");

c.add(loadp);

loadp.addActionListener(this);

loadp.setBounds(300,25,100,50);

run =new JButton("RUN");

c.add(run);

run.addActionListener (this);

run.setBounds(400,25,100,50);

step =new JButton("STEP");

c.add(step);

step.addActionListener(this);

step.setBounds(500,25,100,50);

loads =new JButton("LOAD STATES");

c.add(loads);

loads.addActionListener(this);

loads.setBounds(600,25,100,50);

JPanel prog =new JPanel();

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

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

{

programtext[i]=new JTextField(10);

prog.add(programtext[i]);

}

JPanel tape =new JPanel();

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

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

{

tapetext[i]=new JTextField(10);

tape.add(tapetext[i]);

}

JPanel state =new JPanel();

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

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

{

statetext[i]=new JTextField(10);

state.add(statetext[i]);

}

JPanel contentPane3 =new JPanel();

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

contentPane3.setLayout(new BorderLayout());

contentPane3.add(state, BorderLayout.CENTER);

contentPane3.add(c, BorderLayout.NORTH);

contentPane3.add(prog, BorderLayout.WEST);

contentPane3.add(tape, BorderLayout.EAST);

setContentPane(contentPane3);

}

publicvoid actionPerformed(ActionEvent e)

{

try{

if(e.getSource ()==loadp)

{

JFileChooser chooser=new JFileChooser();

int r= chooser.showOpenDialog(this);

if(r==JFileChooser.APPROVE_OPTION )

{

String name=chooser.getSelectedFile().getName();

File f=chooser.getSelectedFile();

FileInputStream filestream =new FileInputStream(f);

BufferedInputStream bufferstream =new BufferedInputStream(filestream);

DataInputStream datastream =new DataInputStream(bufferstream);

String record =null;

programtext[0].setText("");

try{

int i = 0;

while (true)

{

record=datastream.readLine();

if(record ==null){

break;

}

programtext[i].setText(record);

i++;

count = count + 1;

}

System.out.println ("the no of lines of the program are"+ count);

}

catch (Exception p)

{

System.out.println(p);

}

}

}

elseif(e.getSource()==loads)

{

JFileChooser chooser3=new JFileChooser();

int r3= chooser3.showOpenDialog(this);

if(r3==JFileChooser.APPROVE_OPTION)

{

String name=chooser3.getSelectedFile ().getName();

File f3=chooser3.getSelectedFile();

FileInputStream filestream3 =new FileInputStream(f3);

BufferedInputStream bufferstream3 =new BufferedInputStream(filestream3);

DataInputStream datastream3 =new DataInputStream(bufferstream3);

String record3 =null;

statetext[0].setText("");

try{

int i = 0;

while (true)

{

record3=datastream3.readLine();

if(record3 ==null){

break;

}

statetext[i].setText(record3);

i++;

}

}

catch (Exception p3)

{

System.out.println(p3);

}

}

}

elseif(e.getSource()==loadi)

{

JFileChooser chooser2=new JFileChooser();

int r2= chooser2.showOpenDialog(this);

if(r2==JFileChooser.APPROVE_OPTION )

{

String name=chooser2.getSelectedFile().getName();

File f2=chooser2.getSelectedFile();

FileInputStream filestream2 =new FileInputStream(f2);

BufferedInputStream bufferstream2 =new BufferedInputStream(filestream2);

DataInputStream datastream2 =new DataInputStream(bufferstream2);

String record2 =null;

tapetext[0].setText("");

try{

int i = 0;

while (true)

{

record2=datastream2.readLine();

if(record2 ==null){

break;

}

tapetext[i].setText(record2);

i++;

}

}

catch (Exception p2)

{

System.out.println(p2);

}

}

}

elseif(e.getSource ()==run)

{

String temp="";

String statetemp=" ";

String tapetemp=" ";

int l=0;

int tp=0;

String pars[][] =new String[50][5];

for(int m=0;m<count;m++){

temp = programtext[m].getText();

String str[]=temp.split(" ");

for(int k=0;k<5;k++){

pars[m][k] =str[k];

System.out.println(pars[m][k]);

}

statetemp = statetext[0].getText();

tapetemp = tapetext[l].getText();

while(pars[tp][0]==statetemp && pars[tp][1]==tapetemp && tp><count)

{

statetemp = pars[tp][2];

tapetemp = pars[tp][3];

statetext[0].setText() = statetemp;

tapetext[tp].setText() = tapetemp;

if(pars[tp][4]=="R")

{

l=l+1;

}

else{

l=l-1;

}

tp++;

}

}

}

elseif(e.getSource()==step)

{

}

}

catch(Exception t)

{

System.out.println(t);

}

}

}

>

[12838 byte] By [ping.sumita] at [2007-11-26 15:19:52]
# 1
I don't think you can call a method of JTextField on an instance of JTextField[]. You'll have to loop through your array and call setEditable() on each of the JTextFields in the array on turn.
Peetzorea at 2007-7-8 11:46:43 > top of Java-index,Java Essentials,New To Java...
# 2

Hi,

No, you are trying to make an array of textfields editable. You should call editable on the elements in the array, and not on the array (but don't bother about it, they are editable from the beginning, and all your textfields in the array are null since you haven't created them)

Kaj

kajbja at 2007-7-8 11:46:43 > top of Java-index,Java Essentials,New To Java...
# 3
If you define the array as public JTextField[] tapetext = new JTextField[30];Doesn't this create 30 non-null JTextField objects in the array?
Peetzorea at 2007-7-8 11:46:43 > top of Java-index,Java Essentials,New To Java...
# 4

> If you define the array as public JTextField[]

> tapetext = new JTextField[30];

>

Doesn't this create 30 non-null JTextField

> objects in the array?

Sorry, no it doesn't it creates an empty array. (All nulls)

kajbja at 2007-7-8 11:46:43 > top of Java-index,Java Essentials,New To Java...
# 5
You're right!
Peetzorea at 2007-7-8 11:46:43 > top of Java-index,Java Essentials,New To Java...