jtable selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nellu
    New Member
    • Oct 2006
    • 6

    #1

    jtable selection

    hi to all
    i have a JTable with n Rows and 5 Cols.
    i want to give search option in my program.
    program select a row dynamically.
    my code is like this
    *************** *************** ***
    table = new JTable( dataValues, columnNames );
    ListSelectionMo del selectionModel = table.getSelect ionModel();
    selectionModel. addListSelectio nListener( this );
    scrollPane = new JScrollPane( table );
    topPanel.add( scrollPane, BorderLayout.CE NTER );
    public void valueChanged( ListSelectionEv ent event )
    {
    if( event.getSource () == table.getSelect ionModel()&& event.getFirstI ndex() >= 0 )
    {
    TableModel model = (TableModel)tab le.getModel();
    String string = (String)model.g etValueAt( table.getSelect edRow(), table.getSelect edColumn() );
    System.out.prin tln( "Value selected = " + string );
    }
    }

    *************** *************** *************** *************
    this code will print the selected value.
    i want to add search option here.
    Depending upon the value the corresponing row should select.
    how to set the row dynamically?

    thanks
Working...