954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Jtext area

HI
I am working on a java application using netbeans,
I face a porblem.
I want to display the output of my program, on jtextarea
(i have designed a jtextarea,) just I want to display the output
namely the content of an array.
plz can anyone help?

f.damati
Light Poster
28 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

Use JTextArea methods append(String str) or setText(String str). Nothing big.

Zibo
Light Poster
41 posts since May 2009
Reputation Points: 12
Solved Threads: 3
 

I know the methods, but when i use them they throws java.lang.NullPointerException

f.damati
Light Poster
28 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

Then show this piece of code where You created JTextArea and want to append some text.

Zibo
Light Poster
41 posts since May 2009
Reputation Points: 12
Solved Threads: 3
 
I know the methods, but when i use them they throws java.lang.NullPointerException

You get that exception because you haven't initialized the objects. You have create something with "new" in order to use it.

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

thank you, i initialize an object but another problem appears which is the text area doesn't show anything it is empty

f.damati
Light Poster
28 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

post relevant code

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

Basically displaying text on jTextArea is not a difficult thing to do. Maybe there is a minute error to be fixed. Pls post your code so that we can check it!

bluerose
Newbie Poster
17 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
 

@bluerose

I think javaAddict conveyed that same point with his post. Please don't repeat people for the sake of posting (unless you're adding something to the discussion), otherwise, you'll become like adatapost.

BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
 

Sorry...thanx for reminding that. I posted that coz i missed that #7 post by javaAddict. I just noticed that when u said now. If i had seen that earlier i wouldn't have posted what i have posted. M not an echoer. However thx!

bluerose
Newbie Poster
17 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
 

class cluster{
public Cluster(int i, String name){
cName = name;
featureNumber[0] = i;
for(int c=0;c<7;c++)
clustElement[i][c]=ygenes[i][c];
}

public void print(Cluster cl, javax.swing.JTextArea a){
System.out.println(cl.cName + "has " + cl.n + "Features:");
for (int r=0;r

f.damati
Light Poster
28 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

Where do instantiate the JTextArea? It should be somewhere were is "visible"(not out of scope) form your main. Also if you want it to be displayed you need to attach it to a JPanel, the JPanel to a JFrame and then you need to instantiate the JFrame and set it to be visible. JTextArea will not be displayed no its own

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You