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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:00:33+00:00 2026-05-26T02:00:33+00:00

I am working with a JTable that contains a few columns with different datatypes

  • 0

I am working with a JTable that contains a few columns with different datatypes (int, string, date). When I run the app the data displays fine but if I use the column headers to sort the data it freezes on the columns that contain Date objects. Below is the code. Columns 8, 9, & 10 are the ones causing the problem. How do I make it so the Date columns are sortable?

public void updateLogTable() {

    DefaultTableModel model = (DefaultTableModel) logTable.getModel();
    List<LogObject> lstLogObjects = new ArrayList<LogObject>();
    lstLogObjects = LogManager.getLog();
    for (int i = 0; i < lstLogObjects.size(); i++) {
        Object[] temp = new Object[13];

        temp[0] = Integer.parseInt(lstLogObjects .get(i).getLogID());
        temp[1] = lstLogObjects .get(i).getLogType();
        temp[2] = lstLogObjects .get(i).getYear();
        temp[3] = lstLogObjects .get(i).getQuarter();
        temp[4] = lstLogObjects .get(i).getOriginalID();
        temp[5] = lstLogObjects .get(i).getSubject();
        temp[6] = lstLogObjects .get(i).getAction();
        temp[7] = lstLogObjects .get(i).getRequester();
        temp[8] = lstLogObjects .get(i).getADate(); //Returns java.util.Date
        temp[9] = lstLogObjects .get(i).getCDate(); //Returns java.util.Date
        temp[10] = lstLogObjects .get(i).getSDate(); //Returns java.util.Date
        temp[11] = lstLogObjects .get(i).getRemarks();
        temp[12] = lstLogObjects .get(i).getField1();

        model.addRow(temp);

    }
    model.fireTableDataChanged();
 }
  • 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-26T02:00:34+00:00Added an answer on May 26, 2026 at 2:00 am

    Did you override the getColumnClass(…) method of your TableModel to return the proper class?

    The table sort methods will then sort the column and treat it as a Date rather than invoke toString() on the Date object.

    If you need more help then post your SSCCE demonstrating the problem.

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

Sidebar

Related Questions

Working with a SqlCommand in C# I've created a query that contains a IN
I'm working with a JTable , whose cells data are contained in Object .
How can i add data to JTable while working with netbeans. Netbeans in it's
I have a standalone Java application that gets data from a database and displays
I am working in JTable and I have a requirement like this. Say There
Working on a project that parses a log of events, and then updates a
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
i am working on an animation that when i pressed a button the each
Working in an app where a page_title method was defined in application_helper.rb as such:
I have an application that uses Swing. The display I am working on, uses

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.