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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:21:09+00:00 2026-05-26T17:21:09+00:00

I have a table model. I want to delete a row from a table.

  • 0

I have a table model. I want to delete a row from a table. I am not able to find the model.removeRow method. Can someone tell he how to remove a row? Below is the code for the model.

class TableModel extends AbstractTableModel {
private Object[][] data;
private String[] columnNames;

public TableModel(Object[][] data) {
    this.data = data;
    columnNames=new String[1];
    columnNames[0]="Data";
}

public int getRowCount() {
    return data.length;
}

public int getColumnCount() {
    return columnNames.length;
}

public Object getValueAt(int rowIndex, int columnIndex) {
    return data[rowIndex][columnIndex];
}

public Class getColumnClass(int c) {
    return String.class;
}

public boolean isCellEditable(int rowIndes, int columnIndex) {
    return false;
}

public String getColumnName(int index) {
    return columnNames[index];
}

public void setValueAt(Object value, int rowIndex, int columnIndex) {
    data[rowIndex][columnIndex] = value;
    fireTableCellUpdated(rowIndex, columnIndex);
}

}

  • 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-26T17:21:10+00:00Added an answer on May 26, 2026 at 5:21 pm

    Kaushik, if you really want to make your own implementation of the TableModel interface and deal with the storage of rows manually (as you obviously do by using Object[][] data), then you must implement the removeRow() method because abstract table model does not “know” how to do it. removeRow() will have to fireTableRowsDeleted() at the end…

    A good alternative is to refactor your class and make it extend the DefaultTableModel.

    Another suggestion – since table model changes a lot, a dynamic array may be a bad choice for storage because you must either reallocate space every time you add a row (bad), or you preallocate enough space for certain number of rows, then whenever there is no enough space you allocate new Object[][] with some extra space (for next N rows). Typically people allocate enough space for 2^n rows during the reallocation process.

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

Sidebar

Related Questions

I have a delete button in each row of GridView (component ASP.NET). I want
I have to write a Stored Procedure to delete record from a table. I
I have a table where i want to be to both select a row
I want to be able to select a row in a table (which represents
I have the following multi-table inheritance situation: from django.db import Models class Partner(models.Model): #
I've got a model in CakePHP that doesn't have a table, called Upload. I've
Suppose I have an Orders table in my database and a corresponding model class
I have a problem. Imagine this data model: [Person] table has: PersonId, Name1 [Tag]
I have a simple model called Party with a corresponding table called parties .
I have a Django model with a large number of fields and 20000+ table

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.