Questions tagged [defaulttablemodel]

An implementation of the TableModel interface. Used (by default) by JTable to manage the data found in the table. Custom/alternative implementations of the TableModel interface may be provided.

370 questions
39
votes
10 answers

How to populate JTable from ResultSet?

I call getnPrintAllData() method after pressing OK button: public class DatabaseSQLiteConnection { Connection conn = null; PreparedStatement statement = null; ResultSet res = null; public DatabaseSQLiteConnection(){ …
A. K. M. Tariqul Islam
  • 2,824
  • 6
  • 31
  • 48
19
votes
6 answers

Removing all the rows of DefaultTableModel

I want to delete all the rows of DefaultTable. I found two common ways to delete them on internet, but none of them works in my case because those methods does not exist in my DefaultTableModel. I wonder why. My code for using DefaultTableModel…
Xara
  • 8,748
  • 16
  • 52
  • 82
12
votes
4 answers

JTree update nodes without collapsing

I have a Java SE 7 application that needs to have the JTree nodes updated. From the tutorial given by Oracle using this thread, there's no given hint on how I could update the label (displayed text of the node on the Tree) on code. Currently I am…
David B
  • 3,269
  • 12
  • 48
  • 80
5
votes
6 answers

Add column to exiting TableModel

I have a class; public class A extends AbstractTableModel { ... } Using ResultSetMetaData I build the TableModel to match my result set from the database. public class B extends JPanel { ... } In class B where I extends JPanel and added class A…
Bitmap
  • 12,402
  • 16
  • 64
  • 91
5
votes
1 answer

Rename the table header

In my JTable, I want to rename the table header using right click option.on Right clicking on any header it gives option for rename header.but when I am doing this it will do rename of selected column's header. So I have to first left click on that…
Ronak Jain
  • 2,402
  • 2
  • 24
  • 38
4
votes
3 answers

How to make cells of JTable non-editable, but selectable

I have overridden the isCellEditable() method of class JTable in my code to make the cells of my JTable non-editable but selectable, but the cells are still editable. How do I solve this problem? import java.awt.event.MouseAdapter; import…
user3808922
  • 61
  • 1
  • 1
  • 3
4
votes
2 answers

Adding rows in to jtable by customized table model

I Have created a table model extending DefaultTableModel. public class TableModel extends DefaultTableModel { List data; public AttachedVariableTableModel(){ super(); this.data=Collections.synchronizedList(new…
Nikhil
  • 2,857
  • 9
  • 34
  • 58
4
votes
1 answer

Error in getRowCount() on DefaultTableModel

EDIT I've tried changing the table model back to DefaultTableModel but I am getting an Exception when compiling my code and I can't figure out why! Here's my table init: jTable1.setModel(new Table1Model()); jTable1.setDefaultRenderer(Color.class,new…
4
votes
1 answer

JTable and DefaultTableModel

I have a table that gets information from my local MySQL server. It reads the data very well and post it on GUI. My question is , how can I refresh my table when I change my table command, for example: private String sql = "select * from…
A. Mesut Konuklar
  • 611
  • 3
  • 12
  • 29
4
votes
2 answers

Last row always removed from DefaultTableModel, regardless of index

I face some problems when I am trying to remove rows from a table in java. In particular, I use the DefaultTableModel, and when I am trying to remove a row, using the removeRow(int row) method, the last row is removed, regardless what the row is.…
George
  • 53
  • 9
3
votes
2 answers

Java - JTable - Set a cell to not allow editing

I have a JTable with a model instantiated as: TableModel ss = new DefaultTableModel(myArray[][], myHeaderArray[]); Where the arrays are generated. However, at the moment, you can still edit cells. How can I prevent this? Thanks!
mark
  • 2,841
  • 4
  • 25
  • 23
3
votes
2 answers

DefaultTableModel without column names

This class communicates with my database retrieves data and project them to a JTable.I used the DefaultTableModel but the column names won't appear.I instantiate this class in another class where i retrieve the table with the data through getTable(…
giannis christofakis
  • 8,201
  • 4
  • 54
  • 65
3
votes
1 answer

Java - Method changes value of variable in JTable (refresh not working)

I have a JTable with a variable inside one of the cells. When Button is clicked the variable changes but nothing changes in JTable. Here is my simple example code: public class Test extends JPanel { static String var = "One"; Object rowData[][] = {…
Romeo
  • 311
  • 1
  • 2
  • 9
3
votes
2 answers

DefaultTableModel not returning values in dataVector

My issue is related with JTable and DefaultTableModel. My task is to create JTable which shows data with checkboxes... which I did successfully.. But I want to delete rows from JTable selected by checkboxes... I know this has been asked too many…
Ankit Patel
  • 142
  • 1
  • 13
3
votes
1 answer

Undo in JTable in swing

Have a look at the code shown below. When I add two rows to the table and afterwards try to perform an undo operation I get a java.lang.ArrayIndexOutOfBoundsException: 11 >= 11. Can anyone please tell me what is wrong with the code? import…
Dipti
  • 91
  • 1
  • 5
1
2 3
24 25