Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

array required but java.lang.string found

800328Jan 16 2007
here is my code.....can anybody tell me whats wrong at line 272



at line 272 there are two errors
array required but java.lang.string found
cannot find symbol method split(java.lang.string.string,int)

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;
 
public class tm extends JFrame implements ActionListener
{
	
	
	public JTextField[] programtext = new JTextField[30];
	public JTextField[] tapetext = new JTextField[30];
	public JTextField[] statetext = new JTextField[30];
	int count =0;
	public static void 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= 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);


}

public void 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;
}

}
catch (Exception p)
{
System.out.println(p);
}
}

}



else if(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);
}
}

}





else if(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);
}
}



}



else if(e.getSource()==run)
{


String instr;
String pars[] = new String[5];
for(int m = 0;m<count; count++)
{
for(int k=0;k<5;k++){

pars[m][k] = programtext[m].split(" ",0);





}






}

}


else if(e.getSource()==step)
{

}










}
catch(Exception t)
{
System.out.println(t);
}

}



}




Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 13 2007
Added on Jan 16 2007
0 comments
340 views