wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Printing the contents of arraylist in JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Printing the contents of arraylist in JTextArea" Watch "Printing the contents of arraylist in JTextArea" New topic
Author

Printing the contents of arraylist in JTextArea

Bishawjit Dey
Greenhorn

Joined: Aug 21, 2012
Posts: 4
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
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Welcome to the Ranch
What about the toString() method?
Bishawjit Dey
Greenhorn

Joined: Aug 21, 2012
Posts: 4
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

Joined: Oct 16, 2003
Posts: 1076
    
  10

No, he is talking about using the toString() method in the Arraylist.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Something like this should do the work:


The quieter you are, the more you are able to hear.
 
 
subject: Printing the contents of arraylist in JTextArea
 
Similar Threads
Insertion in JTextArea
How do you set the color of an array List of JTextArea
Printing from JTextArea
display contents of a text file in a new window
JTextArea size increase as size of font increase