*
The moose likes Swing / AWT / SWT and the fly likes Recommendation for Collecting double [][] from user input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Recommendation for Collecting double [][] from user input" Watch "Recommendation for Collecting double [][] from user input" New topic
Author

Recommendation for Collecting double [][] from user input

Adam Price
Ranch Hand

Joined: Nov 11, 2005
Posts: 95
I am building a GUI to lay over a script that I have already written for calculating some chemistry "stuff."

The crucial input is a list of solutes with a few associated parameters. Like so


The whole point of the GUI s to collect this information from the user, run a few calculations and return a formatted text list.

The code as shown has 3 rows (solutes). Users may want to run the script with from 2-8 solutes. I would like some sort of interface that displays the parameters a little more clearly than the form above.

I have been thinking about using a jTable (the rest of the GUI is swing-based) but I can't figure out how to get the contents back from it. Is jTable the way to go? If not, what is? If so, how to I get that user input out?


Thanks,

Adam
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yes, JTable would be a good starting point. You get the data from its table model once the user clicks the "OK" button or whatever they do to indicate they have finished inputting the data.
Adam Price
Ranch Hand

Joined: Nov 11, 2005
Posts: 95
Paul Clapham wrote:Yes, JTable would be a good starting point. You get the data from its table model once the user clicks the "OK" button or whatever they do to indicate they have finished inputting the data.


What is the method call for that? I found all the .getComponent methods, and all the methods for getting information about what is currently being edited (row#, col#, etc) but not for the cell contents.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The method for getting a value from the table model is simply getValueAt(row, column).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Also, use a TableModel that returns Double.class in getColumnClass. That way, your JTable will handle the parsing and conversion from String to Double.

I think How To Use Tables will be a good read for you.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Recommendation for Collecting double [][] from user input
 
Similar Threads
probem with populating JTable
Dynamic JTable
Problem with JTable
JTable
getValueAt in JTable