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 9124987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:41:45+00:00 2026-06-17T06:41:45+00:00

Here is a try block which serves the purpose of filtering through table_job to

  • 0

Here is a try block which serves the purpose of filtering through table_job to find rows which match keyword. However, when the table model changes, I am struggling to obtain the correct row index. It always picks the the first row, even though the filtered result shows a row which is not first.

I understand you can do something with fireTableDataChanged(), but I am not sure HOW and WHERE to do this, in the try and catch block OR in the setLabelText() method which displays the content of the table as . JLabel

try 
{
    sql = "SELECT Job.jobID as 'Job ID', Employer.name as'Company', Job.title as 'Role', Job.description as  'Description', Job.type as 'Type', Job.benefits as 'Benefits', Job.closing as 'Closing Date' FROM Job INNER JOIN Employer ON Job.employerID=Employer.employerID ORDER BY Employer.name";
    pst = conn.prepareStatement(sql);
    rs = pst.executeQuery();
    TableModel model = DbUtils.resultSetToTableModel(rs);
    table_job.setModel(model);
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
    table_job.setRowSorter(sorter);               
    searchJob.addActionListener(new ActionListener()
    {

        public void actionPerformed(ActionEvent e) 
        {
            String text = keyword.getText(); 
            if (text.length() == 0) 
            {
                sorter.setRowFilter(null);
            } 
            else 
            {
                sorter.setRowFilter(RowFilter.regexFilter(text));
            }
        }             
    });
}
catch (Exception e) 
{
    e.printStackTrace();                
}

private void setLabelText() 
{
    try 
    {
        String table_click0 = (table_job.getModel().getValueAt(
                row, 0).toString());
        String sqlSt = "SELECT Employer.name, * FROM Job INNER JOIN Employer ON Job.employerID = Employer.employerID WHERE jobID='"+table_click0+"' ";
        //rest of code to Label text...
    }

The String table_click0 = (table_job.getModel().getValueAt(row, 0).toString()); is picking up the wrong row, not the updated selected row. How can I take this into account?

  • 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-17T06:41:47+00:00Added an answer on June 17, 2026 at 6:41 am

    You probably need to convert your “row” value to a model index value (if your row value is retrieved from a “view” point of view), using convertRowIndexToModel. So just replace

    String table_click0 = (table_job.getModel().getValueAt(row, 0).toString());
    

    with

    String table_click0 = table_job.getModel().getValueAt(table_job.
                              convertRowIndexToModel(row), 0).toString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is example which I have try <?php include 'spider/classes/simple_html_dom.php'; $html = new simple_html_dom();
I have a method which contains a try-catch block and I don't know how
This is my first question here so try to make my best so you
As I don't know how to ask it to google, I'll try here. I
Here is my try: IF (NOT WIN32) #INSTALL_TARGETS(${LIB_INSTALL_DIR} ${tinyscheme-nix_BINARY_DIR}/libtinyscheme.so) #INSTALL(TARGETS ${tinyscheme-nix_BINARY_DIR}/libtinyscheme.so DESTINATION ${LIB_INSTALL_DIR}) ENDIF()
Here is my try : #!/Usr/bin/emacs --script (let ((default-directory /home/vision)) (shell-command git pull;) but
Here is my try: @header(Content-type: text/html; charset=utf-8); @header(Location:/index.php); @header(Cache-Control: no-cache, must-revalidate); // HTTP/1.1 @header(Expires:
What is it I am doing wrong here: When I try to use the
Edit: it's hard to describe what I'm trying to do, but here's a try
Ok, i don't know how call it but here i'll try to explain it...

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.