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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:22:57+00:00 2026-06-03T05:22:57+00:00

I created a function which loads data into a JTable . Everything’s working fine

  • 0

I created a function which loads data into a JTable. Everything’s working fine except that all the cells in this table are editable. Btw, I used defaultTableModel for the table model. Im doing this in Netbeans IDE. Please help. Here’s my code:

private void updateTable(String searchText){

    if(searchText != null)
        this._sqlCmd = this._sqlCmd + " WHERE "+columnCombo.getSelectedItem()+" LIKE '%"+searchText+"%'";
    jTable1.setSurrendersFocusOnKeystroke(true);
    table = (javax.swing.table.DefaultTableModel) jTable1.getModel();  

    try{
        table.setRowCount(0);
    }catch(Exception e){}

    try {
        ResultSet rs = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY).executeQuery(_sqlCmd);
        while (rs.next()){
            Object[] data = new Object[numOfCols];
            for(int i=0; i<data.length; i++){
                data[i] = rs.getObject(i+1);
            }
            table.addRow(data);
        }
        table.fireTableDataChanged();


    } catch (SQLException ex) {
        Logger.getLogger(FindContactGrid.class.getName()).log(Level.SEVERE, null, ex);
    } 
}
  • 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-03T05:22:59+00:00Added an answer on June 3, 2026 at 5:22 am
     private TableModel model = new DefaultTableModel(data, columnNames)
      {
        public boolean isCellEditable(int row, int column)
        {
          return false;//This causes all cells to be not editable
        }
      };
      private JTable table = new JTable(model);
    

    Edited.
    If you are doing this in Netbeans IDE designer, follow the steps below:

    • Select the form on which the JTable is placed
    • From the Navigation Pane, expand JScrollPane and right-click on JTable and Select Customize Code as shown below:

    Navigator Pane

    • On the code customizer, select the second drop down and choose custom property. This enables you to edit the DefaultTableModel code definition.
    • Now paste this:
      {public boolean isCellEditable(int row, int column){return false;}} before the last closing blacket );

    Your final setup should look as shown below:

    • Press ok to save – and job done.

    Code Customizer

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

Sidebar

Related Questions

I have created a add input field function which is working fine. I would
I have created a JS function which executes fine when it's included an the
I created a header file called ofdm.h which includes all the function prototypes. Then
Im trying to load a page I created using ajax, which loads fine and
I created webservice which contain Add function as 'webmethod' when we want to deploy
I created a sample webservice which contain default 'HelloWorld' function as 'webmethod' when tried
Firstly I created a collection which is Collection list; and in a function RSS
We are building an app (WinForms, .NET 3.5) that loads Plugin DLLs into a
I have an XML file containing seed data that I'm trying to load into
I am trying to re-load data into the Store which is further used by

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.