Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7781667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:18:05+00:00 2026-06-01T19:18:05+00:00

I have a JTable which is connected to sqlite. The db table looks like

  • 0

I have a JTable which is connected to sqlite. The db table looks like this:

 resource_id #primary_key, file, type

I have already implemented adding the rows from db, but the problem is i need to know the resource id when some row in jTable is selected (not the index). Is there a way to add rows with unique ids and not based on indexes (or something similar)?

The current solution adds the resource id as a table column, but that doesnt solve the problem completely.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:18:07+00:00Added an answer on June 1, 2026 at 7:18 pm

    Create a class say TableData that contains the data from the table. Use a custom TableModel and place the data for the JTable in Vector<TableData>.

    You may find it useful to create a method such as addRow(TableData data) in your TableModel that process the data from the table and adds data to the Vector.

    In the overridden method public removeRow(int row) you will need to remove the vector data where row can serve as the index.

    The overridden method public Object getValueAt(int row, int col) which is used to display the data in the JTable will then just need to retrieve the data from the Vector<TableData>. You can also place the logic for other columns which not part of the TableData in this method.

    Dont forget to call fireTableRowsUpdated(row,col) and fireTableCellUpdated(row,col) where ever applicable.

    For further reference and how to handling the selections in JTable you can refer this tutorial

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Jtable on which I called the method table1.setAutoCreateRowSorter(true); . So this
I have the following JTable which uses a table model: http://s17.postimage.org/7zfh3l4lr/Screen_Shot_2012_03_10_at_15_11_31.png Instead of using,
I have a JTable and a TableRowSorter which I'd like to perform an operation
We have a Java Swing application which contains components like JTable, JCombobox, JTextArea and
I have a jTable which currently displays and allows editing of a database table,
In Java Swing I have created a JTable which uses a table model class
I have a standalone application in which I have a Jtable. In my table,
I have JTable which elements property binded to List of objects, this is master
I have a JTable for which I have made a table model. But on
I have a JTable which is loaded from a data-structure using table model.The data-structure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.