file data output to table java

Discussion in 'Programming' started by Radio86, Dec 17, 2007.

  1. #1
    Hi guyz,

    am having a problem i want to display data from file into table but i can't figure it out, how to do this....,

    basically, i read data from file then into a object then i want to display it into a table...., is there a way i can do this,


      btnOpen.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent i)
            {
              try
                   {
                   String Data = "";
                   Client studObj = new Client();
                   for (int a = 0; a <=1; a++)
                     {
                          String[] columnName = {"First Name", 
                                    "Last Name",
                                    "Sport",
                                    "# of Years",
                                    "Vegetarian"};
                        studObj = (Client)objIn.readObject();
                        Object [][] data = {{studObj.getClientName(), studObj.getClientAddress() , studObj.getClientTelnod() , studObj.getClientTelnoe()}};
                        table = new JTable(data, columnNames);
                        table.setPreferredScrollableViewportSize(new Dimension(500, 70));
                     }
                    
                      objIn.close();
                  }
                  catch (Exception gg)
                  {
                      System.out.println(gg);
                  }
            }
        }
        );
    Code (markup):
    please do reply ASAP, thanks in advance

    Radio
     
    Radio86, Dec 17, 2007 IP
  2. daman371

    daman371 Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You're going to have to run a loop and output each element with a tab between them.
     
    daman371, Dec 18, 2007 IP