Results 1 to 7 of 7

Thread: Using Jtable

  1. #1
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Posts
    25
    Rep Power
    0

    Default Using Jtable

    Hi,

    I have an array of strings which has to be displayed by using Jtable.

    eg:
    Java Code:
    public String A[];
    A=new String[1];
    A[0]="Hi";
    A[1]="Bye";
    
    String[] title={"Greetings"};
    
    Object [][] data={
    
    ??????????????????????
    
    }
    Could someone explain me how to achieve this?

    Thanks in advance

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default Re: Using Jtable

    what you need is the following:

    JTable table = new JTable(DATA, COLHEADS);

    for more details look at the api site JTable (Java Platform SE 6)

  3. #3
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Posts
    25
    Rep Power
    0

    Default Re: Using Jtable

    Thanks for the quick reply.

    Sorry, I need to know how to write the constructor

    Object [][] data={

    ??????????????????????

    }

    not after that.

    Regards

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

  5. #5
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Posts
    25
    Rep Power
    0

    Default Re: Using Jtable

    No, the problem is my array contains more than 150 elements. So do I need to write down each of them? or can I use a for loop inside this
    Java Code:
    Object [][] data={
    {a[1]},
    {a[2]},
    {a[3]},
    .
    .
    .
    .
    {a[150]},
    }
    if I try to use for loop it shows an error. How can I achieve this. I need to list down these 150 words in this table. Please make some valuable comments.

    Thanks.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Using Jtable

    if I try to use for loop it shows an error.
    I tried and tried, but I couldn't see your monitor screen from here. I think you'll need to post the loop code, preferably wrapped in a SSCCE, along with the error text (copy and paste -- don't paraphrase).

    Also, read the API for DefaultTableModel and JTable, and go through the tutorial on How to Use Tables.

    db

  7. #7
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

Similar Threads

  1. JTable
    By riddhishah28 in forum AWT / Swing
    Replies: 2
    Last Post: 02-19-2011, 08:24 AM
  2. Jtable
    By dhaivat in forum AWT / Swing
    Replies: 2
    Last Post: 03-01-2010, 01:20 AM
  3. Adding New JTable in JTable
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 01-27-2010, 09:27 AM
  4. Replies: 2
    Last Post: 05-15-2008, 11:15 AM
  5. How to add in a new row in Jtable?
    By Ry4n in forum AWT / Swing
    Replies: 0
    Last Post: 01-18-2008, 01:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •