Can't scroll to last row in a JTable

I am having great difficulty in getting a scrollable
JTable to scroll to the very last row.
I've done the following:
int lastRowIndex = table.getRowCount() - 1;
Rectagle rect = table.getCellRect(lastRowIndex);
table.scrollRectToVisible(rect, 0, true));
BUT, it always scrolls the the row just prior to
the last... never the last. I've checked, and my
lastRowIndex is correct. I've even tried something
as stupid as just increasing lastRowIndex by 1,
and it still does not work.
So, I am at a loss as to why this does not work.
b.c

Moving the scroll bar to the bottom (maximum) had
no effect. In fact, doing that alone ought to
acheive the same goal.
However, I have discovered that if I do either
(move scroll bar or set viewport to last cell's
rectangle) TWICE, it works.
I speculate that there is some kind of latency
in the GUI "knowing" what the maximum extent really
is. Trying to move to the end the first time fails,
but it does cause the GUI to refresh itself
immediately afterwards so that if I try this a
second time, it works.
I can achieve the same results if I simply
***force a re-paint before attempting to move
the the last cell***. Then, it works.
So, my solution was to do the following:
__ int lastRowIndex = myTable.getRowCount() - 1;
__ if (lastRowIndex > -1)
_____ // repaint the window first.
_____ Rectangle bounds = getBounds();
_____ bounds.x = 0;
_____ bounds.y = 0;
_____ paintImmediately(bounds);
_____ // Now, move to the last row
_____ bounds = myTable.getCellRect(lastRowIndex, 0, true);
_____ myTable.getScrollPane().getViewport(
_____ ).scrollRectToVisible(bounds);

