jcheckbox in jtable does nothing when clicking on it

jcheckbox in jtable does nothing when clicking on it

my table model is as follows

public class MyTableModel implements TableModel {

ArrayList<PersonDTO> list=new ArrayList<PersonDTO>();

String headerName[]={"checkbox","student_id","name"};

    public MyTableModel(ArrayList<PersonDTO> list) {
        this.list=list;  
    }


    @Override
    public int getRowCount() {
        //throw new UnsupportedOperationException("Not supported yet.");
        System.out.println(list.size());
         return list.size();

    }

    @Override
    public int getColumnCount() {
        //throw new UnsupportedOperationException("Not supported yet.");
       // System.out.println(headerName.length);
        return headerName.length;
    }

    @Override
    public String getColumnName(int columnIndex) {
        //throw new UnsupportedOperationException("Not supported yet.");
       // System.out.println(headerName);
        return headerName[columnIndex];


    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        //throw new UnsupportedOperationException("Not supported yet.");
        switch(columnIndex)
        {
            case 0:
                return JCheckBox.class;
                //return JCheckBox.class;
            case 1:
                return Integer.class;
            case 2:
                return String.class;


        }
        return null;
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
       // throw new UnsupportedOperationException("Not supported yet.");
         return  true;

    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        //throw new UnsupportedOperationException("Not supported yet.");
        PersonDTO personDTO=list.get(rowIndex);
         switch(columnIndex)
        {
            case 0:
               //System.out.println(personDTO.isCheckbox());
              return personDTO.getCheckBox();
                //return new JCheckBox();

            case 1:
                //System.out.println(personDTO.getName());
                return personDTO.getUserId();
            case 2:
                return personDTO.getName();


        }
        return null;
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        //throw new UnsupportedOperationException("Not supported yet."); 

    }

