Use of Jtable

Asked

Viewed 74 times

0

I’m new in the subject and so I’m already taking some courses in the area, but while I’m not getting good, I’m having many doubts.

First excuse not posting a part of the code, but the company I work is all blocked and I’m asking this question from my personal computer at home...

But come on, I hope I’m clear on the doubt.

I need to know if it is possible to set a line in Jtable.

Ex: On the line will be marking your information Food (Rice).

Doubt: I can get this information from Jtable and start the program with the selected line?

Imagem simples de exemplo

1 answer

0

Good afternoon to you, Edi. I think that the question was not very clear, perhaps because of that it had few answers. I’ll try to help you with what I understand, any questions, feel free to comment that I try to tailor the answer to your need. About the "I need to know if it is possible to set a line in Jtable.". Yes, it is possible. About the question "Can I get this information from Jtable and when starting the program already come with the selected line?" , the answer is: yes, but some things will need to be prepared for this.

From what I understand, you will have a table where the food will not be repeated, so once the food line "Rice" is selected, you want to start the program next time with the rice line marked as before. To store this information you will need to store it somewhere, it may be a property file or in a database. Choose to use the same storage you already use to store your data. The only information you need to store is the food, as you described, however, a suggestion from me is that you use the ID, because theoretically the ID will not be repeated, already the food, could be repeated. By storing this information, search it when starting the program and use some form to perform the search in the table. As soon as you find the desired line, use the method setRowSelectionInterval( i, i ); to determine the line to be selected. The variable your table must contain the same name you created for the table and the i is the line you rescued when you searched. If you have any questions with this answer, or would like to add some information, feel free to comment. Hugs and good luck.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.