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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:17:52+00:00 2026-05-25T14:17:52+00:00

I followed the directions somewhere online to insert checkboxes in a JTable. Here is

  • 0

I followed the directions somewhere online to insert checkboxes in a JTable. Here is my code to do so:

  protected class JTableCellRenderer implements TableCellRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
      JCheckBox rendererComponent = new JCheckBox();
      rendererComponent.setSelected((Boolean) tableModel.getValueAt(row,
        column));
      return rendererComponent;
    }

  }

I managed to add checkboxes to a JTable, but then when I run my program, I get the following behavior:

enter image description here

How do I allow a user to check the checkbox instead of selecting True or False from the dropdown menu when he or she clicks on the checkbox? Thanks!

  • 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-25T14:17:53+00:00Added an answer on May 25, 2026 at 2:17 pm

    The directions you are following are bad as there’s no need to fiddle with renderers or editors (and by the way, your problem is that you changed the renderer without changing the editor). All you have to do is in your TableModel class, override the getColumnClass(int index) method and have it return Boolean.class for the column that needs check boxes. That’s it. The JTable will automatically use a checkbox both for the column’s renderer and editor solving your problem in a very easy way. Of course it should go without saying that the data for that column must be Boolean for this to work.

    The Oracle tutorial on JTables will tell you all this and more: How to use Tables

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

Sidebar

Related Questions

I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
I have followed the suggestion in this question... [ How to handle checkboxes in
I followed the directions in this post: how can we integrate jquery autocomplete using
I followed the directions in the Membership Providers document provided by Sitecore, but I
I followed the directions on how to create web applications using Go, and I
I followed the directions in this *link and the while the all sites search
I have followed the directions on the boost website. I have put the boost
hey guys, I've followed some tutorials online regarding creating and installing a windows service
I'm trying to get a Django app running with Lighttpd. I followed the directions
I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I

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.