Fahmi Hammadi
Fahmi Hammadi

Reputation: 25

making Jtable with add,delete,reset and sorting

Hey does anyone know how to make program using JTable with some function with the column that contain variable type: String, Double,Int so it will contain 3 column with different variable

Upvotes: 0

Views: 179

Answers (1)

Asd
Asd

Reputation: 103

Object obj[][]=null;
Table.setModel(obj);

Add row but updating 'obj' and again call Table.setModel(obj); Delete row same as above.

for reset table

 table.setModel(new DefaultTableModel(
                new Object[][]
                {
                    {null, null},
                }
            ) {
                Class[] columnTypes = new Class[] {
                public Class getColumnClass(int columnIndex) {
                boolean[] columnEditables = new boolean[] {
                public boolean isCellEditable(int row, int column) {
             });

Sorting :: I don't know what are you trying to sort but values can be extraxted via getModel()

TableModel Model= T.getModel();

After that you may sort the values and then reinsert into the table by

Model.setValueAt(value,int row,int column);

Upvotes: 1

Related Questions