View Single Post
  #7 (permalink)  
Old 11-29-2009, 03:57 AM
purple purple is offline
Member
 
Join Date: Nov 2009
Posts: 5
Rep Power: 0
purple is on a distinguished road
Default
Well here's what I've got so far:
Code:
class AddressBook2 extends JFrame
{
    //String[][] addresses = {{"Hancock, Bob", "01202719029", "07676101393",
                           //"1 Charminster Road, Bournemouth, Dorset, BH8 8UE"}};
    DefaultTableModel contactsTable;
    JTable table;
    Vector<Object> vectors = new Vector<Object>();

    public AddressBook2() throws IOException
    {
        this.setSize(new Dimension(640, 480));
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new GridBagLayout());

        BufferedReader fileIn = new BufferedReader(new FileReader("AddressBook.buab"));
        while (true)
        {
           String line = fileIn.readLine();
           if (line == null)
           break;
           vectors.add(line);
           //System.out.println(addresses2);
        }
        fileIn.close();
Here's the bit for the table:
Code:
 this.contactsTable = new DefaultTableModel (vectors,new String[] {"Surname", "First Name", "Home Phone Number", "Mobile number", "Address"});
        table = new JTable(this.contactsTable);
Reply With Quote