aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea" Watch "JTextArea" New topic
Author

JTextArea

Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Can someone explain to me how I use JTextArea with columns and rows. In the application I am doing right now I need three columns for sure and the rows would have to be x for now, because I prompting the user for a certain amount of information which depending how much information they enter changes the row amount. So can some one give me an example or ideas? If I did not give enough infomation then just let me know. Thank you in advance.
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
anybody know anything about this? For information, I am wrting an application that prompts a user repeadedly until the user enters -999. After that I then use some if else statements to determine some more information. So in the end I will use JOPtionPane and JTextArea to show three columns of information and an unlimited number of rows depending on the information entered by the user. Any ideas?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Hi Holly,

If you need to show data in columns, you should consider using a JTable, which is a spreadsheet-like thing. That's certainly what I would do.

If you have to use JTextArea -- because a school assignment says so, for example -- then your main alternative is just to use TAB ("\t", or ASCII 9) characters to separate the columns -- although unless every datum is the same size, even that's no guarantee everything will line up.


[Jess in Action][AskingGoodQuestions]
Rikki Bostelmann
Greenhorn

Joined: Sep 25, 2004
Posts: 8
Hi Holly,

or you might use a panel holding three different JTextAreas, although
then you might lose the control that the rows match up nicely(?).
Probably the best way is using JTable, as Ernest suggested.

Good luck,
Rikki
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Yeah my assignment tells me to use JOptionPane and JTextArea. I still dont quite understand how I write the code though if I have a dialog box that pops up several times asking a user to input a number, well it pops up until the user tells it to stop by entering -999. How do I know what code to put into the JOptionPane JTextArea box? It's not like I can put x in because its random, there isnt a set number of times a user will enter in information. So I have a random amount of numbers that need to be put into the dialog box at the end. How does that work?
Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
I'm not sure if this will help, but I'll give it a shot anyway.

What if you use an array that stores all of the users inputs and then create the output display with that information. That way you know how many rows you will need to output when the time comes to display the users inputs.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / AWT / SWT / JFace forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea
 
Similar Threads
Invalid column index
Visible column and row count in JTextArea
How to specify JEditorPane initial size ??
How Do I add a vertical scroll bar to a JTextArea?
SQL invalid column index