Displaying row numbers in tables

Is there a way to get JTable to display row numbers on the left-most side of the table? Are there any functions in JTable that will allow you to do this?
I am thinking that to do this, I will probably need to add a column to my table model and make the first column and uneditable JLabel that shows the row number.
Thanks for any help.
Mike Ryan

Ok , the class i am pulling this code from is 500+ lines of code, so I will try to pull out only the important pieces.
private DefaultTableModel theNorthernModel;
private JTable theNorthernTable;
private DefaultTableCellRenderer[] theRenderer;
private JScrollPane theNorthernPane;
private Object[] rowTitles = {"1", "2", "3",  "4", "5",  "6", "7"};//
private Object[] colTitles  = {"one","two","three","four","five","six"};
     theNorthernModel = new DefaultTableModel(rowTitles.length,colTitles.length);
          theNorthernTable = new JTable(theNorthernModel);
          theNorthernTable.setCellSelectionEnabled(false);
          theNorthernTable.setEnabled(false);
          theNorthernTable.getTableHeader().setReorderingAllowed(false);
          theNorthernPane  = new JScrollPane(theNorthernTable);
          theNorthernPane.setPreferredSize(new Dimension(600, 150));
//this is the stuff you want          
ListModel listModel = new AbstractListModel() {
             public int getSize() {
                     return rowTitles.length;
            public Object getElementAt(int index) {
                 return rowTitles[index];
        JList rowHeader1 = new JList(listModel);
        rowHeader1.setBackground(theNorthernPane.getBackground());
        rowHeader1.setFixedCellWidth(140);
        theNorthernPane.setViewportView(theNorthernTable);
        theNorthernPane.setRowHeaderView(rowHeader1);
        rowHeader1.setCellRenderer(new RowHeaderRenderer(theNorthernTable));
theRenderer = new DefaultTableCellRenderer[6];
          for(int i = 0; i< 6; i++) {
               theRenderer[i] = new DefaultTableCellRenderer();     
theColumnModel = (DefaultTableColumnModel)theNorthernTable.getColumnModel();
* RowHeaderRenderer renders the panel's rows
class RowHeaderRenderer extends JLabel implements ListCellRenderer {
     * Constructor creates all cells the same
     * To change look for individual cells put code in
     * getListCellRendererComponent method
    RowHeaderRenderer(JTable table) {
        JTableHeader header = table.getTableHeader();
        setOpaque(true);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        setHorizontalAlignment(CENTER);
        setForeground(header.getForeground());
        setBackground(header.getBackground());
        setFont(header.getFont());
     * Returns the JLabel after setting the text of the cell
    public Component getListCellRendererComponent( JList list,
    Object value, int index, boolean isSelected, boolean cellHasFocus) {
        setText((value == null) ? "" : value.toString());
        return this;
}

Similar Messages

  • How to change the number displaying rows in a table

    Hi all,
    i have a table for resources in Debrief Work order (Standard Screen), we need to change the default displaying rows. inistially it displayed 3 empty rows.
    i tried to change the Records Displayed for the table but it did not affect.
    also it is possible to change the "Add 3 rows" button in the table to add for example 5 rows instead?
    any idea?
    Regards,
    Mahdi Charara

    Hi,
    Through personalization we can do.On standared page top right u will find personalization link.click on the clink next expand all there find apporiate table .Here u will fine reorder button set as u want display and save. then u can see the change.For add row functionality u need to extend the co.

  • Displaying Row numbers starting from 1

    Hi every one,
    I want to display row number as see in the report while printing, as I am using the fallowing formula I am getting row numbers including suppress records which I donu2019t want, right now my row number is starting from 10. Instead of 1u2026
    WhilePrintingRecords;
    Numbervar x;
    x:=x+1;
    I want row numbers for only display recordsu2026
    Please help me u2026
    Thanks,
    Krish.

    Krish,
    I am assuming that you are using a conditional formula to suppress the details section. If that is the case then add the conditional suppression logic to your running total formula. For example;
    WhilePrintingRecords;
    Numbervar x;
    If Not (condition for suppression) then x:=x+1 else x;

  • Problem in displaying rows in a table.

    Hi
    i have a query region and a results table .
    i have a details button in results table which will fetch results in to the details table.
    once i click the details button of a selected row i get the results into details table.
    now the problem is after applying (commiting transaction) if i click on the another rows details button details table results are not changing..
    what might be the problem...

    Hi,
    i have a vendor name which is lov item.from there i will get the vendorid
    In islovevent() i am capturing that value and passing the same to the initdetails in amimpl
    which in turn calls initquery in voimpl
    the problem is page details are refrshing fine if i dont add a row to the table .the problem arises only when i add a row...
    when i add a row and try saving it.it saves properly. but when i go to vendor lov and selects another vendor ..the details are remianing same....
    the code i used for above :
    CO CODE:
    if (pageContext.isLovEvent())
    String lovInputSourceId = pageContext.getLovInputSourceId();
    if ("SearchVendorName".equals(lovInputSourceId))
    String vendorId=pageContext.getParameter("VendorIDfrm");
    Serializable[] parameters={vendorId };
    am.invokeMethod("initExemptionDetails",parameters);
    AM CODE:
    public void initExemptionDetails(String vendorid){
    ExemptionVOImpl vo = getExemptionVO1();
    if (vo == null) {
    throw new OAException("CLE", "CLE_F272_VO_NULL");
    vo.initExemptionQuery(vendorid);
    VOIMPL CODE:
    public void initExemptionQuery(String vendor_id){
    setWhereClause(null);
    reset();
    setNamedWhereClauseParam("VENDOR_ID",Integer.parseInt(vendor_id));
    executeQuery();
    AND LAST BUT NOT LEAST WHICH IS CAUSING THE ERROR CODE FOR ADDING A ROW:
    ExemptionVOImpl vo = getExemptionVO1();
    if (vo != null)
    vo.setMaxFetchSize(0);
    vo.executeQuery();
    Row row = vo.createRow();
    if (vo.getFetchedRowCount() == 0)
    vo.insertRow(row);
    else
    { vo.insertRowAtRangeIndex(vo.getRowCountInRange(),row); }
    vo.setCurrentRow(row);
    row.setNewRowState(row.STATUS_INITIALIZED);
    please help me out:::

  • Pulling row numbers out of tables.

    I have been looking for different ways to pull row numbers from tables.  There appears to be two main methods, one of which works for me and the other that does not.  The first is:
    NameDataSet.Tables.Rows(0).Count
    This gives me the number of rows in a table.  The problem is that I have a number of tables and it appears to just pick one of them to display (I set the code above up in a
    MessageBox.Show().
    The second is the one I think I would like to use but I get an error with it.
    DataTable.Rows.Count
    In this case it won't accept the table and states that the table is not declared.
    I have looked up everything I can, but much of it makes no sense to me and that which does I seem to be unable to make work.
    gwboolean

    OK, here is what I want to do.  I have an add record event that has a method inside for creating a directory in a specific location with a name that corresponds to the number of the last record in the table.  So I need to extract that number in
    order to create the directory (actually, it gets created anyway, just the wrong name).  Previously when I clicked the add record button the first line of code was:
    Dim txtFileAdd As String = Me.TblFMFileMasterBaseBindingSource.Position
    This used to work, but now, for whatever reason, this always puts me at the first record (possibly due to the binding navigator, but don't know why).
    So I ended up modifying slightly what you gave me:
    Dim txtFileAdd As String = Me._MasterBase_06DataSet.tblFMFileMasterBase.Rows.Count + 1
    Which gives me the exact count I need to then go ahead and create the directory I want.
    Hope that clears up you confusion, at least a little.
    gwboolean

  • Editing a particular row in a table - Web Dynpro Abap

    Hi all,
    My scenario is, I have to fetch contract details from EKPO table when I enter the Purchase Document Number and press SUBMIT button on my interactive form. The details will be displayed in a table.
        This part is working fine.
    Then, out of the displayed rows in that table, I have to click one of the rows. This particular row should appear as a separate row below the existing table. Here I will edit certain fields and update the database.
    My question is, How to display that particular row below the existing table which I select. The table will dynamically increase the row size depending on the records.

    Hi Surya,
    You can use the index property to display the selected row data.
    Suppose your form structure is like:
    BodyPage
       TBL_EKPO
           DATA
               EBELN
               EBELP
               LOEKZ
        SF_SELECTED_ROW_DISPLAY
            EBELN
            EBELP
            LOEKZ
    Then, in any of the field's exit event you can write:
    BodyPage.SF_SELECTED_ROW_DISPLAY. EBELN.rawValue = xfa.resolveNode( " BodyPage.TBL_EKPO.DATA["+ this.parent.index +"].EBELN").rawValue;
    Hope this helps.
    Amit

  • Max Rows in 11g Tables

    It seems no matter what I set as the max display rows for a table in 11g Analysis, it stops at 500 and makes the user select the arrow for a new page. I've checked the MBeans that control the setting in instanceconfig.xml and have found that the max is 65,000. The main issue is that if a user tries to export data from a dashboard it only exports 500 records. I've also checked the maximum in the RPD and it is set to 100,000. Has anyone else experienced this behavior? When exporting from a report, does it limit to 500 rows?
    Thanks!

    *19.3.1.2 Manually Configuring Settings for Data in Views*
    You can configure a similar group of settings that affects the display of data in tables, pivot tables, and graphs. While the settings are mainly the same, you must include the element within each appropriate parent element to override the default setting that applies to that view. For example, the views all use the MaxVisiblePages element. You must include that element within each of the Table, Pivot, and Charts parent elements, to override the default value of that setting for each of those view types.
    Before you begin this procedure, ensure that you are familiar with the information in Section 3.4, "Using a Text Editor to Update Oracle Business Intelligence Configuration Settings".
    To manually edit the settings that change the display of data in views:
    1.Open the instanceconfig.xml file for editing, as described in Section 3.6, "Where are Configuration Files Located?"
    2.Locate the Table, Pivot, and Charts parent sections, in which you must add the elements that are described in Table 19-1.
    3.Include the elements and their ancestor elements as appropriate, as shown in the following example.
    <ServerInstance>
    <Views>
    <Table>
    <MaxVisiblePages>1000</MaxVisiblePages>
    <MaxVisibleRows>500</MaxVisibleRows>
    <MaxVisibleSections>25</MaxVisibleSections>
    <DefaultRowsDisplayed>30</DefaultRowsDisplayed>
    </Table>
    <Pivot>
    <MaxVisibleColumns>300</MaxVisibleColumns>
    <MaxVisiblePages>1000</MaxVisiblePages>
    <MaxVisibleRows>500</MaxVisibleRows>
    <MaxVisibleSections>25</MaxVisibleSections>
    <DefaultRowsDisplayed>30</DefaultRowsDisplayed>
    </Pivot>
    <Charts>
    <MaxVisibleColumns>2000</MaxVisibleColumns>
    <MaxVisiblePages>1000</MaxVisiblePages>
    <MaxVisibleRows>2000</MaxVisibleRows>
    <MaxVisibleSections>25</MaxVisibleSections>
    <JavaHostReadLimitInKB>4096</JavaHostReadLimitInKB>
    </Charts>
    </Views>
    </ServerInstance>
    Note that this example does not include parameters that might exist in the file, but that are centrally managed by Fusion Middleware Control and cannot be changed manually.
    4.Save your changes and close the file.
    5.Restart Oracle Business Intelligence.
    Table 19-1 describes the common elements that affect the display of data in views. If the user exceeds these values, then the Oracle BI Server returns an error message when the view is rendered.
    Table 19-1 Common Elements for Manually Changing the Display of Data in Views
    Element Description Default Value Applicable Views
    DefaultRowsDisplayed
    Specifies the default number of rows to display in the view.
    30
    Pivot Table, Table
    MaxVisibleColumns
    Specifies the maximum number of columns to be displayed in a view.
    300
    Graph, Pivot Table
    MaxVisibleRows
    Specifies the maximum number of rows to be displayed in a view.
    For tables and pivot tables, specifies the number of rows that is displayed on the tooltip for the Display Maximum Rows per Page paging control button.
    500
    Graph, Pivot Table, Table
    MaxVisiblePages
    Specifies the maximum number of page choices (or pages in PDF) to be displayed in a view.
    1000
    Graph, Pivot Table, Table
    MaxVisibleSections
    Specifies the maximum number of sections to be displayed in a view.
    This element does not apply when a slider is in place for a graph. The SectionSliderDefault and SectionSliderLimit elements apply to limit section values when a slider is in place. See Table 19-2.
    25
    Graph, Pivot Table, Table
    JavaHostReadLimitInKB
    Specifies the maximum amount of data that is sent to the browser for a single graph.
    4096
    Graph
    I hope you helps...

  • How can I display "detailStamp" facet selectively for rows in a table ?

    Hi,
    My JDEV version is Studio Edition Version 11.1.1.5.0
    I am trying to display "detailStamp" facet selectively .
    If I read api in link below
    http://docs.oracle.com/cd/E26098_01/apirefs.1112/e17488/oracle/adf/view/rich/component/rich/data/RichTable.html
    Use the "detailStamp" facet on the Table to include a collapsable content area for each table row. Please note that the height of the open detail area will be a set height based on the height of the detailStamp component. Adding a component that changes in height (like showDetail or panelBox) will by default produce strange results when the detailStamp component's height changes.
    Detail Stamp can be selectively displayed for rows in the table by EL binding the "rendered" attribute of the "detailStamp" facet to "true" or "false". The EL binding can contain references to the table "var" attribute since during rendering it will be executed in the context of the row. Disclosure icon is displayed only for rows which have rendered="true".
    I can see that i can achieve it by setting rendered property for that facet. BUT this property is not available in Studio Edition Version 11.1.1.5.0

    Hi Frank.
    Thanks for your quick reply .
    But I am using Studio Edition Version 11.1.1.5.0 . In this version the property RENDERED of f:facet name="detailStamp" is NOT allowed.
    Edited by: user13764942 on Feb 7, 2013 5:48 AM
    Put in another way , I want to render the "detailStamp" facet selectively for rows , so for that I need the RENDERED property of "detailStamp" facet. This property is ONLY available in Jdev version 11.2 . I am using Jdev 11.1.1.5.0 so I need some alternative to RENDERED property as this property is NOT available in Jdev 11.1.1.5.0.
    Please suggest some way to achieve this behaviour of displaying "detailStamp" facet selectively ....
    Thanks!
    Edited by: Mangpal Singh on Feb 7, 2013 11:57 PM

  • Dynamically want to display a row of a table in BI Publisher

    Hi Gurus,
    Could any body help me regarding the following thing .
    I want to display a complete row of a table as a first record(on thenext page) if the particular Group having some data goes to next page .
    This Grouph is the inner group. I have tried in using following way but it didnot help me .
    I declare 2 variable as "present" and "prevoius and used <?xdoxslt:set_variable($_XDOCTX, 'count', <fo:page-number/>)?> to assigned value for both the variable . After that i have used <?:if $present != $rprevous?> Print the row else donot print.
    Please i need a urgent help for this and will appriciate to you guys.

    try BI publisher forum.
    --Prasanna                                                                                                                                                                                                                           

  • Display of selected row no in table footer.

    Hi,
    Row no of first row is generally displayed in the footer of the table as
    Row <first row rowno> of <total no of rows>.Eg Row 1 of 10.
    Can this be changed to display row no of currently selected row insted of first row?
    Thanks in advance,
    Apurva.

    Hi ,
    You would not be able to extend the UI per se..
    Instead you can make use of the property "firstVisibleRow" and "visiblerows" .
    When a user clicks a button to bring down the entries by one
    - increase the firstvisiblerow property by 1
    when he wants to move to next page ,
    - increase the firstvisiblerow property to firstvisiblerow+visiblerows
    Use the table toolbar for scrolling..and placing your elements as it would always be properly aligned to your table..
    Regards
    Bharathwaj..

  • Display of row index in table footer

    Hi,
    Row no of first row is generally displayed in the footer of the table as
    Row <first row rowno> of <total no of rows>.Eg Row 1 of 10.
    Can this be changed to display row no of currently selected row insted of first row?
    Thanks in advance,
    Apurva.

    Hi ,
    You would not be able to extend the UI per se..
    Instead you can make use of the property "firstVisibleRow" and "visiblerows" .
    When a user clicks a button to bring down the entries by one
    - increase the firstvisiblerow property by 1
    when he wants to move to next page ,
    - increase the firstvisiblerow property to firstvisiblerow+visiblerows
    Use the table toolbar for scrolling..and placing your elements as it would always be properly aligned to your table..
    Regards
    Bharathwaj..

  • How to: Display Last n Rows in a table

    I am currently running Crystal Reports XI and have been tasked with developing a report that displays only the last 30 rows in a table in ascending order (the records are used for showing data trends over time in a line graph). I have created a Command to extract the records, and by using the TOP 30 statement I can get the first 30 rows in proper order; however, in order to get the last 30 rows I have to sort the records in descending order. This gives me the last 30 rows that I need, but the data is in descending order. Is there another way to get the last 30 rows in a table so that the records come out in ascending order?
    The Command I am using looks like this:
    SELECT TOP 30 ROWID FROM MYTABLE ORDER BY ROWID DESC
    (The ROWID field is alpha numeric)

    Hi,
    Create a Group based on Rowid in the order-Ascending. This Group should contain all the fields that you require to print along with Rowid.  Therafter insert Summary like sum,count etc for for any field within the group of the type numbervar(numeric). This would activate the Group Sort Expert in the Report Menu. Click on it and select Bottom N (with N as 30) within nature of Sort and suppy the fieldname as Rowid.
    Hope this solves.....
    Thanks,
    Amogh.

  • How do I get the numbers ipad app to plot a graph of dates against values, where the most recent date is on the right of the graph, but the most recent date is at the top rather than bottom of the rows in the table?

    How do I get the numbers ipad app to plot a graph of dates against values, where the most recent date is on the right of the graph, but the most recent date is at the top rather than bottom of the rows in the table?
    Also how can it be a line graph without plotting a circle at each value?
    Thanks this is very frustrating

    Make a copy of the table and produce your Line chart or Bar chart from the copy. Sort the copy into the order you want to see in your chart.
    Alternately you could use a Scatter Chart...
    Jerry

  • How to display more than 200 rows in the table?

    Hi Experts,
    Is that possible to display more than 200 rows in a Table.
    when i query from table, it has 1000 rows, i want to display all the 1000 rows in the Table.
    when i query, the values are displaying up to 201 rows only,
    when i click next on 200 - 201 it throws Exception says
    *"Query has exceeded 200 rows. Potentially more rows exist, please restrict your query."*
    let me know how to display all the 1000 rows in a table without Exception.
    Any idea will be highly appreciated.
    Thanks
    Aswath

    The number of rows retrieved is controlled by profile option "FND: View Object Max Fetch Size". I believe 200 is the default value. Pl see these MOS Docs
    386402.1- Query Has Exceeded 200 Rows
    275876.1 - Oracle Application Framework Profile Options Release 11i (11.5.10)
    HTH
    Srini

  • Query for how to display unique rows in a table

    Can i have a query for displaying unique rows in a table.

    use d query
    select distinct col1,col2... from table ;

Maybe you are looking for

  • How do I get an older version of Pages to work on Snow Leopard? (I already purchased it on App Store a while back)

    I purchased Pages on the App store a while back and I can't get it any more on my computer. I have an early 2006 MacBook Pro with Mac OS X Snow Leopard 10.6.8, which is the highest it would go to, and it isn't compatible with the new Pages version. H

  • Bridge menu no longer working

    I can no longer use the camera raw menu button or rotate buttons in CS6 bridge.   Also for many TIFF photos, I get the TiFF logo rather than the photo. These two problems began that at the same time after I shut down the PS and Bridge in the usual wa

  • Oracle 9i installtion problen on RH21AS 2.4.9-e.3

    Hi, I am installing Oracle 9i cluster on RH21AS kernel version 2.4.9-e.3. Using the doc "Tips to install oracle 9i on RH21AS" I have installed my OS configured it to install oracle. I could get Oracle cluster manager installed and started (using watc

  • Problem in alv dispaly filedcat-edit

    Dear,       i am using filedcat-edit to change the output of alv display but after changing the quantity  and when i pressing  save button it is converting quantity   8.000 to 0.008 . kindly help me. thannk u,

  • Weird (and annoying) two profiles on the one ID.

    I've not used the forums much recently so when I logged in a couple of days ago I didn't worry about the prompt to assign a 'screen name' to my ID. I just thought it was a feature of the upgraded forum. But then I noticed that my avatar and points we