JTextArea or JTextPane

hai forum,Plz help me find a solution to this simple problem.I have to dispaly dynamic method invocation results inside a Jscrollpane.Which one is more advisable JTextArea or JTextPane to be used inside the scroll pane?thank you all.
[261 byte] By [divyabhaskarana] at [2007-10-3 1:04:07]
# 1

> I have to dispaly dynamic method invocation results

> inside a Jscrollpane.Which one is more advisable

> JTextArea or JTextPane to be used inside the scroll

> pane?

Depends on your requirements. Is plain text okay or do you need any styled text as well? If the latter, use JTextPane.

CeciNEstPasUnProgrammeura at 2007-7-14 18:00:25 > top of Java-index,Java Essentials,New To Java...
# 2

Thank you.

finally i used JTextArea to display my results.

But no TextArea is being displayed ,not only that the whole contentpane is going blank.I am doing this in JDeveloper.

I have used this code.Please tel me what went wrong.

JTextArea resultArea=new JTextArea();

resultArea.setBounds(new Rectangle(290, 225, 455, 260));

resultArea.setBorder(BorderFactory.createTitledBorder("METHOD INVOCATION RESULT"));

resultArea.setEditable(false);

resultArea.setLineWrap(true);

resultArea.setRows(100);

c.add(resultArea, null);//Add to contentPane

resultArea.setDocument(new PlainDocument());

......................

....................

Object result = method.invoke(instance, parameters);

String r=(String)result;

resultArea.setText(r);

scrollPane.getViewport().add(resultArea,null);

.................

.....................................

Thank you

divyabhaskarana at 2007-7-14 18:00:25 > top of Java-index,Java Essentials,New To Java...
# 3

Why do you explicitly call setDocument() on resultArea? Isn't it enough to

call resultArea.setText() when you have some content?

You add the result Area to a thing called "c", then later you add it to something

that is probably a JViewport. Perhaps you don't make this latter component

visible.

In any case, perhaps you could post some brief compiliable code that

illustrates your problem. (The act of making the code a manageable size

will help you focus on what the problem actually is).

pbrockway2a at 2007-7-14 18:00:25 > top of Java-index,Java Essentials,New To Java...