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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:32:12+00:00 2026-06-08T11:32:12+00:00

I’m making a database management system using java and mySQL. I’m using a jTable

  • 0

I’m making a database management system using java and mySQL. I’m using a jTable as a interface to the database.

Though the post look little long, the problem wont be that much of complex, for an experienced person (i guess).

This is my problem. After selecting a cell, i can enter values, (no prob with that). But after entering values, when i click on some other cell, the entered values get disappeared and it gets back to null.

Can’t figure out the reason. I don’t have much experience on jTables. But i think the problem is with the tablemodel.

This is my tablemodel

import Templates.TableEntry;
import java.util.LinkedList;
import javax.swing.table.AbstractTableModel;

public class myTableModel extends AbstractTableModel {

public static final int DATE_INDEX = 0;
public static final int ORDERNO_INDEX = 1;
public static final int ROOT_INDEX = 2;
public static final int HIDDEN_INDEX = 3;
public String[] columnnames;
public LinkedList<TableEntry> entryList;

public myTableModel(String[] columnNames) {
    this.columnnames = columnNames;
    entryList = new LinkedList<TableEntry>();
}

@Override
public String getColumnName(int column) {
    return columnnames[column];
}

@Override
public boolean isCellEditable(int row, int column) {
    if (column == HIDDEN_INDEX) {
        return false;
    } else {
        return true;
    }
}

@Override
public Class getColumnClass(int column) {
    return String.class;
}

@Override
public String getValueAt(int row, int column) {
    TableEntry record = entryList.get(row);
    switch (column) {
        case DATE_INDEX:
            return record.date;
        case ORDERNO_INDEX:
            return record.jobOdrerNo;
        case ROOT_INDEX:
            return record.rootCardNos;
        default:
            return null;
    }
}

public void setValueAt(String value, int row, int column) {
    TableEntry record = entryList.get(row);
    switch (column) {
        case DATE_INDEX:
            record.date = value;
            break;
        case ORDERNO_INDEX:
            record.jobOdrerNo = value;
            break;
        case ROOT_INDEX:
            record.rootCardNos = value;
            break;
        default:
            System.out.println("invalid index");
    }
    updateTable(row, column);
}

public void updateTable(int row, int column) {
    fireTableCellUpdated(row, column);
}

@Override
public int getRowCount() {
    return entryList.size();
}

@Override
public int getColumnCount() {
    return columnnames.length;
}

public boolean hasEmptyRow() {
    if (entryList.size() == 0) {
        return false;
    }
    TableEntry entry = entryList.get(entryList.size() - 1);
    if ("".equals(entry.date)) {
        return true;
    } else {
        return false;

    }
}

public void addEmptyRow() {
    entryList.add(new TableEntry());
    fireTableRowsInserted(entryList.size() - 1, entryList.size() - 1);
}

public void deleteRow(int i) {
    if (i != 0) {
        entryList.remove(i);
        fireTableRowsDeleted(i - 1, i + 1);
    }
}

}

Sorry about the length. But i posted the whole code for the sake of completeness. Most of the parts can be neglected.

TableEntry is a simple class.

package Templates;

public class TableEntry {

public String date;
public String jobOdrerNo;
public String rootCardNos;
public String yardRootCard;
public String MCISO_NO;
public String service_maintenance_breakdown;
public String jobNo;
public String machineName;
public String fault;
public String problematicPart;
public String person;
public String action;
public String startTime;
public String finishedTime;
public String durationOfRepair;
public String spareParts;
public String itemCode;
public String no;
public String value;
public String totalCost;
public String remark;
public String breakdownAndSolution;

}

Hope I’ve provided all the details. This has been a real bug for me. Any help is appreciated.
Thanx in advance..!

(If any clarification is needed, please let me know.. difficult to post whole project. It’s a bit huge.. :D)

  • 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-08T11:32:14+00:00Added an answer on June 8, 2026 at 11:32 am

    There’s a small bug in your code. Next time, be carefull..

    In the tablemodel’s method “setValueAt(—)” you’ve put wrong arguments. you were trying to override a method of class “AbstractTableModel”. Original method is,

    public void setValueAt(Object aValue, int rowIndex, int columnIndex){
    }
    

    But you’ve written your method as,

    public void setValueAt(String value, int row, int column) {
    ...//method body
    }
    

    Hence, it wont override the intended function. Everytime a cell is changed, tablemodel will call the original “setValueAt(…)” function. But since it hasn’t overriden, it will do nothing (you must override it, original method has no body).

    Hope this helps..

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.