How to select a particular row in a JTable?

I want to select a particular row in a JTable. i.e something like
table.setSelectedRow(arg)how can i do it.

You can use
table.getSelectionModel().setwhateverIsInTheAPI(...)
depending on your selection mode.Thanx,
but i don't want to change the selectionMode, i
want to select a particular row thro program.
This is like list.setSelected(index) in
JListThe original poster was pointing you in the right direction. You have to use the SelectionModel when you want to work with the selected indexes of a JTable. It will return a ListSelectionModel, which will be an instance of DefaultListSelectionModel unless you implemented your own. Refer to the API for the appropiate method(s).
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/ListSelectionModel.html

Similar Messages

  • How to select a particular row in grid?

    I am trying to generate a user defined CFL form which should work exactly as system CFL. Using Matrix takes minutes to load the query's output so I m using grid instead and passing the query as a parameter to datatable. is there any way to select a particular row in grid through SDK ? for matrix , it cud be written like 'matrix.selectrow(). doesn't seem to have such property for grid. Any help on this will be appreciated.
    Thank you..

    hi
    oGrid.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Single;
                        oGrid.Rows.SelectedRows.Add(pVal.Row);
    i think that will help you
    Regards,
    Rajesh Saini

  • How to disable a particular row in a JTable

    How can a disable only a particular row/column in a JTable.
    I am trying to create an XML Notepad type of application for which I need the row which contains the root element or any element which has a child element to be disabled. How can I achieve this??
    I would be grateful for replies.

    Hi,
    Create your own class which extends TableModel and in that class u override the method
    public boolean isCellEditable( int row, int col)
    As u know the row and col which u want to disable hard code those values in the method.
    Like
    public boolean isCellEditable( int row, int col)
    if( row == 2 and col == 1 )
    return false
    else
    return true
    Hopefully this provides u with a solution.
    Cheers :)
    Nagaraj

  • How to delete a particular row in ALV table

    Hi,
    How to delete a particular row in ALV table based on some condition(by checking value for one of the columns in a row)
    Thanks
    Bala Duvvuri

    Hello Bala,
    Can you please be a bit more clear as to how you intend to delete the rows from your ALV? By the way deleting rows from an ALV is no different from deleting rows from a normal table. Suppose you have enabled selection property in ALV & then select multiple rows and click up on a button to delete the rows then below would be the coding: (Also keep in mind that you would have to maintain the Selection property of the context node that you are binding to your ALV to 0..n)
    data : lr_table_settings  TYPE REF TO if_salv_wd_table_settings,
                 lr_config          TYPE REF TO cl_salv_wd_config_table.
      lr_table_settings  ?= lr_config.
    ** Setting the ALV selection to multiple selection with no lead selection
      lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).
    Next delete the selected rows in the action triggered by the button:
    METHOD onactiondelete_rows .
      DATA:  wd_node TYPE REF TO if_wd_context_node,
             lt_node1 TYPE ig_componentcontroller=>elements_node,
             wa_temp  TYPE REF TO if_wd_context_element,
             lt_temp  TYPE wdr_context_element_set,
             row_number TYPE i VALUE 0.
      wd_node = wd_context->get_child_node( name = 'NODE' ).
      CALL METHOD wd_node->get_selected_elements
        RECEIVING
          set = lt_temp.
      LOOP AT lt_temp INTO wa_temp.
        wd_node->remove_element( EXPORTING element = wa_temp ).
      ENDLOOP.
      CALL METHOD wd_node->get_static_attributes_table
        EXPORTING
          from  = 1
          to    = 2147483647
        IMPORTING
          table = lt_node1.
      wd_node->bind_table( new_items = lt_node1 ).
    ENDMETHOD.
    If in case this isn't your requirement please do let me know so that I can try come up with another analysis.
    Regards,
    Uday

  • How to edit a particular row in the table ctrl when a push button is clickd

    Hi Experts,
    How to edit a particular row (except the Primary keys) after selecting it in the TABLE CONTROL when a
    push button is clicked in the table control.
    For Eg. If you have a push button say "Modify", the particular row what we select in the table control should be in a
    editable mode after clicking "Modify" Push button.
    Please help me out.
    Thanks in advance.

    Hey Ram,
    Thanks a ton.
    Its working fine...sorry for the late reply.
    The reason behind the delay is because i had modified my code as per your logic it worked fine but the thing is that the whole column was in editable mode but not a single row.
    For E.g  If i want to edit a particular row, first i select the row and then  click on "Modify" button. After i click on the button, the whole column gets in a editable mode including the one which i intentionally selected.
    Here, the solution is that you have to set a flag in PBO so that once it is done with PBO then it need not come back again after we click on "Modify" button.
    And one more query is that after you modify a particular row in the table control ( When it is in editable mode) and click on the "Save" button, it is not getting updated to database.
    To update the database, we need to select the row once again after modifying it and click on the "Save" button.
    Here, database is updating only when it is selected again. If it is not selected, it is not getting updated.
    If you have any alternative solution, then please help me out.( I hope i am clear with the question.)
    Thanks,
    Ananth.

  • Add radioButton to select the particular Row

    Hello
    Team
    I have one af:table componant i want to give the radio button to a row for select the particular row...
    this functionality bydefault added in 10g but..now i am working in 11g,how can i achive this functionality

    Hi,
    this is tricky because it involves manual coding. You would need to add a radio button. You would use
    http://adfui.us.oracle.com/projects/adf.faces/multiproject/adf-richclient-api/tagdoc/af_selectBooleanRadio.html
    in an extra column and define the group attribute so all rows participate in a single select case. The, when you select a group you need to fire a change event that allows you to determine which radio button is clicked. Based on this information you select the current row in the table. I didn't code this, but this is how I would do it. As said, gows with some coding especially when you nedd to synchronize the radio button with the selction users do by directly clicking into the table
    Frank

  • How to select odd/even rows from table....

    How to select odd/even rows from a table?
    Please help.
    Edited by: vaibhav on May 7, 2012 5:30 AM

    just don't expect the results to come out in the sequence odd, even, odd, even .....
    The answer you have marked correct needs two order by clauses to guarantee that.
    The inner select will return rows in a random order, potentially different each time you run it. The outer select may not return rows in the same order as the inner one.

  • How to diasble selection for particular rows in a Table?

    im currently working on a multiple select table.. i need to disable the checkbox for some particular rows. How can i get runtime control over that cell??

    To disable one or more rows of single or multiple selection in your table, add the following code to your controller processRequest method:
    OATableBean tableBean = ...;
    tableBean.setSelectionDisabledBindingAttr("Disabled");
    In the example above, "Disabled" represents the Boolean view attribute that returns 1/"Y" if one or more rows is (are) to be disabled, otherwise it returns 0/"N". The view attribute "Disabled" must belong to the same view object as the one associated with the table items.
    If its an advanced table, use the same method on OAAdvancedTableBean instead.

  • How to color a particular row in a matrix

    Hi All,
    Using SBO, i am having two queries:
    1. Is it possible to color single row, Cell in a matrix or a grid by any way.
    2. And How to copy particular row from 1 matrix to another?. I want this by using drag n drop event of mouse. Only click and right click mouse events are available in SBO. But I want to use mouse down and mouse up events..Please help me, it's urgent.
    Thanks in advance.

    Hi,
    1) No, unfortunately, you cannot colour either a row or a single cell in the current versions of the matrix and grid controls. As a workaround, I use an image column as the first column in my matrices and then put coloured squares in this column for rows that I want to 'highlight'.
    2) You can't drag and drop using the SBO controls. Personally, I use the right-click event and add a menu option to copy the selected rows to the other matrix and it works fine. Click is the Mouse Down event and Item Pressed is the Mouse Up but it is not fully supported on matrices or grids.
    Kind Regards,
    Owen

  • How to make a particular row and column field editable in ALV

    Hi Experts,
    I have a requirement to make a particular row and column field editable in ALV output. Like i need to make 2nd row - 4th column editable of ALV output.
    Kindly help me out to solve this.
    Any help would be appreciated.
    Thanks,
    Ashutosh

    Hi Ashutosh,
    please check below, explained by some experts.
    In the below link  editing two columns MOD_RANK and TECH_RANK.
    These two columns will be in edit mode once after selecting the required record
    Editing single cell in a row of ALV table
    And also look for more info
    http://scn.sap.com/thread/884976

  • How to select a particular layer in AE?

    Hi,
         I want to select a particular layer in Timeline. Is it possible to select a layer if I have the AEGP_LayerH? I searched in AE_SDK_guide but did not find any function in LayerSuite.
    Any ideas?
    Thanks,
    Dheeraj.

    Thanks Shachar. I checked the collectionSuite but got confused as to how to add items to collection and when to delete the collection. I will try again.

  • How to select all the rows of table control in BDC

    Hi All,
    While I am doing BDC for Transaction Code MC88, After the first screen I will get another screen with tabble control, Here I need to select all the rows of table control, I am assignng the 'X' to the first field of Table Control which is the indicator for selection.
    Here I am getting message called Indicator field is not in program and screen.
    While doing Recording I am not able to record the indicator, Please any one let me know how to record the Entire table control selection.
    Thanks in advance..

    Sorry about that lakshmi. Here is my code.
        PERFORM dynpro USING : 'X'   'SAPMMCP6'          '0105',
                               ' '   'RMCP2-MATNR'       t_matnr,
                               ' '   'RMCP2-WERKS'       t_werks,
                               ' '   'BDC_OKCODE'        '=AKTV'.
        PERFORM dynpro USING : 'X'   'SAPLMCPA'          '0707',
                               ' '   'BDC_OKCODE'        '=MRKE'.
        PERFORM dynpro USING : 'X'   'SAPLMCPA'          '0707',
                               ' '   'BDC_OKCODE'        '=GRAO

  • How to read the particular row in table..

    HELLO ALL
    I have a dynamically generated table which is filled with values
    from a Bean. The next step is to select a row in that table by
    clicking on a check box. The problem is that i want to read 3
    values from the selected row. I can get the value from the checkbox
    button but i always get the values from the first line in the
    table. Is there someway to select an entire row and submit in in
    the request so i can read the values from the selected row?

    Yes,
    but the checkbox values are printing rightly.I mean if user checks 1,5 rowed checkbox in next jsp printing 1 and 3.But the rowed values are printing sequence manner,not the chcked ones.

  • How to select a particular node in a tree?-want suggestions urgent

    i've to make a tree showing "c:\" folder structure of the system. Initially i'm adding the folders in c:\ only tothe tree. And i'm adding the subfolders when ever i select a particular folder. I'm opening the subfolders and inner subfolders of it and so inside like that. now i'm closing the window . i want the tree to reopen with the previously opened level when ever i again run the program. On closing i'm storing the last selected node using tree.getMaxSelectionPath() . And on reopen i'm setting it as tree.setSelectionPath(tree.getMaxSelectionPath()).
    But it is not opening the entire path. it is opening uptop one level only. what to do. Needs suggestion urgently.
    Thnaks for suggestons.

    Hi again,
    I am sorry, I cannot help in another way than looking at the documentation, because I have currently no JDK available here. If expandPath(...) doesn't work, you can try to get all the nodes of that path and expand them from the root node downwards, perhaps that will work.
    greetings Marsian

  • How to Select the Current Row When Using af:iterator?

    Hello all,
    I encounter the following problem when using af:iterator to display data from
    a View Object:
    When trying to display the content of a row via a popup, only the first row is
    returned no matter which row is selected. So a selection of the current row
    should exist or some other method which should allow the access to the
    current row.
    The af:table has a selectionListener attribute which permit to achieve this.
    Does anyone know about some similar attribute or some method for
    selecting the current row when the af:iterator is used?
    Thank you,
    Mirela

    I would be interested in the answer to this basic question as well. I cannot get the selected row value of an attribute in an iterator for a view if I simply set-up a attribute binding to the iterator. It seems that this should be possible. I've had no other option but to obtain the current row and the related attributes programmatically. This works fine, but if there is a more elegant option, then I'd certainly like to use it.
              <af:table value="#{bindings.CompaniesView1.collectionModel}"
                            var="row"
                            rows="#{bindings.CompaniesView1.rangeSize}"
                            emptyText="#{bindings.CompaniesView1.viewable ? 'No data to display.' : 'Access Denied.'}"
                            fetchSize="#{bindings.CompaniesView1.rangeSize}"
                            selectedRowKeys="#{bindings.CompaniesView1.collectionModel.selectedRow}"
                            rowBandingInterval="0" id="tCompanies"
                            summary="Companies"
                            width="100%"
                            rowSelection="single"
                            binding="#{CompanyBackingBean.companiesTable}">Page Def:
        <attributeValues IterBinding="CompaniesView1Iterator" id="Id">
          <AttrNames>
            <Item Value="Id"/>
          </AttrNames>
        </attributeValues>I should be able to get the Id attribute value of the current selected row using "#{bindings.Id}", right? Well, it doesn't work for me. Any ideas?
    Thanks

