accessing a jTable problem
From: Mike (mike_at_n-o--s-p-a-m.luusac.co.uk)
Date: 10/24/03
- Next message: Lee Fesperman: "Re: JDBC:how to compare char[] and int"
- Previous message: Frederic Pepin: "Re: trouble getting a connection from MS SQL Server 2000 database server from WSAD"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Oct 2003 23:11:19 +0100
Hi,
I have a jtable in a scrollpane generated by forte and I don't know how to
access the data. I have written manual code before where I add a table
model when instantiating the jtable, but now I am using forte and it has
generated the code for the table for me and I don't know how to access the
table model. The forte code I have is below:
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null}
},
new String [] {
"Column 1", "Column 2", "Column 3", "Column 4", "Column 5",
"Quantity", "Column 6"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class,
java.lang.String.class, java.lang.String.class, java.lang.String.class,
java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
And the code I have to link it with I would normally do like:
Vector data = themodel.v.tabmod.getDataVector();
having created the table thus:
DefaultTableModel tabmod = new DefaultTableModel(){
blah
};
JTable mytable = new JTable(tabmod);
I also need to know how to add and remove rows from the jtable and have the
same problem re the table model.
I need to get this working urgently and would welcome any help,
Mike
- Next message: Lee Fesperman: "Re: JDBC:how to compare char[] and int"
- Previous message: Frederic Pepin: "Re: trouble getting a connection from MS SQL Server 2000 database server from WSAD"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]