i have just learned how to print a text ( not a text file ) in Java, and i also have just learned how to make a program with GUI using AWT and SWING ( i understand only a little bit of those two techniques, just adequate for me to make my program works ). now what i'm trying to do is to make a GUI program that prints an ArrayList's contents when i push a 'PRINT' button. the bottomline of my case is that i need to know how to make a print method with an ArrayList parameter which contents is going to be print. let me simplify more : say i have this program i used to print import java.awt.*;
you will see that i'm printing "text1","text2",etc in a certain position, now i want to replace those texts with caontents from an ArrayList. can somebody give me some hints,codes,links,examples,explanations,or anything that might help? any help would be great thank you very much
Instead of text4 your can use arrayobject.toString(); Which will give you [ array contains, array contains,....] result
Else extend a class from arraylist , and override toString method to get the desired output.
Joined: Feb 16, 2005
oops...i forgot to mentioned that my problem is how to pass the ArrayList object to my print method i used ( which i have wrote on my last posting ) once i can get the Arraylist read inside my print method, the next step step would be more simple. i've tried to do this in my sub class' constructor :
private class IntroPage(ArrayList) implements Printable
as you can see in my coding (on the last posting) i use this IntroPage class to do the printing job and design the result. but when i change its declaration (adding a parameter to it) it doesn't work! the error message was that i need to add a "(" which i assumed i already did. is there any rules on printing in Java that i missed??