Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm kinda new to Java and Netbean. How do I make a jTable that could fetch data from a mySQL database? I drag and drop the jTable into my jDialog but can't customize it. I can hand code it using http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/components/TableDemoProject/src/components/TableDemo.java[^] but it's in JFrame. The main problem is, how do I customize it? I don't want any netbean dumb default jTable.
Posted

I thing you are trying to do something like this.populate data from database into jtable
 
Share this answer
 
write below code in constructor
Java
DefaultTableModel model;
model = new DefaultTableModel(null,col);
 
        jTable1.setModel(model);
 
        int l2 = jTable1.getRowCount();
        while(l2>=1)
        {
            model.removeRow(0);
            l2 = l2-1;
        }
and after retrieving values from database
String data[]={value1,value2};
model.addRow(data);
 
Share this answer
 
v2
Comments
Valentine1993 24-Jun-13 2:25am    
I changed the GUI. So...apparently it's consider solved for me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900