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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:58:45+00:00 2026-06-06T17:58:45+00:00

Im having trouble getting my JTable that im using to display either check boxes

  • 0

Im having trouble getting my JTable that im using to display either check boxes or combo boxes in my applet.

Here is the code that is not working correctly

 String[] options = {"download", "ignore"};
 Object[] obj = {new JComboBox(options), ((MetadataList)array.get(1)).getMetadata("Filename").getValue()};

 defaultTableModel2.addRow(obj);

The defaultTableModel2 is simply a DefaultTableModel defaultTabelModel2 = new DefaultTableModel() so nothing too dramatic there. The code above is using a JComboBox, but I have also tried using a JCheckBox as well and the same issues were present.

javax.swing.JComboBox[,0,0,0x0,invalid,layout=javax.swing.plaf.basic.BasicComboBoxUI$Handler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@8380df,flags=320,maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=download] 

is what appears instead of a JComboBox

Any help would be greatly appreciated!

  • 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-06T17:58:47+00:00Added an answer on June 6, 2026 at 5:58 pm

    For example:

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    
    @SuppressWarnings("serial")
    public class TableJunk extends JPanel {
       enum Day {MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY}
       MyTableModel tableModel = new MyTableModel();
       private JTable myTable = new JTable(tableModel);
    
       public TableJunk() {
          setLayout(new BorderLayout());
          add(new JScrollPane(myTable));
    
          Object[] rowData = {Day.MONDAY, Boolean.TRUE};
          tableModel.addRow(rowData );
          rowData = new Object[]{Day.TUESDAY, Boolean.TRUE};
          tableModel.addRow(rowData );
          rowData = new Object[]{Day.WEDNESDAY, Boolean.TRUE};
          tableModel.addRow(rowData );
          rowData = new Object[]{Day.THURSDAY, Boolean.TRUE};
          tableModel.addRow(rowData );
          rowData = new Object[]{Day.FRIDAY, Boolean.TRUE};
          tableModel.addRow(rowData );
          rowData = new Object[]{Day.SATURDAY, Boolean.FALSE};
          tableModel.addRow(rowData );
          rowData = new Object[]{Day.SUNDAY, Boolean.FALSE};
          tableModel.addRow(rowData );
    
          // create the combo box for the column editor          
          JComboBox<Day> comboBox = new JComboBox<TableJunk.Day>(Day.values());
          myTable.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(comboBox));
       }
    
       private static void createAndShowGui() {
          TableJunk mainPanel = new TableJunk();
    
          JFrame frame = new JFrame("TableJunk");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().add(mainPanel);
          frame.pack();
          frame.setLocationByPlatform(true);
          frame.setVisible(true);
       }
    
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                createAndShowGui();
             }
          });
       }
    
    
       private static class MyTableModel extends DefaultTableModel {
          private static final String[] COLUMN_NAMES = {"Day", "Work Day"};
    
          public MyTableModel() {
             super(COLUMN_NAMES, 0);
          }
    
          // this method will allow the check box to be rendered in the 2nd column
          public java.lang.Class<?> getColumnClass(int columnIndex) {
             if (columnIndex == 0) {
                return Day.class;
             } else if (columnIndex == 1) {
                return Boolean.class;
             } else {
                return super.getColumnClass(columnIndex);
             }
          };
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently having trouble getting example code for using tweepy to access Twitter's Streaming
I'm having trouble getting Japanese text to display properly on a website compiled using
I'm having trouble getting Jquery .closest() to work. Here's my code, it's simple and
Having trouble getting the javascript alert to display from my code behind. c# -
I am having trouble getting the hibernate criteria to execute, here is my code
Hi guys I'm having trouble getting my code to correctly display html within the
I'm having trouble getting Tire working using ElasticSearch with the Bonsai addon on the
I'm having trouble getting OpenGL 3.2 to run on Lion (osx 10.7.4) using Derelict3
Having trouble getting my JQuery POST to be accepted by the WCF Service. Here's
Having trouble getting this to work. What's strange is that I have 10 bookmarks

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.