Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

JTable with DATABASE but with custom row numbers

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends;

Good day. I want to add custom row numbers in JTable at first column. Here is my code for update the table from mysql database.



how i fix it?

regards
 
Marshal
Posts: 25436
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So in the JTable, column 0 contains a "custom row number" and the other two columns contain two fields from the database row? It seems to me that given that requirement it shouldn't be too difficult to write the code.

It looks to me like your code which declares the table model to have three columns is mostly okay. But your code which sets up a table row from a database row needs to be fixed to include the custom row number.

Does that help?
 
Hamad Sultan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul;

Please help me with the line of code.

Thanks
 
Paul Clapham
Marshal
Posts: 25436
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What line of code?
 
Hamad Sultan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul;

How i add Row Numbers in first column, The other two column from Database.

I am not good with JTable. Please help me howi fix it?

Regards
 
Paul Clapham
Marshal
Posts: 25436
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here you have some code which puts the columns from the ResultSet into that Vector.

But you want the first entry of the Vector to have a custom row number, and then the subsequent entries to have the column from the ResultSet. So:



That really wasn't that difficult, was it?
 
Hamad Sultan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul;
Great. I am Thankful to you.
Sir now i want a best advise from you on the following matter. My application have 5 categories combo boxes are populate from the database.

Now i am reaching to make a final data entry form. I have two options
1. Use Combo and text boxes on the panel and save the record to the database. By this user insert record to database one by one. If operator needs any category which is not available in respective combo it opens related form and add new category and then back to data entry form and refresh the combo and starts to enter data.
2. But i have an idea if i make a JTable  and add combo boxes in it. Column A,B,C,D,E. Suppose at Row 30 the user need to add an category at Column B Combo , It opens the related category form add it. Now he return to the JTable at row 30 how he refresh the only combo at row 30 while the above 29 values already found ok.

If i refresh the combo with an GUI button then all the combos above line 30 also refresh and selected items are changed.Is there any way to just refresh the specific row combo with update data.

Whats you suggest for me?

I am waiting for your value able suggestion.

Regards
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic