jack1
jack1

Reputation: 11

how to display .txt file in jtext area in netbeans7.0

I created the textarea on the form on which I am working but don't know how to display the contents of text file in jtextArea in netbeans7.0

Upvotes: 1

Views: 912

Answers (3)

Atreys
Atreys

Reputation: 3761

I saw this suggestion on another question earlier: Use the read() method of JTextComponent.

    textArea.read(new FileReader(textFile), "here's a description of the file");

Upvotes: 3

jzd
jzd

Reputation: 23629

If you have a JTextArea, just call setText(String yourText) to populate it.

Also see the tutorial: http://download.oracle.com/javase/tutorial/uiswing/components/textarea.html

Upvotes: 0

Swaranga Sarma
Swaranga Sarma

Reputation: 13413

This has nothing to do with Netbeans 7.0. In Java this is how you set text to a JTextArea:

jTextAreaInstance.setText("myText");

Upvotes: 0

Related Questions