Results 1 to 3 of 3
- 08-18-2012, 05:33 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 1
- Rep Power
- 0
Problem with Jtable with ResultSet
Hello Everybody:
i´m new in this forum and this is my first thread, i hope you can help me, i have a problem with JTable and ResultSetScrollable, the question is that i have a JTable with AbstractTableModel, in the class AbstractTableModel, i override the three methods, getvalueat, getcolumnname....also i have a ComboBox, when i select a value of the ComboBox, the JTable shows the data associated with the ComboBox.
Well, the problem is that JTable only shows INTEGER data, but String not, i don´t know why this could be.
if someone knows anything about this, would be very grateful.
this is a part of the code:
**********This is the AbstractTableModel******************************** *********
public class PersonalTableModel extends AbstractTableModel{
ResultSet rs;
public PersonalTableModel(ResultSet rs) {
this.rs=rs;
}
public Object getValueAt(int ri, int ci) {
Object ob=null;
try{
rs.absolute(ri+1);
ob=rs.getObject(ci+1);
}catch(Exception e){
e.printStackTrace();
}
return ob;
}
************************************************** ***********
****This is the ItemListener for the ComboBox*******************
public class ComboCambio implements ItemListener{
//Recogemos en un objeto tipo ventanaprincipal la ventana principal para acceder a los controles
VentanaPrincipal ventanaprincipal;
public ComboCambio(VentanaPrincipal ventana){
this.ventanaprincipal=ventana;
}
public void itemStateChanged(ItemEvent e) {
PersonalTableModel pt;
Sql sql=new Sql("BBDDChefDnix");
Grupo g=(Grupo)ventanaprincipal.combobox.getSelectedItem ();
pt=new PersonalTableModel(sql.getResultSetScrollable(g.ge tGrupo()));
//Una vez tenemos el elemento del combobox actualizamos la tabla.
this.ventanaprincipal.tabla.setModel(pt);
}
}
************************************************** *
If you need more code, please tell me and i paste it.
Thxxxxxxxxxxxxxxxxxxxx a lot!!!
- 08-18-2012, 06:44 PM #2
Re: Problem with Jtable with ResultSet
Why do they call it rush hour when nothing moves? - Robin Williams
- 08-18-2012, 11:36 PM #3
Re: Problem with Jtable with ResultSet
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Problem with ResultSet when using GUI
By RefugeX in forum New To JavaReplies: 6Last Post: 12-01-2011, 10:21 PM -
Multiple Resultset in Jtable
By hash004 in forum New To JavaReplies: 1Last Post: 07-17-2011, 09:14 PM -
populating jtable with resultSet - help needed
By smallmos1 in forum JDBCReplies: 2Last Post: 05-07-2011, 06:32 PM -
Returning a ResultSet to custom JTable Model
By Kenjitsuka in forum New To JavaReplies: 9Last Post: 10-16-2010, 09:17 PM -
ResultSet to JTable
By Java Tip in forum Java TipReplies: 0Last Post: 02-11-2008, 09:01 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks