Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT jcheckbox in jtable does nothing when clicking on it
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


tejas
jcheckbox in jtable does nothing when clicking on it
0 Answer(s)      2 years ago
Posted in : Swing AWT


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.");
    }

}

Advertisement
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
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
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  Values to be displayed in JTextfield when Clicked on JTable Cells
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
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
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  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
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
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
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 table=new JTable(data,labels); JScrollPane pane=new JScrollPane
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
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
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
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
jtable problem
jtable problem  how to make a cell text hypertext
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 query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month
Retrieve data by clicking a link
Retrieve data by clicking a link  In a page there are 5 links.Every link has a hidden value. According to that hidden value data should be retrieved from the database and data should be displayed in a new page.How to do it?Please
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
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
Advertisements
 

 

 

DMCA.com