Similar Messages

  • How can I delete the last row of a Matrix

    Hi All,
    Does anyone know whether deleting the last row of a matrix controlled by a UDO child table gives problems? I have the strange effect that I cannot delete the very last existing row in the matrix, i.e. after updating the delete the last to-be deleted row comes back into my matrix !!
    I give you a snippet of my code (function getSelectedRow gives the selected row in the matrix):
    ==
    if (evnt.ItemUID.Equals(ViewConstants.Items.DELETEBUTTON))
      if (evnt.EventType == BoEventTypes.et_ITEM_PRESSED)
        if (evnt.BeforeAction)
          form = BusinessOne.Application.Forms.Item(formUID);
          mtx = (Matrix)form.Items.Item(ViewConstants.Items.MATRIX).Specific;
         int numRow = getSelectedRow(mtx);
         if (numRow != -1)
                                            mtx.DeleteRow(numRow);
                                            form.Mode = BoFormMode.fm_UPDATE_MODE;
                                       Item btn = (Item)form.Items.Item(ViewConstants.Items.ADDBUTTON);
                                       btn.Enabled = true;
    ==
    Cheers,
    Marcel Peek
    Alpha One
    Message was edited by: Marcel Peek
    Message was edited by: Marcel Peek

    Yes, there is a problem to delete the last row.
    It is fixed in version 2005.

  • How to test to see if the cursor is on the last row in a jTable?

    I like to know how to test the cursor position in jTable.

    From the many topics you post here, I can see that you are thinking in the wrong terms.
    Although it's possible, you should not test if the current row is the last one in a JTable. Instead you should test whether or not the current row is the last one in a VO instance, to which any particular JTable's model is bound.
    So, please read the API documentation for oracle.jbo.ViewObject and oracle.jbo.server.ViewObjectImpl.

  • How can I read the last cell of a JTable that a user Enters data

    I have a one column JTable with several rows that a user enters data to. Upon entering the last data, the user clicks a button to read all the data from the rows in the JTable and puts them in an arraylist. If the user does not click enter or navigates away from the last cell, then after clicking the button it does not read the last cell entered. Since the user is clicking on a button to indicate he is done entering data on the table, does he also have to hit the enter key to indicate he is done entering the data?
    The code below is my tablemodelListener:
    public class InteractiveTableModelListener implements TableModelListener {
    public void tableChanged(TableModelEvent evt) {
    if (evt.getType() == TableModelEvent.UPDATE) {
    int row = evt.getFirstRow();
    System.out.println("Update row:"+" "+row);
    jTable1.setRowSelectionInterval(row, row);
    }

    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
    In the future, Swing related questions should be posted in the Swing fourm. (This question has been asked and answered dozens of times).
    But there is not need to repost because [Table Stop Editing|http://www.camick.com/java/blog.html?name=table-stop-editing] explains whats happening and give a couple of solutions.

  • How can I add a new row in a JTable dynamically?

    Dear Sir(s)
    I want to add a new row in a Jtable as I press enter key the time focus is on the last cell of the row? pls help

    TomDooley wrote:
    Hello,
    ...I write directly to a cvs file ...my loop slows down to 0.2 Hz
    Writing a series of 5 values to a file should not take so long. There is probably something wrong in the way you are saving your data. May be you should post a simplified version of your vi, so we could see how to improve your code.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • ALV Scrolls to last row

    Hello everybody,
    I have a problem with my WebDynpro ALV. When I am using the calculation functions the ALV scrolls down to the totals line. When I set "Display Calculations at Start of Table" it scrolls to the first row in the Table (which is in fact the behaviour I want to achieve).
    Is it possible to convince my ALV to start at the first row and displaying the totals at the bottom of the Table? I have searched in the cl_salv_wd_config_table, but I did not find anything what soved my problem.
    Anyone any ideas?
    Thanks
    Daniel

    Hi,
    Are you using the standard ALV total functioanlity or custom caluculation.
    Can you be more clear in your requriement.
    Check the method cl_salv_wd_config_table -
    IF_SALV_WD_TABLE_SETTINGS~SET_FIRST_VISIBLE_ROW to set the first visible row.
    Regards,
    Lekha.

  • VBS:How can i determine the last row of an excel-sheet

    I want to replace the chn-comments of an datafile. I pick up the chn-names and want to compare them with an excel-file and so get from the excel-file the right chn-comment and store int back in the datafile. my problem is how can i determine where the excelfile-row is on the end to load the loopounter with corr values.
    i know one solution via scan on ascii 13 and 9.but bether is to know immediately the length of the column.
    answers also in german possible.

    Peter,
    Are you using DIAdem's Excel Import Wizard? By "Excel file" do you mean a tab- or comma-delimited ASCII file that Excel can read in easily, or do you mean a file with the extension "*.xls"? You certainly could not search through an *.xls file to find CR/LF characters.
    If you use the ASCII or Excel Import Wizard to create an *.STP file for the "Excel" file in question, then after the *.STP file is loaded you have access to a whole range of variables, starting with Ascii... or Excel... which completely outline the structure of the ASCII or Excel file, including things like the row in which the channel comments are, etc.
    Why don't you send over your Excel file and I'll be able to help you a lot better.
    Regards,
    Brad Turpin
    NI

  • How can I get a Row in a JTable?

    I want to get the Last row in a JTable. How can I get it? Thanks.

    something like
    TableModel tm = table.getModel();
    int rows = tm.getRowCount();
    Object col0Value = tm.getValueAt(rows, 0);
    Object col1Value = tm.getValueAt(rows,1);
    ...

  • Datagrid last row flickering problem.

    Hi,
        I used flex 3.5 datagrid. It is a complex datagrid with lot of itemrenderers and itemeditors.when my datagrid has vertical scroll and when i scroll datagrid, last row keep on flickering.
         any idea or solution for this problem?   

    my grid contains 6 columns. Among 6, some of the column texts are  visible some of them hided.
    it is only happens to last row of the Datagrid.
    This is happened when i scroll my datagrid vertically.

  • Getting the Selected Row from a JTable

    hi,
    how Can i get the Selected row from a JTable
    thanks...

    You know that JTable class? Well, you see those methods in it called "getSelectedRow()" and "getSelectedRows()"...?

  • How to auto scroll a table to last row when using Active Data Service?  11g

    Hi all,
    Has anyone got any experience with the ADF Active Data Service?
    I am using an af:table in combination with the ADF Active Data Service and I want the table to scroll to the latest row when new data arrives.
    It is basically a simple setup:
    The value attribute of my table points to a bean that extends CollectionModel and implements ActiveDataModel. This works perfectly. A soon as I receive new data in my bean, the table is automatically updated (e.g. a new row is inserted). I use JDev version: 11.1.1.3
    The problem is that I can not get the scroll bar to move down to the last row automatically when new data arrives. The auto scroll only works for the client that actually performs a submit. In other words the person that submits the new data, will see his scrollbar move down, this is because I added the following code:
    RowKeySet rowkeysset = chatTableBinding.getSelectedRowKeys();
    rowkeysset.clear();
    rowkeysset.add(getRowKey());
    AdfFacesContext.getCurrentInstance().addPartialTarget(this.chatTableBinding);
    This does not work for the clients that receive the new data via the Active data model. Apparently the active data service partially refreshes the table, but not in such a way that it sets the selected row to the last row?
    My table definition:
    <af:table value="#{pageFlowScope.chatBean.instantMessagingChatwindowBean}" var="row"
    id="t1" columnStretching="last" rows="10"
    styleClass="AFStretchWidth" autoHeightRows="10" contentDelivery="immediate"
    horizontalGridVisible="false"
    verticalGridVisible="false"
    disableColumnReordering="true" displayRow="last"
    rowSelection="single"
    binding="#{pageFlowScope.chatBean.instantMessagingChatwindowBean.chatTableBinding}"
    inlineStyle="height:80px;">
    p.s.
    The table is used to show incoming chat message.
    I am building a chat client (taskflow) in a Webcenter application. The concept is similar of that presented by Lucas Jellemain in his blogpost on building a Google Talk Client http://www.oracle.com/technetwork/articles/jellema-googletalk-094343.html

    Dan,
    This is a thanks for posting your findings. You saved me quite some time.
    <af:selectBooleanCheckbox id="showOnlyActiveSubscriptions" selected="true"
    label="Show only active services:"
    value="#{servicePortfolioBean.showOnlyActiveSubscriptions}"
    autoSubmit="true" />
    <af:table binding="#{servicePortfolioBean.serviceTable}" ...
    partialTriggers="showOnlyActiveSubscriptions">
    Of course, when I add a "ValueChangeListener" to the selectBooleanCheckbox, the PPR stops working. :( I wonder why?

  • Can we scroll to the last page of an alv grid?

    I am dispalying a report in ALV grid format - REUSE_ALV_GRID_DISPLAY.
    As soon as the execute button is clicked it should show the last page with the totals.
    User will then scroll upwards to see the details.
    How to scroll to the end of the ALV grid?
    (It is like goign to the last page of course)
    Thanks,
    Ven

    Hi,
    Yes..You can do it using the OO ALV...You can use the method set_current_cell_via_id ..to show the last record.
    Check this example.
    * Declarations.
    DATA: l_lines TYPE int4,
          l_row_no TYPE lvc_s_roid.
    DATA: ok_code LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'CONTAINER1',
          g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gs_layout TYPE lvc_s_layo.
    DATA: gt_outtab TYPE TABLE OF t001w.
    DATA: v_count TYPE i.
    *       MAIN                                                          *
    CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'TEST'.
      SET TITLEBAR 'MAIN100'.
    * Create the grid.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
          EXPORTING
            container_name = g_container.
        CREATE OBJECT g_grid
          EXPORTING
            i_parent = g_custom_container.
    * Get the data.
        SELECT * FROM t001w INTO TABLE gt_outtab.
        CALL METHOD g_grid->set_table_for_first_display
          EXPORTING
            i_structure_name = 'T001W'
            is_layout        = gs_layout
          CHANGING
            it_outtab        = gt_outtab.
        DESCRIBE TABLE gt_outtab LINES l_lines.
    * Go to the last row.
        l_row_no-row_id =  l_lines.
        CALL METHOD g_grid->set_current_cell_via_id
          EXPORTING
            is_row_no = l_row_no.
      ENDIF.
    ENDMODULE.                    "pbo OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      CASE sy-ucomm.
        WHEN 'EXIT' OR 'BACK'.
          PERFORM exit_program.
      ENDCASE.
    ENDMODULE.                    "pai INPUT
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      LEAVE PROGRAM.
    ENDFORM.                    "exit_program
    Thanks
    Naren

  • Sqlldr - can you skip last row from a data file

    Hi
    I need to skip last line from the data file when I load the data into the tables. Is that possible to do using sqlldr, if yes How?
    Also, the first row in the data file, which has a single column needs to be loaded into all the rows of the table. How can i do that?
    Example
    020051213
    1088110 0047245 A 000000000000GB 00000496546700
    1088110 0719210 A 000000000000GB 00001643982200
    1088110 0727871 A 000000000000GB 00000083008900
    9010163
    The first line needs to go into all the rows, and the last row needs to be skipped. Remaining can be loaded normally. I think this would take multiple loads. Can anybody please help.
    TIA

    here i am sending a control file sample which use the when clause
    in sql loader
    load data
    infile 'load_4.dat'
    discardfile 'load_4.dsc'
    insert
    into table sql_loader_4_a
    when field_2 = 'Fruit'
    field_1 position(1) char(8),
    field_2 position(9) char(5)
    into table sql_loader_4_b
    when field_2 = 'City'
    field_1 position(1) char(8),
    field_2 position(9) char(5)
    )

  • How to display the last row in a table

    I have a table that is constantly updating, and I always want to see the last row. How can I get my table to auto scroll?

    Hi žabić,
    there is a property called "top left visible row". You can use it to scroll your table.
    edit:
    Maybe this is not the exact name, but you can see an example here
    Mike
    Message Edited by MikeS81 on 05-27-2010 03:57 PM

  • Lock datagrid last row with agregates (don't know what to do next :( )

    Hi,
    I have been googling for 2 hours and have been reading some forum posts, etc... but can't get this thing working. It seems an important flaw in datagrid, because I'm sure lota peopple needs this, but I've not found a good solution.
    What I need to do is add a row of agregates to a datagrid that contains flat data (it must be last one, and locked, I mean, must not scroll). I have been reading about this:
    http://blogs.adobe.com/aharui/2008/03/flex_3_datagrid_footers.html
    But this makes the row separated from the grid, I mean, It is not really a datagrid row. Other problems arise using this implementation like, impossibility to keep last row aligned with datagrid columns when scrolling (I need to scroll because I have lota columns), etc...
    So, could anybody please help here to accomplish this? I think it is a pretty common task and it is a bit dissapointing it can't be done easily with flex.
    Thanks in advance,
    Aron.

    I haven't seen this done.
    You can add a summary row fairly easily using the Advanced Data Grid:
    http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_10.html

Maybe you are looking for

  • FS-CD dunning block report

    Dear all, I need a transaction or report in FS-CD so that I can see the insurance objects and contract accounts are blocked for dunning. Can you please help me on this Thanks, Latifaa

  • Something's wrong with iPodService...

    After many days trying to get iTunes launched (It Actually did launch but with a delay of...3 minutes!!!)I found out that I needed to start iPodService before and just then iTunes would start. OK now it works, but it's kind of anoying... Could anyone

  • FIELD FOR PAYMENT IN INVOICE

    Dear experts, I have to create a template for an invoice. I have a problem. In the combo box where there is the list of the tables, I can't find the INV3 table. I need some values of this one. How can I do to solve this problem? Thanks.

  • Oracle 10g on AMD 64

    I am really going crazy. I have installed Oracle 9 and 10 on Solaris SPARC for years with no issues. However I now have to install it on a AMD 64bit server for a special project our University is doing. I have checked packages: rpm -q binutils compat

  • I have an AMD Sapphire 7950 3GB GPU and Creative Cloud, but Mercury Playback still says software only

    I have an AMD HD Sapphire 7950 3GB GPU and Creative Cloud, but Mercury Playback still says software only. I thought CC allowed you to bypass the "whitelist" even though my card is listed as supported here on the site. Playback without it jerky on 4k