• 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

JTextArea

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Swing / AWT / SWT / JFace forum...
 
reply
    Bookmark Topic Watch Topic
  • New Topic