    @Override
    public void addTableModelListener(TableModelListener l) {
       // throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void removeTableModelListener(TableModelListener l) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

}
View Answers









Related Tutorials/Questions & Answers:
jcheckbox in jtable does nothing when clicking on it
jcheckbox in jtable does nothing when clicking on it  my table model is as follows public class MyTableModel implements TableModel...(); //return new JCheckBox(); case 1: //System.out.println
jcheckbox
jcheckbox  How to insert value into database from jcheckbox using java swing
Advertisements
ModuleNotFoundError: No module named 'custom-test-package-that-does-nothing'
ModuleNotFoundError: No module named 'custom-test-package-that-does-nothing...: ModuleNotFoundError: No module named 'custom-test-package-that-does-nothing' How...-that-does-nothing After the installation of custom-test-package-that-does
ModuleNotFoundError: No module named 'custom-test-package-that-does-nothing'
ModuleNotFoundError: No module named 'custom-test-package-that-does-nothing...: ModuleNotFoundError: No module named 'custom-test-package-that-does-nothing' How...-that-does-nothing After the installation of custom-test-package-that-does
How to Display an alert message when nothing is selected in jspinner in java?
How to Display an alert message when nothing is selected in jspinner in java... a message when nothing is selected. My initial value is 0 min value = 0 max value = 200 so when the application is running it displays the jspinner
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...
How to read and retrieve jtable row values into jtextfield on clicking... application in which i have to display database records in jtable .now I want... that in textfield below the jtable. plz sir give me the code.... Thank you Sir
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button... .when i enter search value in the search field only one row is displayed in the jtable .Suppose i enter name in search field which has two rows in the database
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button... .when i enter search value in the search field only one row is displayed in the jtable .Suppose i enter name in search field which has two rows in the database
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button... .when i enter search value in the search field only one row is displayed in the jtable .Suppose i enter name in search field which has two rows in the database
JTable
JTable  Values to be displayed in JTextfield when Clicked on JTable Cells
SplitButton of dropdownbutton invisible when mouse clicking - Swing AWT
SplitButton of dropdownbutton invisible when mouse clicking  click the SplitButton of dropdownbutton, when dropdownmenu willbe displayed. but this is not disabled when mouevent performed on the jpanel how to disabled or hide
jtable
jtable  how to get the values from database into jtable and also add a checkbox into it and then when selected the checkbox it should again insert into database the selected chewckbox.plzz help
jtable
jtable  hi Sir i am working netbeans IDE,I have a jtable when i insert values in jtable then i am unable to print all inserted values,For eg if i insert 1,2,3,4,5,6,7,8 values then , i am getting output
JTable
JTable  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
JTable
JTable   how to select a definite cell which containing a similar text containg to the one which the user entering from a jtable at runtime in java
JTable
JTable  Hi I have problems in setting values to a cell in Jtable which is in a jFrame which implements TableModelListener which has a abstract method tableChanged(TableModelEvent e) . I'll be loading values from data base when
JTABLE Issue
JTABLE Issue  Hi Eveyone, I am developing a small application on Swing-AWT. I have used JTABLE to show data. There is "input field" and "search button " on a frame , by clicking this search button data will be retrived from DB
JTable
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
JTable
JTable  Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
jtable
jtable  hey i have build a form and i m also able to add data from database to jtable along with checkbox.the only problem is that if i select multiple checkboxes the data doesnt get inserted into new database and if only one
regarding jtable...
regarding jtable...  sir, im working with jtables. i wanted to populate a jtable from the database and when i click any row it should add a container... table after clicking the row on to the jdialog box. i am not able to add
JTable
"}; JTable table=new JTable(data,labels); JScrollPane pane=new JScrollPane
ModuleNotFoundError: No module named 'nothing'
ModuleNotFoundError: No module named 'nothing'  Hi, My Python... 'nothing' How to remove the ModuleNotFoundError: No module named 'nothing... to install padas library. You can install nothing python with following command
jcheckbox not enabled in java - Swing AWT
jcheckbox not enabled in java  . im new to java.. jcheck box not enabled after i placed in sort select table in gui. what can i do to enable and made a click on it.after that selected rows are are opened in excel . already i
Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below
Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below  HI, I have... and horizontal scroll bar. Problem: When the vertical scroll bar is used to scroll
regarding JTable - JDBC
regarding JTable  how to populate a JTable with mysql data after clicking JButton please explain with the example
ModuleNotFoundError: No module named 'absolutely_nothing'
ModuleNotFoundError: No module named 'absolutely_nothing'  Hi, My... named 'absolutely_nothing' How to remove the ModuleNotFoundError: No module named 'absolutely_nothing' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'test-nothing'
ModuleNotFoundError: No module named 'test-nothing'  Hi, My Python... 'test-nothing' How to remove the ModuleNotFoundError: No module named 'test-nothing' error? Thanks   Hi, In your python
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month
problem with JTable - Swing AWT
to swings.i was having an assignment like i need to create a JTable... an action event such that if i check the checkbox outside the JTable,all the checkboxes inside the JTable should be checked. details: for creating JTable
JTable - Java Beginners
JTable search example  I've problem about JTable, i wan to search records when i types words in JTable cell,can u give the source code.I'm Beginner and i start begins learning java programming.Please send the example into my
jtable problem
jtable problem  how to make a cell text hypertext
Java: Adding Row in JTable
Java: Adding Row in JTable   how about if we already have the JTAble created earlier. And i just found nothing to get its DefaultTableModel, thus, I can't call insertRow() method. Is there any work around for this? I found
Jbutton in JTable cells
Jbutton in JTable cells  I am a Java Beginner... I want a code in which I display data in Jtable from database and correspondingly a JButton for each cell and when i click on that button a new window should open
Display alert box on clicking link
Display alert box on clicking link In this tutorial, we will display alert box... a "a href" link. On clicking this link ,a alert box prompt message "redirecting...." and when we click "Ok" button
ModuleNotFoundError: No module named 'clicking'
ModuleNotFoundError: No module named 'clicking'  Hi, My Python... 'clicking' How to remove the ModuleNotFoundError: No module named 'clicking... to install padas library. You can install clicking python with following
JTABLE OF JAVA
JTABLE OF JAVA  i have a jtable in java,i have used checkbox in jtable. now i want to add(submit) only those records that i have checked by checkbox how? i want small example with coding
How to insert rows in jTable?
How to insert rows in jTable?  Hi, I need to take input from user using JTable. I want an empty row to appear after clicking a insert button. The values will be entered in this empty row. I have searched on this but could
Jtable-Java
Jtable-Java  Hi all,I have a Jtable And i need to clear the data in the table .I only Need to remove the data in the table.not the rows.Please help me
Swings JTable
Swings JTable  add values to JTable with four coloums,two of them are comboboxes
sum in JTable
sum in JTable  how to calculate sum from JTable's one field like total
JTable with Date Picker
JTable with Date Picker  Hi, I'd like to implement the following but I have no idea where to start: I have a JTable with 1 column containing... a datepicker that i'd like to pop up when this cell is clicked and allowing
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to transfer
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to transfer
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to transfer
jtable query
jtable query  I need a syntax...where i could fetch the whole data from the database once i click the cell in jtable...and that must be displayed in the nearby text field which i have set in the same frame
java jtable
java jtable  Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to read only... that in jtable. plz help me with the code
JTable populate with resultset.
JTable populate with resultset.  How to diplay data of resultset using JTable?   JTable is component of java swing toolkit. JTable class is helpful in displaying data in tabular format. You can also edit data. JTable
JTable Cell Validation? - Swing AWT
JTable Cell Validation?  hi there please i want a simple example of JTable with 3 columns Name,Number,Price and the first columns is string... or leave the cell empty nothing happens(the value still as it was) thank you all 
Creating a JTable Component
Creating a JTable Component       Now you can easily create a JTable component. Here, the procedure for creating a JTable component is given with the brief description

Ads