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);

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 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);

  • How to select first row of each group in a group by statement

    Table            
    ProdCode    PackType    BatchCode    ExpDate
    BURSLO               1             BS20GO-2001    01/12/2004
    BURSLO               1             BS20GO-2011    01/01/2007
    BURSLO               2             BS20GO-2027    01/02/2003
    BURSLO               3             BS20GO-2060    01/02/2004
    BURSOI               9             BU10F12    01/02/2006
    BURSOI               9             BU10GO-1301    01/05/2005
    BURSOI              11             BU10GO-131    01/06/2008
    BURSOI               2             BU10GO-1311    01/06/2007
    BURSOI              13             BU10GO-1328    01/07/2006
    Output            
    ProdCode    PackType    BatchCode    ExpDate
    BURSLO               1             BS20GO-2011    01/01/2007
    BURSLO               2             BS20GO-2027    01/02/2003
    BURSLO               3             BS20GO-2060    01/02/2004
    BURSOI               9             BU10F12    01/02/2006
    BURSOI              11             BU10GO-131    01/06/2008
    BURSOI               2             BU10GO-1311    01/06/2007
    BURSOI              13             BU10GO-1328    01/07/2006
    i need first row after group by ProdCode,    PackType and decreading order of ExpDate
    Please Help me.
    Thanks.
         

    Try the below:
    ;With cte
    as
    (Select *,Row_Number()Over(partition by Prodcode,Packtype Order by expdate desc) Rn From Tablename)
    Select * From cte where rn=1

  • How to make first row of JTable bold

    I am working with JTable and unable to change to 1st row to BOLD

    harshal_2010 wrote:
    hi codingMonkey I know that u r very smart guy who doesn't know anythingWow! Could you really deduce that from a simple 'Why?'. Brilliant; absolutely phenomenal!
    Oh, and by the way, I hope you like helping yourself. Saying "Hey, you stupid ugly jerk, will you help me with my question?" generally doesn't go down well on these fora.

  • How to make first row as selected in af:table

    Hi,
    I am using JDeveloper 11.1.1.4 and ADF-BC in my application.
    In all the pages across my application we have multi select enabled for the table[af:table].
    But when the pages are displayed,the first row is not selected by default.
    My requirement is to display first row as selected across all the tables in my app.
    I have the selectionListenerset as for example selectionListener="#{bindings.RSCMapVO2.collectionModel.makeCurrent}" in all the pages.
    Please suggest on how to make first row as selected.
    Regards,
    Praveen

    Hi
    Put these codes in your selection listner method(You have to define a selectionListner method in your backing bean and put this code segment
    (Special thanks go to Franks how posted this code segment. threadID=1089583)
    RichTable yourTable = (RichTable) selectionEvent.getSource();
    //the Collection Model is the object that provides the structured data
    //for the table to render
    CollectionModel yourTableModel = (CollectionModel) yourTable.getValue();
    //the ADF object that implements the CollectionModel is JUCtrlHierBinding. It
    //is wrapped by the CollectionModel API
    JUCtrlHierBinding yourTableBinding = (JUCtrlHierBinding) yourTableModel.getWrappedData();
    //Acess the ADF iterator binding that is used with ADF table binding
    DCIteratorBinding yourTableIteratorBinding = yourTableeBinding.getDCIteratorBinding();
    //the role of this method is to synchronize the table component selection
    //with the selection in the ADF model
    Object _selectedRowData = yourTable.getSelectedRowData();
    //cast to JUCtrlHierNodeBinding, which is the ADF object that represents
    //a row
    JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding) selectedRowData;
    //get the row key from the node binding and set it as the current row in the
    //iterator
    Key rwKey = nodeBinding.getRowKey();
    tableIteratorBinding.setCurrentRowWithKey(rwKey.toStringFormat(true));
    Thanks
    Padma

  • 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.

  • How to display first row value returened from a query as checked as default in a report

    How to display first row value returned from a query as checked as default in a report
    Example
    Parameter 1
    Paramerter2
    ABD
    x(checked)
    Test
    DEF
    JMG
    Mudassar

    Hi Mudassar,
    The issue is caused by the order in which the parameters appear in the report data tab can be difference between our report execution and it failing. In other words, “Parameter2” is execution before parameter “A” due to this issue. We can adjust the parameter’s
    order to solve the issue.
    If “Parameter2” is parameter “A”, we cannot use that expression. Because fields cannot be used in report parameter expression, if we want to display the first value returned from a query as default value, we have to fill the “Specify values” text box with
    the specific value in Default Values dialog box.
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • Af:inputListOfValues popup : selecting first row

    Hi,
    Is there a way to select first row inside lov popup, the by default behaviour is it selects the rowHeader rather than row itself.
    When the lov popup is opened , there is no focus on table resides in the popup
    - to focus on table, user has to press down arrow key - which will just focus on rowHeader and not the actual row itself
    - to focus row for currently selected rowHeader user has to press right arrow key which will then select the table row itself
    its cumbersome everytime when you open lov and do these extra steps to just to select a value from lov
    any ideas?
    Thanks,
    Dev

    so, why it supports keyboard navigation at all? either support full features or nothing. the fact that user can use up/down arrow keys which selects rowHeader of every row , rather than actual row
    regarding "Search and Select : " it could be anything it has nothing to do with row selection,
    Thanks,

  • 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 disable first row selection in a table

    Hi,
    I have three tables which have master child relationship. I need to enable a button for each table based on row selection of corresponding table.But first row is being selected automatically and the buttons are enabled.
    what should i do in order to avoid first row selection in a table.I tried by removing selected Row Keys.But still i am getting the same problem.can anyone suggest on this.
    Thank You,
    Sukumar

    I know a hack but I don't recommend it, anyway here it goes:
    Remove selected Row Keys
    Change selectionListener from the default and create a custom action listener (You can call the default one inside of it) (Tip: use makeCurrent function in this PDF
    This will make sure that there is no selected row highlighted for the first time, but it actually means that the first row is selected, it's just not shown.
    This method is tested with 11.1.1.7

  • 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.

Maybe you are looking for

  • ITunes library file cannot be saved. You do not have enough access privileges for this operation.

    iTunes suddenly give me the above error message and doesn't register playcounts and imports. Who can help?

  • Type mismatch in assignment statement

    Hi all, Here my problem tcrComp1.method = method.selectedItem; In the left side:: tcrComp1: an object of type TCRComponents method : is an attribute of type String In the right side:: method : is a comboBox that includes an array of Strings like <mx:

  • FCC : use of  recordsets per message

    Hi experts, what is the use of Recordsets per message in FCC, where we will use this option, in what type of situations we will use... Thx in Advance John

  • KANBAN External Supplier with MRP

    We have a requirement to use KANBAN for external vendors and also do forecasting for same materials using MRP. Does standard SAP support this? We are using replenishment strategy 02 ( with SA's ) but it is not working. Any ideas ??

  • ITunes has stopped recognising my iPod 80GB!

    Hi, I was wondering if anyone could please help me. My iPod wiped itself of all it's music yesterday so i thought I will plug it back in and restore it to it's original settings. Although Windows still recognises it, iTunes won't. I have already trie