Maybe you are looking for

  • Computer hangs on AC Power loss on Docking station (Z61p)

    I have a problem that the computer hangs if IU disconnect the power to my docking station similar to: http://www-307.ibm.com/pc/support/site.wss/document.do?sitestyle=lenovo&lndocid=MIGR-69370 Is this a known problem for the Z-series? Any solution?

  • Call search help as seperately

    Hello, May I know if there is possible to call the popup window for search help directly, but not through the input field which uses the search help.Thank you very much! Best regards, Shumin

  • Adjusting different audio clips levels?

    Working in FCP and have a project with a lot of small individual clips of people speaking and each clip is at a different audio level. What's the best and easiest way to adjust the audio on each individual clip without over doing it labor wise? Thank

  • Embedding Windows media play in LabVIEW

    Hi, I´ve tried to play AVIs (coded MPEG4) using ActiveX Plug-in of Windows Media Player.  The problem appears when I change the window appearance property. If the property "window has title bar" is unchecked, the video will not be shown, but the soun

  • MIDI Sounds in Nvidia MCP2-T

    Hello you, I´d like to know if there is a software to change soundfonts in Nvidia MCP2-T sound chip of my Mobo K7N2 Delta ILSR, because I have downloaded several files .sf2 and haven´t found how to use them (maybe it´s not possible). There must been