aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 38412
    
  23
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing the contents of arraylist in JTextArea