file contents in jtextarea

i have the following program but i need to edit it in order to open the text file and display its contents in a jtextarea anyone know what i have done wrong so far and what i need to change

import java.io.*;

import java.awt.*;

import javax.swing.*;

//this is a cprogram i have created so the users data entered into my main program can be read in a text file

class cdetailreader extends JFrame

{

JTextArea read1 = new JTextArea();

public TextAreadetails() {

read1.setText();

JScrollPane scrollingArea = new JScrollPane(_ta); //viewport in here

JPanel tpanel = new JPanel();

// tpanel.add("cdetails.txt");

tpanel.setLayout(new BorderLayout());

tpanel.add(scrollingArea, BorderLayout.CENTER);

TextAreadetails.getContentPane().add(tpanel);

this.pack();

JFrame td = new TextAreadetails();

td.setvisible(true);

}

public static void main (String args[])

{

int input;

try

{

// I have created a filereader to read the contents of the text file i created to hold customer data

// In my main program i named the text file to store customer details cdetails.txt

FileReader readcdetails = new FileReader("cdetails.txt");

input = readcdetails.read();

while (input >=0)

{

System.out.print ((char) input(TextAreadetails));

input = readcdetails.read();

}

}

catch(Exception e){

System.out.println("File does not exist"+e);

}

}

}

[1554 byte] By [jonathanca] at [2007-11-27 11:57:28]
# 1

sorry

import java.io.*;

import java.awt.*;

import javax.swing.*;

//this is a cprogram i have created so the users data entered into my main program can be read in a text file

class cdetailreader extends JFrame

{

JTextArea read1 = new JTextArea();

public TextAreadetails() {

read1.setText();

JScrollPane scrollingArea = new JScrollPane(_ta); //viewport in here

JPanel tpanel = new JPanel();

// tpanel.add("cdetails.txt");

tpanel.setLayout(new BorderLayout());

tpanel.add(scrollingArea, BorderLayout.CENTER);

TextAreadetails.getContentPane().add(tpanel);

this.pack();

JFrame td = new TextAreadetails();

td.setvisible(true);

}

public static void main (String args[])

{

int input;

try

{

// I have created a filereader to read the contents of the text file i created to hold customer data

// In my main program i named the text file to store customer details cdetails.txt

FileReader readcdetails = new FileReader("cdetails.txt");

input = readcdetails.read();

while (input >=0)

{

System.out.print ((char) input(TextAreadetails));

input = readcdetails.read();

}

}

catch(Exception e){

System.out.println("File does not exist"+e);

}

}

}

jonathanca at 2007-7-29 19:14:06 > top of Java-index,Desktop,Core GUI APIs...
# 2

As I told you in your last posting there are methods that allow you to read a text file into a JTextArea and write the text from a JTextArea to a file. All you need to do is read the API.

camickra at 2007-7-29 19:14:06 > top of Java-index,Desktop,Core GUI APIs...