How to select a row in JTable

Hello,
I have a problem selecting a row in a JTable.
I use
mytable.getSelectionModel().setSelectionInterval(row, row);
to select a row, but after that this row is only highlighted. After calling this method I cannot change the selection using the arrow keys.
Can anybody give me a hint, how I can get the row selected, so that I can use the arrow keys immediately after selecting the row?
Any help is welcome.
Thanks,
Fritz

Hello,
I got the solution:
final int pRow = row;
final int pCol = column;
final JTable myTable = mytable;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
myTable.requestFocusInWindow();
myTable.changeSelection(pRow, pCol, true, true);

Similar Messages

  • How to select a row in Jtable at runtime

    how to select a row in Jtable at runtime.

    use
    setRowSelectionInterval(int fromRowIndex, int toRowIndex);example if your table has 10 rows then u want to select the rows from 4 to 8 then use
    setRowSelectionInterval(3, 7);if you want to select just one row for example 5 then use
    setRowSelectionInterval(5, 5);

  • How to select a row in JTable for right mouse click ?

    Hi All,
    I need to select a row on JTable for right mouse click ?
    Can any one help me ?
    Thanks a lot.
    Seelam.

    Got solution...
    tabel.addRowSelectionInterval(..) works.
    thanks.

  • How to select first row of JTable by default

    Hi,
    I have a JTable with 5 rows.
    When the software starts, none of the rows are selected.
    I wish to keep the first row selected by default.
    How do I do it?
    I couldnt find any method like setSelectedRow() !!!
    Does anyone have a sample code plz?
    Thanks.
    Anuj

    couldnt find any method like
    setSelectedRow()You need to use getSelectionModel() first.
    Another way is to use:
    table.changeSelection(0, 0, false, false);

  • How to select a row in datagrid by checking the check box in that row

    how to select a row in datagrid by checking the check box in that row.
    Im using <html:checkbox> tag, and also a VO which is in request scope. i wanna display the values in the VO in a row and corresponding to this i want a checkbox..
    Thanx in advance
    Message was edited by: me
    Hemanth@SA
    Message was edited by:
    Hemanth@SA

    Hello,
    I got the solution:
    final int pRow = row;
    final int pCol = column;
    final JTable myTable = mytable;
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    myTable.requestFocusInWindow();
    myTable.changeSelection(pRow, pCol, true, true);

  • How to select multiple row in ALV report

    Hi friends,
    1. How to select multiple row in ALV report
                   ( How to set tab in ALV report and want to select multiple line.)
    Thanking you.
    Subash

    Hi Sahoo,
    If you are using the class CL_GUI_ALV_GRID. In methods SET_TABLE_FOR_FIRST_DISPLAY.
    in layout structure you will find field SEL_MODE
    pass :
    LS_LAYOUT-SEL_MODE = 'A'.
    In PAI.
      CALL METHOD GRID->GET_SELECTED_ROWS
        IMPORTING
          ET_INDEX_ROWS = T_ROWS
          ET_ROW_NO     = T_ROWID.
    Hope these will solve your problem.
    Regards,
    Kumar M.

  • Urgent :  how to select the rows in the ALV Grid Control

    How to select the rows in the ALV Grid control,
    I am facing the situation where i need to select the row/rows in the Grid control and then to lock the entries,
    If anyone have the solution please help me out
    <b>Its very Urgent</b>

    Hi Bharath,
    Go through this hope u can understand.
    SEL_MODE. Selection mode, determines how rows can be selected. Can have the following values:
    A Multiple columns, multiple rows with selection buttons.
    B Simple selection, listbox, Single row/column
    C Multiple rows without buttons
    D Multiple rows with buttons and select all ICON
    Setting and getting selected rows (Columns) and read line contents
    You can read which rows of the grid that has been selected, and dynamic select rows of the grid using methods get_selected_rows and set_selected_rows. There are similar methods for columns.
    Note that the grid table always has the rows in the same sequence as displayed in the grid, thus you can use the index of the selected row(s) to read the information in the rows from the table. In the examples below the grid table is named gi_sflight.
    Data declaration:
    DATA:
    Internal table for indexes of selected rows
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    Example 1: Reading index of selected row(s) and using it to read the grid table
      CALL METHOD go_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines = 0.
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
             EXPORTING
                  textline1 = 'You must choose a valid line'.
        EXIT.
      ENDIF.
      LOOP AT gi_index_rows INTO g_selected_row.
         READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
        ENDIF.
      ENDLOOP.
    Example 2: Set selected row(s).
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines > 0.
        CALL METHOD go_grid->set_selected_rows
            exporting
              it_index_rows = gi_index_rows.
      ENDIF.
    Reward points if helpful.
    Thanks
    Naveen khan

  • How to set special rows in jtable not selectable

    Hello programmers,
    anybody knows how to set special rows(p.E. row 0) in jtable not selectable.
    in advance thanks for your answers

    table = new JTable(...)
         public void changeSelection(int row, int column, boolean toggle, boolean extend)
              if (row == 0)
                   return;
              else
                   super.changeSelection(row, column, toggle, extend);
    };

  • How to select multiple rows from List Of Values

    Hello,
    I use ADF 11g to create my list of values (LOV). I want to select multiple rows from it. but i can't.
    so how i can select many rows to set them in my adf table.
    Thank in advance

    Hi,
    LOV is map to an attribute in the viewObject so it will return only one value or more values from selected row. You can't select multiple rows from LOV.
    But you can do this by using popup which you can select multiple rows and insert the selected rows to another table.
    This blog post explain how to achieve this :
    http://husaindalal.blogspot.com/2009/11/search-from-popup-and-add-to-new-table.html#comments
    Sameh Nassar

  • How to select a row in a single-select table view?

    Hello folks,
    I have a table view with a 'details' button. When a row is selected and 'details' is pressed, the table view disappears and a form view is displayed (like the toggle button in PCUI). I have implemented this using a navigation link. When I press 'cancel' in the form view, another navigation link takes the user back to the table view.
    My problem is, when the table view reappears, there is no row selected (the row that was selected previously, is de-selected). How do I make sure that the row remains selected?
    I tried using the collection_wrapper->mark() method in the inbound plug of the table view, but it works only for multi-select table.

    Hi Masood,
    Thanks for your reply.
    I had already tried using MARK ( iv_index = lv_index ), but it did not work because the first statement in the MARK method is
      check ME->MULTI_SELECT = ABAP_TRUE.
    Mine is a single-select table. So, using the MARK of the iterator object, with either the IV_BO or the IV_INDEX parameter also does not work. Is there any other way for a table with single row selection?
    Thanks!!!
    Rohan.

  • How to select JLabel inside a JTable

    hi all,
    I have a Jtable which has own renderer so it can store components in it. I have added a Jlabel one of its cells but when I select that row the label stays upon the selected background color. here is a sample screenshot to decribe my problem clearly [http://www.imagecross.com/06/image-hosting-view-01.php?id=6570label.jpg]
    is there any way to select the label inside selected background color.
    - I have already tried to make the label not opaque but it didnt work -
    thanks...

    I have added bold parts of the code below. if you use other components you can make a type casting and do what you want.
    thanks again..
    class ComponentRenderer *extends JComponent*  implements TableCellRenderer
        public Component getTableCellRendererComponent(JTable table, Object value,
              boolean isSelected, boolean hasFocus, int row, int column) {
        *     JLabel l = (JLabel)value;*
        *     if(isSelected) {*
        *          l.setForeground(Color.BLUE);*
        *          l.setOpaque(true);*
        *          l.setBackground(new Color(184, 207, 229));*
        *     else {*
        *          l.setForeground(Color.BLACK);*
        *          l.setOpaque(true);*
        *          l.setBackground(Color.WHITE);*
            return l;
        /*public ComponentRenderer() {
    }

  • How to select a row in LSMW

    Hi,
    I have a requirement to create new materials copying from exsting material.For this we have custom transaction which will display all the materials in a plant in the table cotrol.Now in this table control i have to select a material based on the input file material.
    can any one please tell me how to select a particuler row in table control In lsmw.
    Thank you.
    CS Reddy.

    hi
    Using the read statement. y bcoz u r putting data in an internal table for a table control. so u want to retieve a particular row so use index position along with read statement.
    if it is useful,please reward points.
    Regards,
    satish

  • How to remove a row from JTable

    Hi!
    I'm used to remove rows from JTables getting the model and doing a removeRow(num) like this:
    ((DefaultTableModel)jTable1.getModel()).removeRow(0);
    But with ADF and JDeveloper the model says it's a JUTableBinding.JUTableModel but its not accessible.
    How to remove a row in Jdeveloper 10.1.3.4.0?

    Or maybe is just better to refresh data in the jTable but I do not know either like doing it.

  • HOW TO SELECT ALL ROWS IN A MULTI SELECT TABLE!!!!!

    Hello
    I have a table with tableSelectMany component. how can I set the page to initially select all rows when first opened?????

    efffffttttttt? are you saying you will do an electronic funds funds funds funds funds transfer transfer transfer transfer transfer transfer to anyone who answers?
    What version of JDeveloper are you using - that is quite important in order to be able to give you an answer.
    What also might be useful is "please" and "thank you" instead of SHOUTING IN ALL CAPS THAT YOUR QUESTION IS IMPORTANT. Realizing that you asked this question over a weekend when most people dont sit and read the forum...
    You have a habit of saying all your questions are URGENT!!!!!! which is generally considered, um...., impolite.

  • How to select a row dynamically in a TreeTable?

    I am trying to select a row in a treeTable when the user right clinks on a row. how I do this? I tried giving the following. I don't see visually that the row is selected. What I try to achieve this?
    ....me.getX() here "me" is the MouseEvent. I see the selRow has the right value too but can' tsee it visually the selected row.
    int selRow = treeTableData.rowAtPoint(new Point(me.getX(),me.getY()));
    treeTableData.setRowSelectionInterval(selRow,selRow);
    treeTableData.repaint();
    treeTableData.updateUI();
    component = me.getComponent();
    popEditor.show(me.getComponent(), me.getX(), me.getY());

    use
    setRowSelectionInterval(int fromRowIndex, int toRowIndex);example if your table has 10 rows then u want to select the rows from 4 to 8 then use
    setRowSelectionInterval(3, 7);if you want to select just one row for example 5 then use
    setRowSelectionInterval(5, 5);

Maybe you are looking for

  • Oracle 8.1.7.3

    is there any patch release for Pro*C for oracle 8.1.7.3 . Please let us know the version if there is one. Thanks & Regards Saroj

  • Nano -no sound from Bose docking station

    My nano plays sound thru headphones but there is no soung when used on Bose station.It is not the station as I have another nano which plays on it. I have sent the problematic nano back to apple but they found no fault.Ant ideas?

  • Pulling Music Off Of An Old iPhone?

    My partner is currently using an old iPhone as an iPod, and it houses the vast majority of his music, but all of that music isn't backed up on a computer nor is it all from iTunes. Is there any way he can pull the music off of the iPhone safely, sinc

  • FW: (forte-users) Copy Input parameter

    Peter, That is the behaviour that I have experienced also, so I do not have such (anchored service object) attributes in my classes anymore but instead add that service object attribute as an input parameter to all methods in that class that require

  • Layer Name Max Length

    Just tried out the Photoshop CC Image Asset Generation and it rocks. However, I can only add up to so many characters for names of the layers. Is there a way that the limit can be lifted. I think this would be beneficial especially for all the differ