Adding a String to a JScrollPane

A

Allan Bruce

I want to know how to add a String to a JScrollPane?
I have a String which is changing and I want to display it in a JScrollPane.
I know how to do it in the constructor of the JScrollPane but this is no use
because it is changing. Also, is there a way to make it automatically
display the correct umber of rows/colums in the String, to save me writing
my own code?

Thanks
Allan
 
A

Alex Hunsley

Allan said:
I want to know how to add a String to a JScrollPane?
I have a String which is changing and I want to display it in a JScrollPane.
I know how to do it in the constructor of the JScrollPane but this is no use
because it is changing. Also, is there a way to make it automatically
display the correct umber of rows/colums in the String, to save me writing
my own code?

Thanks
Allan

Please don't multipost. It makes life more complicated for all concerned.

http://www.blakjak.demon.co.uk/mul_crss.htm

Also, your question would have been suitable for just comp.lang.java.help.

alex
 
A

Andrew Thompson

Allan Bruce said:
I want to know how to add a String to a JScrollPane?
I have a String which is changing and I want to display it in a JScrollPane.
I know how to do it in the constructor of the JScrollPane but this is no use
because it is changing.

...errr, what? No JScrollPane constructor takes
a String, try Component, like JTextArea, JPanel,
JTable...
Also, is there a way to make it automatically
display the correct umber of rows/colums in the String, to save me writing
my own code?

Which API docs are you reading?
 
T

Thomas Weidenfeller

Allan said:
I want to know how to add a String to a JScrollPane?

A scroll pane does not scroll/display Strings. It displays other
components. To display a string you have to add a component to the
scroll pane which is intended to display strings. E.g. a JTextArea.
I have a String which is changing and I want to display it in a JScrollPane.
I know how to do it in the constructor of the JScrollPane but this is no use
because it is changing.

Nonsense. Once you have set the mentioned other component, you change
these other component's content, and not the scroll pane's viewport.
content.

I would strongly suggest you work through

http://java.sun.com/j2se/1.4.2/docs/api/index.html

/Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top