• 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

Java text fields to 2D array

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having an issue populating a 2D array from textfields. The GUI has 2 buttons and 2 textfields. Everytime the enter button is pushed it should store the values in the 2 text fields into the array. When the report button is pushed it should output all the values in the array to a textarea. The end result should be a 2D array with 2 columns and unlimited rows that stores the values until the report button is pushed. Any help would be greatly appreciated.

 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

terrence mann wrote:I'm having an issue populating a 2D array from textfields.


And what exactly is that issue?

By the way, if you enclose your code in the "Code" tags (see that "Code" button above the box where you post?) then your code will show up nicely and people will be more likely to read it. I have to admit that I didn't read your code, but then you didn't ask a question about it.
 
terrence mann
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul I appreciate the quick response and apologize for the horrible code post. The issue that I am having with this code is that whenever I click the enter button it doesn't add the value to the array and add a new row. it just writes the value in [0][0] and [0][1] again. I need it to write the value in the text boxes to the array. Then the next time the enter button is clicked add the values in the text boxes to the next row in the array. Thanks again for your quick response.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a new row? To that double [][] tutorArray? It isn't possible to add rows to an array. You could make a new array with one more row, and copy over the existing data from the old array to the new array, but I would advise using some data structure which is less unsuitable.

And you seem to have the Swing aspects working okay, right? You click on the button and it updates the array? Then this isn't really a Swing question. Unless it's a question about how to display that array in Swing... right now you're just trying to update it, but later you might want to display it somehow. And if that was a requirement, it would lead to an answer about the suitable data structure.
 
reply
    Bookmark Topic Watch Topic
  • New Topic