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

  • Home
  • SEARCH
  • 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 4034370
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:57:49+00:00 2026-05-20T11:57:49+00:00

I have a JTable that is populated using a custom TableModel I created. I

  • 0

I have a JTable that is populated using a custom TableModel I created. I have another JTable that rows can be added to from the first JTable. I can add the row to the new JTable no problem, but I need to remove that row from the first JTable upon adding it to the new JTable. Unfortunately removeRow() is only a method for DefaultTableModel, and I’ve checked the source code on that and it doesn’t show up…

Thanks in advance!

here’s my custom table model:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ttp;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.*;
import java.util.*;

/**
 *
 * @author ericrea
 */

/**creates the model for the accounts table*/
public class tableModel extends AbstractTableModel {

    //private int rowCount = 0;
    private static final int COLUMN_COUNT = 3;
    private Conceptual_Package pp;
    Conceptual_Package j = GUIpos.i;



    public tableModel(Conceptual_Package pp) {
        this.pp = pp;

    }

    /**sets the column headers*/
    public String getColumnName(int i){
        switch (i) {
            case 0:
                return "Sec";
            case 1:
                return "Row";
            case 2:
                return "Seat";
            default:
                return null;
        }
    }

    /**figures out how many rows the model needs*/
    public int getRowCount() {
        int h = 0;
        try {
            h = Physical_PackageDAO.getInstance().getByConceptual_Package(j.getId()).size();
        } catch (DataException ex) {
            Logger.getLogger(tableModel.class.getName()).log(Level.SEVERE, null, ex);
        }

        return h;
    }

    /**Figures out number of columns*/
    public int getColumnCount() {
        return COLUMN_COUNT;

    }

    /**gets the account information from the Physical_Package*/
    public Object getValueAt(int rowIndex, int columnIndex) {
        String a = null;
        String b = null;
        String c = null;

        try {
            Physical_Package pp = Physical_PackageDAO.getInstance().getByConceptual_Package(j.getId()).get(rowIndex);
            a = pp.getVenueSeat().getRowInVenue().getSectionInVenue().getSectionNumber();
            b = pp.getVenueSeat().getRowInVenue().getRowNumber();
            c = pp.getVenueSeat().getSeatNumber();

            } catch (DataException ex) {
            Logger.getLogger(tableModel.class.getName()).log(Level.SEVERE, null, ex);
        }
            switch (columnIndex) {
                case 0:
                    return a.trim();
                case 1:
                    return b.trim();
                case 2:
                    return c.trim();
                default:
                    return null;
            }

    }

    /**gets the right account for the Physical_Package*/
    public Physical_Package getCPackage(int index){
        Physical_Package d = null;
        try {
            Physical_PackageDAO.getInstance().getByConceptual_Package(j.getId()).get(index);
        } catch (DataException ex) {
            Logger.getLogger(tableModel.class.getName()).log(Level.SEVERE, null, ex);
        }

        return d;
    }

    public void removeRow(int index){

    }
//write in mainFrame, in panel
//ValueChanged{
//    get the selected name
//    Physical_Packages.get()
//    namefield.settext(pp.getname);
//
//}
}
  • 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-20T11:57:49+00:00Added an answer on May 20, 2026 at 11:57 am

    Unfortunately removeRow() is only a method for DefaultTableModel

    Take a look at the source code for the DefaultTableModel. Both of these methods are implemented so you can use the code and an example of what your code might look like. The key ar the “fireXXX” methods. Invoking these methods will notify the table that the model has changed so the table can repaint itself.

    From your older question (which you just deleted) you state “I can add the row to the new jTable no problem,”

    From looking at your code (before you deleted the question) I have the following comment:

    Its looks to me like you are creating a completely new TableModel. That is not the same as adding a row to an existing model. That does not seem like a very good solution. Instead you need to create an addRow(…)

    If you find the code too confusing in the DefaultTableModel, then here is some code that shows how I’ve implemented addRow(…) and removeRow(…) methods. See Row Table Model. The class shows the proper fireXXX methods to use for each method.

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

Sidebar

Related Questions

I have a JTable that is within a JScrollPane. Rows are added to the
I have a JTable with a custom TableModel called DataTableModel . I initialized the
Good evening I have a JTable that I built with a TableModel how to
I have a JTable and a TableModel that extends AbstractTableModel . I would like
The problem is quite basic. I have a JTable showing cached data from a
I have a custom cell renderer set in JTable and it works but instead
I am using 2 Tables (JTable) with their DefaultTableModels. The first table is already
I have a project with a jTable called AchTable , that is like this:
I have a JTable that I want to use to display some data (a
I have a JTable that stores the results of a database query, so far

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.