How to bind JTable and data in a text file ?

R

RedGrittyBrick

tobleron said:
What I want to do is :

1. Open the text file, extract the values.
2. Construct the JTable using those values, including rows and columns
values.
3. Add select option in each row, so user can select which record will
be processed.
4. Add "OK" button to process each selected records.

I hope you understand what I'm figuring out.

Points 1, 2 and 3 are handled by the working program I posted in this
thread earlier:
<http://groups.google.com/group/comp.lang.java.programmer/msg/5416a54b511eb2a6>

For point 4, I'd add a JButton and an ActionListener,
I'd add a `getID(int row)` method to TextFileModel,
create a method `process(ID id) in FileTable
and call it in the ActionListener:
processID(model.getID(table.getSelectedRow()))
 
L

Lew

tobleron said:
2. As I mentioned, NetBeans didn't allow me to edit its generated
code, so I copied the whole code, opened a new blank java file,
pasted it, and tried to modify it.

That isn't necessary. NetBeans's form-based development is perfectly capable
of modification outside the guarded section to accomplish any desired effect.
 
L

Lew

It is impolite not to attribute quotes:
I used a text file to stored the data. So, I tried to opened the text
file, extracted the values, and looped until the end. I tried to
constructed the JTable with this values. That's what I tried to do.

This doesn't explain why you tried to construct, at run time, a fragment of
(syntactically incorrect) source code in a String. The question was why you
tried that particular idiom, not what your overall goal was.
 
L

Lew

tobleron said:
Don't be confused with /* .... */ code. That was the original NetBeans
code that I tried to modify.

It is best to remove commented-out code and other potentially confusing
elements from Usenet code samples. It is not enough to instruct those from
whom you request assistance to overlook your failure to do so.
 
N

Nigel Wade

Lew said:
That isn't necessary. NetBeans's form-based development is perfectly capable
of modification outside the guarded section to accomplish any desired effect.

and within the guarded section custom code can be inserted using the "Code" tab
of the Properties window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top