Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTables - pls help!  RSS feed

 
Kaushik Gopal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am designing an Email client and am not a very experienced Java programmer. I am using JTables to display my incoming email. I store my incoming mail in a 2D array results[][] which is got by using a executeQuery(sql query) statement. When I click on a folder (eg INBOX), I want to refresh the JTable and display only the inbox contents. I do this by using the following code:
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)jTree_folderList.getLastSelectedPathComponent();
Object nodeInfo = node.getUserObject();
if (node.isLeaf()) {
// node.toString() is the name of the folder you clicked.
String folder = node.toString();
// Create columns names
String columnNames[] = { "From", "Subject", "Date" };
// Create some data
String dataValues[][] = db.getFolderContents(username, folder);
kgTable = new JTable( dataValues, columnNames );
This code does not put the the results into the JTable and refresh it, but there is no error message either! Pls help me, I have 2 weeks to go b4 submission!
 
jaganbala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use Model to your table.Pass the column values and the column names to the Table model and then pass the model to your JTable by calling JTable.setModel(tableModel).
 
Kaushik Gopal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks jagan but I have not used a table model. I just create it by myself in the code. I have had a look at table models but do not understand them...is there anyway to bypass this? Please let me know. Cheers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!