Results 1 to 4 of 4

Thread: JTable

  1. #1
    hedonist is offline Member
    Join Date
    Jun 2009
    Posts
    35
    Rep Power
    0

    Default JTable

    Hi,
    I have a JTable called 'table'. The table has four columns and some rows.
    The columns are "firstName", "lastName","address"," married". firstName, lastName and address are textFields, married is a checkBox.

    I have inserted some data into the table. Now, when i click into a particular row of the table, i want the firstName, lastName, address and married to show their information in the respective textField and checkBox.

    I have added a mouseEvent to the table and tried to use table.getSelectedRow() and table.getSelectedColumn(), but it doesn't work. They give a single cell position at a time and i cannot manipulate them.

    I will highly appreciate any help
    thank you.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    837
    Rep Power
    6

    Default

    Could u paste ur code using code tag?
    Ramya:cool:

  3. #3
    Join Date
    Oct 2009
    Posts
    88
    Rep Power
    0

    Wink

    uset the logique as follow
    Event is mouse clicked
    Example:
    private void mousedClicked(evt)
    {
    int rowselected=tablename.getSelectedRow();
    Object textfield1=tablename.getValueAt(rowselected,0);
    Object textfield2=tablename.getValueAt(rowselected,1);
    Object textfield3=tablename.getValueAt(rowselected,2);


    }
    then typecast for String objectname.toString() for string and set value in textfiled
    this can be done by texfieldname.setText(value); in the function of mouseclicked method i hope it will solve problem

  4. #4
    hedonist is offline Member
    Join Date
    Jun 2009
    Posts
    35
    Rep Power
    0

Similar Threads

  1. From txt to JTable.
    By ocean in forum New To Java
    Replies: 3
    Last Post: 10-17-2009, 09:30 PM
  2. Regarding JTable
    By adeeb in forum AWT / Swing
    Replies: 12
    Last Post: 06-19-2008, 07:39 AM
  3. Regarding JTable
    By adeeb in forum SWT / JFace
    Replies: 0
    Last Post: 06-18-2008, 06:13 PM
  4. Replies: 2
    Last Post: 05-15-2008, 10: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, 12: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
  •