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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:53:35+00:00 2026-05-16T20:53:35+00:00

I have a master/detail form with a JTable on top, and all the JTextFields

  • 0

I have a master/detail form with a JTable on top, and all the JTextFields corresponding below in the JPanel. I’m trying to make a search in the JTable, so that when the correct row gets picked, all the JTextFields can be filled with the column values. I don’t know how can I call the rows programmatically to do so. How would it be done?

This is the code I’m using to do the search:

int rows = (masterTable.getModel()).getRowCount();
final int colCedula = 1; //columna de la CEDULA
final int colRuc = 11; //columna de RUC
String value = null ;
for(int i=0; i
value = (String) (masterTable.getModel()).getValueAt(i, colCedula);
if (value.equals(this.txt_BuscaCliente.getText())) {
    //CODE FOR FILLING JTEXTFIELDS
}

If the search finds the column value and stops the loop, could I just write in the //CODE section masterTable.getSelectedRow() and then fill all the JTextFields with its column values???

Also, how is it done to have the row selected highlighted, programatically? Let’s say, after my search finds the column value, to have that row highlighted in the JTable

  • 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-05-16T20:53:36+00:00Added an answer on May 16, 2026 at 8:53 pm

    I’d start with the example in the tutorial article How to Use Tables: User Selections in order to understand list selection events. Given a SINGLE_SELECTION model, you won’t have to search; just fill in the text fields from the selected row. Alternatively, you can make the cells editable in your table model, and you won’t have to copy them at all.

    Addendum:

    Also, how is it done to have the row selected highlighted, programatically?

    Instead of searching, let your implementation of ListSelectionListener tell you what selection has been made by the user. In the example cited, modify the RowListener as shown below to iterate through the columns in the selected row.

    private class RowListener implements ListSelectionListener {
    
        @Override
        public void valueChanged(ListSelectionEvent event) {
            if (!event.getValueIsAdjusting()) {
                for (int c : table.getSelectedRows()) {
                    int row = table.convertRowIndexToModel(c);
                    TableModel model = table.getModel();
                    for (int col = 0; col < model.getRowCount(); col++) {
                        System.out.println(model.getValueAt(row, col));
                    }
                    System.out.println();
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a form that needs to show data from 2 tables (parent
I'm trying to create a kind of master/detail UI using an MVP pattern. I
I have 2 domains .. master and details. Master{ String masterName; static hasMany=[details:Detail] }
I want to show a master / detail relationship using two datagridviews and DataRelation
I have a basic test web form with a DataList and a DetailsView and
The Master grid is Customers and the Detail grid is a Customers Orders. Using
i have this problem that has been buggin me for the last hours. Lets
Since beginning to use VB.NET some years ago I have become slowly familiar with
I am having a WPF dataentry form which has got 3 comboboxes which needs
I am creating an application using WPF which is using Prism framework. I have

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.