Setting row count to JTable RunTime

I am creating JTable at RuTime. I want to set the default 1 row for the Table
df = new DefaultTableModel();
jTable1.setModel(df);
//add Columns to Table
for(int i=0; i<chars.size(); i++)
TableColumn col = new TableColumn();
col.setHeaderValue(.....);
col.setPreferredWidth(...);
jTable1.addColumn(col);
jTable1.updateUI();
df.setRowCount(1); //Problematic code . if remove this line everithing works fine
The above code does't work properly(the last line) Nothing displays on the screen and it's seems to doing processing in loop ...
Plese provide the solution I reqires this urgently............

what does "Problematic code" mean? Why can't people just post the error messag/exception? do you think we are prophets?

Similar Messages

  • Set row height in JTable

    i would like to hide, show row/s in the JTable. I try it with setRowHeight but it affect all rows.
    is it possible to do it ? what shoud i rewrite(add) to create this functionality?
    i use JDK1.2.2 :-(
    thanks Tomas

    The other way is to modify your table model class:
    Let the getValueAt method return only the rows you need and the getRowsCount method return the needed row count.
    It may be done in respect to some condition of the table
    Best regards,
    Martin

  • How to get  visible row  count  in JTable ?

    I have one table which is added to one scroll pane. For example my table have total 1000 rows, but at a time only 20 rows should be visible to the scroll pane. And I want to scroll the rows and show only 20 at a time.When user scrolls JTable then next time he can view only 1 to 21, then 2 to 22, and so on. I want to know how to get that number which represents the visible row( in this case it is 20).So kindly help me how to get visible row count. Any help regarding this will be appriciated.
    Thanks and Regards,
    Sheetal

    how to get visible row count.First you need to get the viewport used by the scrollpane. Then you can use methods like getViewPosition() and getViewSize() to get information about the current postition of and size of the viewport.
    Then you can use the table method getRowAtPoint(). to determine the first and last visible row which can then be used to calculate the visible row count.
    When user scrolls JTable then next time he can view only 1 to 21, then 2 to 22, and so onThis is the default behaviour when a "block" scroll is done.
    However when you click on the arrow button on the scrollbar it will only scroll a single row. You could override the getScrollableUnitIncrement() method to return the value from the getScrollableBlockIncrement() method.
    However the user can still drag the scrollbar manually which would cause a problem. So you would also need to remove the MouseMotionListeners from the scrollbar to prevent this.

  • Setting row color in JTable

    I am trying to display some rows in a JTable in a different color regardless of selection status. The row color criteria would be from data from the object in the row, i.e., given a certain status of a record, I would want to show it as red instead of black.

    A few optimizations:
    class StatusColorRenderer
    extends DefaultTableCellRenderer
        public StatusColorRenderer()
            // super(); not needed, call by default
            setOpaque(true);
            // DefaultTableCellRenderer returns itself as a CellRenderer Component, it extends JLabel so you can call setOpaque on it
    // since this method is called at every paint for every cell it should be HIGHLY optimized
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
        Component c = super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column);
        MyObjectClass myObject  = ( MyObjectClass ) myTableModel.getMyVector().elementAt(row);
        <SomeClass> myStatus = myObject.getTheStatus();
        if ( myStatus.compareTo(Status.BAD_STAT) == 0)
            c.setForeground(Color.red);
        else if (myStatus.compareTo(Status.IN_PROGRESS) == 0)
            c.setForeground(Color.green);
        else if ( myObject.getOtherFactor().compareTo(OtherFactors.NOT_DEFAULT) ==  0)
            c.setForeground(Color.blue);
        else
            c.setForeground(Color.black);
        // c.repaint(); NEVER DO THAT
        return c;
    StatusColorRenderer myRenderer = new StatusColorRenderer();
    // only one instance of the renderer
    for ( int i = myTableModel.getColumnCount() - 1 ; i >= 0 ; i-- )
       //column = myTable.getColumnModel().getColumn( i );
       myTable.setDefaultRenderer( myTable.getColumnClass( i ),
                                                myRenderer );
    }Comment:
    AbstractTableModel and DefaultTableModel.getColumnClass method returns Object.class, it is used by the JTable to setup the editor and the renderer of a column
    so if you're using the DefaultTableModel and JTable without overriden getColumnClass, you can set a generic renderer for your JTable by using:
    myTable.setDefaultRenderer( Object.class, myRenderer );

  • Dynamically set maximum row count in Interactive Report

    Hi,
    Has anyone worked out a way of dynamically setting (e.g. via select list) the maximum row count value for an Interactive Report, taking into account issues with order by when the report is filtered. I'm aware of solutions like this: http://www.talkapex.com/2010/10/apex-reports-no-limit-downloads.html but as far as I can tell this doesn't work when the report is filtered and the IR is rewritten in the background. Data sets then become unreliable because they are reordered.
    Thanks,
    Mike

    Hi Mike,
    You can do that with javascript
    gReport.search('SEARCH',100)the 100 you can replace for any number you like.I have a report with filter,sorting and groups and it is gives no problem there.
    any number means any number but not higher than the number you set at Maximum Rows Per Page.
    You probably can mix the solution from Martin and the above code.
    Regards,
    Kees Vlek
    <tt>Company: http://www.orcado.nl
    Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
    Twitter: http://www.twitter.com/skier66</tt>
    If the question is answered please change it to answered and mark the appropriate post as correct/helpfull.
    Edited by: kvlek on 24-apr-2013 12:29
    Edited by: kvlek on 24-apr-2013 12:35

  • How do you set the font color for a specific entire row inside a JTable?

    How do you set the font color for a specific entire row inside a JTable?
    I want to change the font color for only a couple of rows inside a JTable.
    I've seen some ways to possibly do this with an individual cell.
    Clarification on changing the font color in an individual cell would be helpful too if
    there is no easy way to do this for a row.

    hai,
    Try out with this piece of code.Create your table and assign the renderer to each column in the table.
    CellColorRenderer m_CellColorRenderer = new CellColorRenderer();
    for(int i=0;i<your_JTable.getColumnCount();i++)
    your_JTable.getColumnModel().getColumn(i).setCellRenderer(m_CellColorRenderer);
    class CellColorRenderer extends JLabel implements TableCellRenderer
    CellColorRenderer()     
    setOpaque(true);     
    setHorizontalAlignment(LEFT);
    setVerticalAlignment(CENTER);
    setBackground(Color.white);
    setForeground(Color.black);
    protected void setValue(Object value)
         setText((value == null) ? "" : value.toString());
    public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected, boolean hasFocus, int row,int column)
         if(isSelected == true)
              setForeground(Color.red);
         else
              setForeground(Color.black);
         setValue(value);
         return this;
    regards,
    bala

  • Need to set the Vissible row count Dynamically

    Hi,
       I have requirement where i am supposed to set the Vissible row count for a table dynmaically, depending upon the number of rows in a table.

    Or use a calculated attribute.
    Create an attribute in the context called calcVisibleRowCount of type integer and make it read only and calculated. Then bind that attribute to the visibleRowCount attribute of your table.
    The method for the attribute looks something like this:
    (this displays 10 rows per page if more than 10 records in the node, otherwise it displays the same number of rows in the table as in the context)
      public int getCalcVisibleRowCount(IPrivateStartsida.ILayoutElement element)
        //@@begin getCalcVisibleRowCount(IPrivateStartsida.ILayoutElement)
              if (wdContext.nodeXXXX().size() > 10) {
                   return 10;
              } else {
                   return wdContext.nodeXXXX().size();
        //@@end
    Note that this attribute is not created in the node that you want to count number of elements in.
    Edited by: Richard Linnander on Apr 1, 2011 3:41 PM

  • Localization in OBIEE 10g(Error "start row is set higher than the row count

    Hi All,
    I m Working on Localization.
    I have used exteranize string and saved excel file and added language column and inserted data en and fr and loaded the file into the database.
    then i have created 2 variables
    one is for weblanguage SELECT 'VALUEOF(NQ_SESSION.WEBLANGUAGE)' FROM DUAL
    second is SELECT SESSION_VARIABLE, TRANSLATION FROM TAB_EXTERNAL WHERE LANGUAGE = 'VALUEOF(NQ_SESSION.LOCALE)' when i click on Test for the second variable it showing error
    "start row is set higher than the row count"
    i have seleted start row =10 and show some 10.then also it is showing same error.
    Please send me the solution ASAP.
    Thanks and Regards
    Kiran Kumar

    Hi Kiran,
    I am working in OBIEE localization. I created two variables and when press test i am getting vaules successfully. But in OBIEE application i am getting columns in english only. It seems there is some problem with values in DUAL table. It contains only 1 column called 'DUMMY' and value as 'X'.
    Please give me complete configuration steps to setup localization OBIEE 10g. Please drop me a mail to [email protected] if u have steps. I will call u if u provide contact number.

  • Pagination disappears after setting 'max row count'

    I have a report with app. 4500 records (with the default of 15 lines per page) and a pagination scheme of 'Row Ranges 1-15 16-30 in select list (with pagination)'.
    When running the report, all is working fine and i get the information in the select list '.. of more than 500'.
    Then i inserted some values in the 'max row count'-field:
    a value of 2000: it's working as expected
    a value of 4000 (or more): the pagination disappears and won't be desplayed :-(
    Any ideas, what i have done wrong?
    Thanks
    Rainer

    Hi
    This problem - select list dissapearing when > 32k still persists in Version 3.
    A neat workaround is to use a page item to set the number of rows disaplyed.
    Where there is a large number of rows in the table and the max rows is also large, simply set the page item value for the number of rows to a larger value say 200 - then - if the select list now becomes less than 32K the select list will be shown.
    It's a matter of balancing the number of rows shown on the page with the total number of rows in the table / max rows combination.
    It's not perfect but it works.
    Hope this helps.
    Mike Mac
    Message was edited by:
    Mike Mac

  • How to set Tile count column or count row?

    How to set Tile count column or count row? If not can do, How
    to adjust count row or count column?
    Thx for all idea.

    The Tile container's number of columns and rows is calculated
    based on each child's width and height (or based on tileWidth and
    tileHeight which you can set). If you need more control over the
    layout, use Grid.

  • Setting the Vissible Row count Dynamicaly

    Hi,
        I need to set the Vissible row count dynamically in Webdynpro Java, depending upon the number of rows in the internal table.

    Hi Delphi,
    This is Webdynpro ABAP Forum, Try to post in Webdynpro Java. I dont know WD Java.
    Create one attribute of type i  ex : COUNT TYPE I, and bind to visible row count property of table.
    In code Describe table and get total no of records to one variable.
    Finally use Set_attribute - Pass COUNT Value. Now Based on Count Value you get no of table rows.
    Hope it Helps.
    Cheers,
    Kris.

  • Setting colors of the rows of  a JTable

    Hi,
    How can we set multiple colors(foreground) for multiple rows in a JTable?. (i want to set the color of the row depends on the value of a column. Foe example if the value of a particular column is "x" then i want to set the color of that particular row as "RED" or if the value of that column is "y" then i want to set the color of the column as "GREEN". )

    Try this:
    * Method to set custom cell renderer
    *Adopted from
    * http://javaalmanac.com/egs/javax.swing.table/Stripe.html
    JTable theTable = new JTable() {
    public Component prepareRenderer(TableCellRenderer renderer,
    int row, int col) {
    Component c = super.prepareRenderer(renderer, row, col);
    //Example assumes the column number is 1 and value is "Critical"
    if (theTable.getValueAt(row, 1) != null) {
    if (theTable.getValueAt(row, 1).equals("Critical")) {
    if (col == 1) {
    c.setForeground(Color.red);
    c.setBackground(new Color(255, 255, 204));
    c.setFont(new java.awt.Font("MS Sans Serif", 1, 11));
    return c;
    };

  • How to set visible row count dynamically

    i  need to place input field so that user enters value for visible row count in ALV WEBDYNPRO

    Hi Prabhu,
    As Suggested use set_visible_row_count. First count your table entries. based on count display records.
    count = LINES( lt_n_contract ).
      IF count > 5.
        lt_table_settings->set_visible_row_count( value  = 10 ).
      ELSE.
        lt_table_settings->set_visible_row_count( value  = 3 ).
      ENDIF.
    Cheers,
    Kris.

  • How to set  row height  for  each row

    Hi
    i am trying to set rowheight of row in a JTable using setRowHeight(row,rowheight)
    it is not affecting on Table.but if i use setRowheight(rowheight) it applying
    entire table ,please help me to solve this problem
    after setRowHeight(row,rowheight), i am calling firechanged() method also ,i t will not affecting please hemp me
    how to set row height at runtime in a JTable

    Ok fine... do one thing... post ur code here let me check and tell u....
    Ciya.....

  • Help required for creating Row Renderer for JTable

    Hi all,
    I am trying to create customize row renderer for JTable.
    My requirements are as below.
    |-----------------|-------------------|------------------|------------------|-------|----------------|
    |Category | Product ID |Description | Unit Price |Qty | Sub-Total |
    |-----------------|-------------------|------------------|------------------|-------|----------------|
    I have designed a combobox for category and product ID columns inside JTable. I want to put a listener on Category ID such that product IDs in selected categories will be visible in product ID drop down of selected row keeping other rows unchanged.
    Column renderer is defining a class for entire column but by setting that im getting same values in all the rows for product IDs. And if I update values for one product ID dropdown, entire column data is changing.
    Even im not able to put array of combobox for product ID column as number of rows are not fixed and increasing runtime.
    Can anyone suggest me how can i customize Cells under particular column with JComboBox?
    Regards,
    Mahesh Kedari
    Fidus Technologies Ltd.
    Edited by: m1JustM1 on Feb 8, 2010 4:48 AM

    Start by reading [this |http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender] tutorial. If you still have questions afterward, feel free to post an SSCCE .

Maybe you are looking for

  • Family sharing with a non primary iCloud ID?!

    I have been living in different countries for the past couple years. I have: Account A - primary iCloud account (also as developer account) set to HK (no iOS App purchases) Account B - my App Store account in HK Account C - my old Canadian iTunes acc

  • Double click does not open CR2 in Photoshop CS 6

    I just moved Photoshop CS6, Bridge CS6, and Lightroom 4.1 to a new MacBook Pro Retna running Lion 10.7.4 Camera Raw 7.1 is installed. If I double-click a JPG image in Bridge or Mini-Bridge, it will open in Photoshop. If I select a JPG image in Lightr

  • Airport 6.3.1 - Unexpected error connecting to Airport Express

    I have an Airport Extreme (A1408) base station. I am trying to add an Airport Express (A1392) to my network using Airport Utility 6.3.1 (631.4) with Mac OS/X 10.8.4 (12E 55) running on an iMac. The Airport Utility can find the Express, but returns "A

  • How to obtain error codes from LDAP exceptions

    Is there a way to obtain the error codes returned by LDAP services. In our application, we want to give more understandable messages and solution to rectify the issues, for the exception thrown while accessing LDAP. The NamingException does not conta

  • Changing photo file formats-Making JPG lower case

    I am new to the Mac OS and I run OS X 10.5.1 . I am having trouble uploading pics to myspace that have been transfered from my Canon PowerShot A420 camera. When the pics are taken they are saved in jpg. format but the jpg. is actually all caps (JPG).