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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:02:43+00:00 2026-05-24T23:02:43+00:00

Alright. I have implemented a custom JTable model that includes the whole @Override public

  • 0

Alright. I have implemented a custom JTable model that includes the whole

@Override
public Class<?> getColumnClass(final int column) {

and inside that I have

if (column == 0)
    return Boolean.class;

When I run, and I go to the JTable, instead of a checked JCheckbox, it says true. When I click on it, it turns into a JCheckBox until I unclick and then either says true or false.

WHAT AM I DOING WRONG!!???

  • 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-24T23:02:44+00:00Added an answer on May 24, 2026 at 11:02 pm

    really don’t know, you can compare your code with

    note both definitions for Column.Class are valid, you can try it that with uncomment blocked code

    enter image description here

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    
    public class TablePrepareRenderer extends JFrame {
    
        private static final long serialVersionUID = 1L;
        private JTable table;
    
        public TablePrepareRenderer() {
            Object[] columnNames = {"Type", "Company", "Shares", "Price", "Boolean"};
            Object[][] data = {
                {"Buy", "IBM", new Integer(1000), new Double(80.50), false},
                {"Sell", "MicroSoft", new Integer(2000), new Double(6.25), true},
                {"Sell", "Apple", new Integer(3000), new Double(7.35), true},
                {"Buy", "Nortel", new Integer(4000), new Double(20.00), false}
            };
            DefaultTableModel model = new DefaultTableModel(data, columnNames);
            table = new JTable(model) {
    
                private static final long serialVersionUID = 1L;
    
                /*@Override
                public Class getColumnClass(int column) {
                return getValueAt(0, column).getClass();
                }*/
                @Override
                public Class getColumnClass(int column) {
                    switch (column) {
                        case 0:
                            return String.class;
                        case 1:
                            return String.class;
                        case 2:
                            return Integer.class;
                        case 3:
                            return Double.class;
                        default:
                            return Boolean.class;
                    }
                }
    
                @Override
                public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
                    Component c = super.prepareRenderer(renderer, row, column);
                    int firstRow = 0;
                    int lastRow = table.getRowCount() - 1;
                    if (row == lastRow) {
                        ((JComponent) c).setBackground(Color.red);
                    } else if (row == firstRow) {
                        ((JComponent) c).setBackground(Color.blue);
                    } else {
                        ((JComponent) c).setBackground(table.getBackground());
                    }
                    return c;
                }
            };
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane(table);
            getContentPane().add(scrollPane);
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    TablePrepareRenderer frame = new TablePrepareRenderer();
                    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright so I have a task, that I have to let the client try
Alright, currently I have my SWF hitting a php file that will go and
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
(Java Spring WebApp) I have: public class PersonValidator implements Validator { private PersonDAO d;
Alright I have a div that contains an image, <div id=image> <img src=images/medium/1.png />
Alright I have a question that seems simple but I haven't been able to
Alright so I have a custom page template designed with javascript and php (lets
Alright, I have a class EIR which is a List based from its base
Alright so given this graph that must be implemented with the minimum number of

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.