Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Printing the contents of arraylist in JTextArea
Bishawjit Dey
Greenhorn
Posts: 4
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have an arraylist of
string
type and I want to print the contents of that arraylist in a jtextarea using its settext method. but jTextArea only accepts string Objects.
Campbell Ritchie
Marshal
Posts: 79177
377
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Welcome to the Ranch
What about the toString() method?
Bishawjit Dey
Greenhorn
Posts: 4
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thank you
I have my arraylist in a separate class from the gui class and I am trying to set the text in Jtextarea with a method. kind of like this
JTextArea txt = new JTextArea();
txt.setText(cal.returnArray());
returnArray is a method which will return a few variables packed in an ArrayList of string type
I am confused as how I can typecast a method to toString().
Ranganathan Kaliyur Mannar
Bartender
Posts: 1104
10
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
No, he is talking about using the toString() method in the Arraylist.
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Kemal Sokolovic
Bartender
Posts: 825
5
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Something like this should do the work:
// Instead of initializing and populating new ArrayList, you // can use the one you already have ArrayList<String> strings = new ArrayList<String>(); strings.add("one"); strings.add("two"); strings.add("three"); JTextArea text = new JTextArea(); // Iterate over entire ArrayList for(String s : strings) { // Append each string from ArrayList to the end of text in JTextArea // separated by newline text.append(s + System.getProperty("line.separator")); }
The quieter you are, the more you are able to hear.
Is that a spider in your hair? Here, threaten it with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Insertion in JTextArea
display contents of a text file in a new window
How do you set the color of an array List of JTextArea
Printing from JTextArea
JTextArea size increase as size of font increase
More...