943,915 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3775
  • Java RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Nov 29th, 2008
0

Re: JTable

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
Reputation Points: 123
Solved Threads: 106
Posting Pro
quuba is offline Offline
573 posts
since Nov 2008
Nov 29th, 2008
0

Re: JTable

Java Syntax (Toggle Plain Text)
  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. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ebiz is offline Offline
16 posts
since Nov 2008
Nov 29th, 2008
0

Re: JTable

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
Reputation Points: 123
Solved Threads: 106
Posting Pro
quuba is offline Offline
573 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: how to make attempts in pin numbers
Next Thread in Java Forum Timeline: Problem reading data from file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC