0

i am create a swing based authentication system and i have a table where i wish to print some necessary details and want the last columnn to have a checkbox. Even after giving a boolean value it is printing true or false rather than a checkbox

                controlPanel.removeAll();
                System.out.println("coming1");
                JournalApprovalClass JAC = new JournalApprovalClass();
                JournalApproval JA = new JournalApproval();

                String[] columns = { "Author1", "Author2", "Author3",
                        "Author4", "Author5", "Author6", "Title",
                        "JournalName", "Scopus", "ImpactFactor",
                        "JournalMonth", "JournalYear", "NamePublisher",
                        "VolumeIssuePageNo", "BtechMtech", "OtherDetails",
                        "Approval" };
                System.out.println("coming2");

                try {
                    JA.adminApprovalJournalApproval();
                } catch (ClassNotFoundException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (SQLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                System.out.println("coming3");
                DefaultTableModel model = new DefaultTableModel(
                        journalTable.values2, columns);
                JTable journalAdminApprovalTable = new JTable(model);

                journalAdminApprovalTable
                        .setPreferredScrollableViewportSize(new Dimension(
                                1200, 100));
                journalAdminApprovalTable.setFillsViewportHeight(true);
                TableColumn column = null;
                for (int i = 0; i <= 16; i++) {
                    column = journalAdminApprovalTable.getColumnModel()
                            .getColumn(i);
                    column.setPreferredWidth(50);
                    if (i == 16) {
                        column.setPreferredWidth(10);
                    }

                }
                System.out.println("coming4");
                JScrollPane scrollPane = new JScrollPane(
                        journalAdminApprovalTable);
                controlPanel.add(scrollPane);
                controlPanel.revalidate();
                controlPanel.repaint();
                System.out.println("coming5");

This is where i am trying to create to create the table the data object is created in another class

                ma.values[0] = au.Author1;
                ma.values[1] = au.Author2;
                ma.values[2] = au.Author3;
                ma.values[3] = au.Author4;
                ma.values[4] = au.Author5;
                ma.values[5] = au.Author6;
                ma.values[6] = au.Title;
                ma.values[7] = au.JournalName;
                ma.values[8] = au.Scopus;
                ma.values[9] = au.ImpactFactor;
                ma.values[10] = au.JournalMonth;
                ma.values[11] = au.JournalYear;
                ma.values[12] = au.NamePublisher;
                ma.values[13] = au.VolumeIssuePageNo;
                ma.values[14] = au.BtechMtech;
                ma.values[15] = au.OtherDetails;
                ma.values[16] = new Boolean(true);
                /*if (au.AdminApproval == "NO") {
                    ma.values[16] = new JCheckBox("Approval");
                } else
                    ma.values[16] = new Boolean(true);*/
                ma.values1[i] = new Object[17];
                ma.values1[i] = ma.values;

                System.out.println(ma.values1[i] + " " + ma.values[0] + " "
                        + i);
                i++;
            }
            resultSet.next();
        }
        journalTable.values2 = new Object[i][];
        for (int j = 0; j < i; j++)
            journalTable.values2[j] = journalTable.values1[j];
        return;

Everything is working properly but the thing what i wish for is to have checkbox which is always checked(the reason behind giving true). when i run the code i get the following output

last column i need a checkbox

1 Answers1

0

It is because your model is operating on String rather than Object. I am not able to run your code, but if I were you I would:

  1. Try to change String[] columns to Object[] columns.
  2. If that doesn't help, take a look at this
freefall
  • 597
  • 2
  • 12
  • 28