JTable

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 332
Reputation: quuba is on a distinguished road 
Solved Threads: 54
quuba quuba is offline Offline
Posting Whiz

Re: JTable

 
0
  #11
Nov 29th, 2008
I see, Your data have a form:
4 columns;
Types in order: String,integer,integer,String
Give name for this structure, and names for pariculary columns.
quuba
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 16
Reputation: ebiz is an unknown quantity at this point 
Solved Threads: 0
ebiz ebiz is offline Offline
Newbie Poster

Re: JTable

 
0
  #12
Nov 29th, 2008
  1. package org.project;
  2.  
  3. import java.util.*;
  4. import java.io.*;
  5. import javax.swing.*;
  6.  
  7. public class openResults
  8. {
  9.  
  10. public static void readMatch() throws FileNotFoundException
  11. {
  12. JFrame frame = new JFrame ("Match Results");
  13. JTable table = new JTable();
  14. List<String> columnData = new ArrayList<String>();
  15.  
  16. JFileChooser chooser = new JFileChooser(); //Creating the File Chooser
  17.  
  18. int status = chooser.showOpenDialog (null); //setting blank File Chooser
  19.  
  20. if(status != JFileChooser.APPROVE_OPTION)
  21. ((DefaultTableModel) table.getModel()).addColumn("No File Chosen", (Object[])null);
  22. }
  23. else
  24. {
  25. File file = chooser.getSelectedFile(); //Selecting File
  26. Scanner scan = new Scanner(file); //Scanning the file from file chooser
  27.  
  28. while(scan.hasNext(","))
  29. {
  30. columnData.add(scan.nextLine());
  31. }
  32. ((DefaultTableModel) table.getModel()).addColumn("DATA", columnData.toArray());
  33. }
  34. JScrollPane jsp = newJScrollPane (table);
  35. frame.getContentPane().add(jsp);
  36. frame.pack();
  37. frame.setVisible(true);
  38. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 332
Reputation: quuba is on a distinguished road 
Solved Threads: 54
quuba quuba is offline Offline
Posting Whiz

Re: JTable

 
0
  #13
Nov 29th, 2008
Step1.
We focus on one theme. You have
String scanLine="westham,0,0,Queens Park Rangers";
java.util.StringTokenizer st = new java.util.StringTokenizer(scanLine,",");
...
Read all about java.util.StringTokenizer.java class and complete for me the code.
quuba
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1795 | Replies: 12
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC