Display 2D array in a table, 1 row at a time

I am using a For Loop to read a serial port 40 times and display the values in a table of 40 rows and 5 columns.  I auto index the output of the For Loop to build the 2D string array. The problem is that the serial port takes too long to answer and the VI takes about two minutes to display the values in the table because it doesn't do it until the For Loop finish its 40 iterations. Is it possible to display each iteration as it executes? I mean, to pass the value of the 1st iteration to the 1st row of the table and then do the 2nd iteration, pass its value to the 2nd row of the table and so on? Thanks a lot! (Merry Christmas to the ones that celebrate it)
Solved!
Go to Solution.

Hello Farracillo,
Your welcome,
It's pretty cool to have backup if an answer mach correctly for a problem and so
others members don't have to work on , i mean for more complexes questions
and ever even more cool to give/receive kudos to keep up motivation ...
 see you for others questions...
@+
Tinnitus
Message Edité par tinnitus le 12-26-2008 09:33 AM
CLAD / Labview 2011, Win Xp
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail
Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte

Similar Messages

  • Display string array in a table using netui-data:repeater tags

    hi,
    I am trying to display a string array in a table using the netui-data:repeater tag.
    I have to use a page flow controller Array(1 Dimensional) to be displayed in the jsp.
    Can any one tell me how to print the array in a table of 3rows & 5 columns.
    Here is the code on which I am crrently working on.
    <netui-data:repeater dataSource="{pageFlow.strWorkObject_Array}">
    <netui-data:repeaterHeader>
    <table cellpadding="4" border="1" class="tablebody">
    </netui-data:repeaterHeader>
    <netui-data:repeaterItem>
    <tr>
    <td><netui:label value="{container.item}" >
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    </tr>
    </netui-data:repeaterItem>
    <netui-data:repeaterFooter>
    </table>
    </netui-data:repeaterFooter>
    </netui-data:repeater>

    weblogic.developer.interest.workshop
    Mansoor Naseem wrote:
    I would like to know where the pageflow newsgroup is.
    These are all the groups in weblogic.developer.interest:
    weblogic.developer.interest.60beta.* (5 groups) weblogic.developer.interest.management
    weblogic.developer.interest.61beta.* (2 groups) weblogic.developer.interest.misc
    weblogic.developer.interest.clustering.* (1 group) weblogic.developer.interest.performance
    weblogic.developer.interest.commerce weblogic.developer.interest.personalization
    weblogic.developer.interest.ejb.* (3 groups) weblogic.developer.interest.portal
    weblogic.developer.interest.environment weblogic.developer.interest.rmi-iiop
    weblogic.developer.interest.jdbc weblogic.developer.interest.security
    weblogic.developer.interest.jms weblogic.developer.interest.servlet
    weblogic.developer.interest.jndi weblogic.developer.interest.tools
    weblogic.developer.interest.jsp weblogic.developer.interest.weblogicenterprise
    MN

  • I need to display an array of doubles on a table and I am loosing my percision

    Hello,
    I need to display an array of doubles on a table but I am losing my decimal precision. I am converting the array to a string in order to display it on the table with a number to decimal function. This is where I lose my precision since that control converts the double into an integer and then into the string. What control do I need to use instead of that in order to preserve my decimal precision all the way to the table? I have attached my VI. Thanks in advance!
    Gregory Osenbach, CLA
    Fluke
    Attachments:
    canalyzer_prototype_1.vi ‏52 KB

    Thank you both for the quick response. Its just the info I needed!
    Gregory Osenbach, CLA
    Fluke

  • Inserting a associative array into a table

    Hi,
    I am working on a process where I want to store the temporary results in an associative array. At the end of the process I plan to write the contents of the array into a table that has the same structure. (the array is defined as a %rowtype of the table)
    Is it possible to execute ONE sql statement that transfers the array into the table? I am on 10g (10.2.0.4.0)
    Here's what I have now:
    declare
      type t_emp is table of emp%rowtype index by pls_integer;
      v_emp t_emp;
    begin
      -- a process that fills v_emp with lots of data
      for i in v_emp.first .. v_emp.last
      loop
        insert into emp values v_emp(i);
      end loop;  
    end;But it would be better if the loop could be replaced by sql one statement that inserts all of v_emp into emp. Is that possible?
    Thanks!
    PS: I'm not sure whether it's a good idea to use this approach... building a table in memory and inserting it into the database at the end of the process. Maybe it's better to insert every record directly into the table... but in any case I'm curious to see if it is possible in theory :)
    Edited: Added version info

    True, SQL cannot access the PL/SQL type.
    So you can not do something like this:
    insert into emp
    select * from table(v_emp)That is not possible.
    But FORALL is possible:
    FORALL i in v_emp.first .. v_emp.last
        insert into emp values v_emp(i);FORALL makes just one "round trip" to SQL bulk binding the entire contents of the array.
    It is much more efficient than the normal FOR loop, though it is mostly a PL/SQL optimization - even the FORALL actually inserts the rows "one at the time", it just hands the entire array to the SQL engine in one go.
    If the logic has to be done procedurally, FORALL is efficient.
    If the logic can be changed so arrays can be avoided completely and everything done in a single "insert into ... select ..." statement, that is the most efficient.

  • How to display required data from emp table?

    Hi every one, this is my first post in this portal. I want display the details of emp table.. for that I am using this SQL statement.
    select * from emp where mgr=nvl(:mgr,mgr);
    when I give the input as 7698 it is displaying the corresponding records... and also when I won't give any input then it is displaying all the records except the mgr with null values.
    1)I want to display all the records when I won't give any input including nulls
    2)I want to display all the records who's mgr is null
    Is there any way to incorporate to include all these in a single query..

    Hi,
    937440 wrote:
    Hi every one, this is my first post in this portal. Welcome to the forum!
    Be sure to read the forum FAQ {message:id=9360002}
    I want display the details of emp table.. for that I am using this SQL statement.
    select * from emp where mgr=nvl(:mgr,mgr);
    when I give the input as 7698 it is displaying the corresponding records... and also when I won't give any input then it is displaying all the records except the mgr with null values.
    1)I want to display all the records when I won't give any input including nulls
    2)I want to display all the records who's mgr is null
    Is there any way to incorporate to include all these in a single query..It's a little unclear what you're asking.
    The following query always includes rows where mgr is NULL, and when the bind variable :mgr is NULL, it displays all rows:
    SELECT  *
    FROM     emp
    WHERE     LNNVL (mgr != :mgr)
    ;That is, when :mgr = 7698, it displays 6 rows, and when :mgr is NULL it displays 14 rows (assuming you're using the Oracle-supplied scott.emp table).
    The following query includes rows where mgr is NULL only when the bind variable :mgr is NULL, in which case it displays all rows:
    SELECT     *
    FROM     emp
    WHERE     :mgr     = mgr
    OR       :mgr       IS NULL
    ;When :mgr = 7698, this displays 5 rows, and when :mgr is NULL it displays 14 rows.
    The following query includes rows where mgr is NULL only when the bind variab;e :mgr is NULL, in which case it displays only the rows where mgr is NULL. That is, it treats NULL as a value:
    SELECT     *
    FROM     emp
    WHERE     DECODE ( mgr
                , :mgr, 'OK'
                )     = 'OK'
    ;When :mgr = 7698, this displays 5 rows, and when :mgr is NULL, it displays 1 row.

  • How to display multiple data from different table in one table? please help

    Hi
    I got sun java studio creator 2(the separate installation not the one in the net beans)....
    My question is about displaying data that have been taken from the database.... I know how to display data in a table(just click on the table "bind data" )... but my question is that:
    when i want to use a sql statement that taken the data from different table...
    how can i display that data in the table(that will be shown in the web) ??? when i click bind data on the table i can only select one table i can't select more than one....
    Note:
    1) i'm using the rowset for displaying the data in the table, since the sql statement is depending on a condition(i.e. select a from b where c= ? )...
    2) i mean by different table is that( i.e. select a from table1,table2 )..
    thanks in advance...

    Hi,
    937440 wrote:
    Hi every one, this is my first post in this portal. Welcome to the forum!
    Be sure to read the forum FAQ {message:id=9360002}
    I want display the details of emp table.. for that I am using this SQL statement.
    select * from emp where mgr=nvl(:mgr,mgr);
    when I give the input as 7698 it is displaying the corresponding records... and also when I won't give any input then it is displaying all the records except the mgr with null values.
    1)I want to display all the records when I won't give any input including nulls
    2)I want to display all the records who's mgr is null
    Is there any way to incorporate to include all these in a single query..It's a little unclear what you're asking.
    The following query always includes rows where mgr is NULL, and when the bind variable :mgr is NULL, it displays all rows:
    SELECT  *
    FROM     emp
    WHERE     LNNVL (mgr != :mgr)
    ;That is, when :mgr = 7698, it displays 6 rows, and when :mgr is NULL it displays 14 rows (assuming you're using the Oracle-supplied scott.emp table).
    The following query includes rows where mgr is NULL only when the bind variable :mgr is NULL, in which case it displays all rows:
    SELECT     *
    FROM     emp
    WHERE     :mgr     = mgr
    OR       :mgr       IS NULL
    ;When :mgr = 7698, this displays 5 rows, and when :mgr is NULL it displays 14 rows.
    The following query includes rows where mgr is NULL only when the bind variab;e :mgr is NULL, in which case it displays only the rows where mgr is NULL. That is, it treats NULL as a value:
    SELECT     *
    FROM     emp
    WHERE     DECODE ( mgr
                , :mgr, 'OK'
                )     = 'OK'
    ;When :mgr = 7698, this displays 5 rows, and when :mgr is NULL, it displays 1 row.

  • Adding data from an array to a table

    How can i add information from an array to a table via JDBC? I have tried:
    stmt.executeUpdate("INSERT INTO TEMP " + "VALUES (" + carData[0] + ", " + carData[1]);
    but i get the error:
    SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
    Also, can i only add data to some columns of a row and not all?

    If your TEMP table has only two columns and both of
    them are of number
    types, and your array contains only numeric types
    (int[], long[] etc., it should not be a problem.
    If your table contains more than two columns (and the
    remaining columns are nullable) you need to list the
    column names in the insert statement. Check your table
    definition in the database and see SQL syntax for
    insert.
    If your columns are of string type, you need to
    enclose the values in quotes (alternatively, use
    PreparedStatement).I agree with this.
    Here is the syntax that he was talking about
    //if the values are numeric
    stmt.executeUpdate("INSERT INTO TEMP(<COLUMN NAME>,<COLUMN NAME>) "
    + "VALUES(" + carData[0] + "," + carData[1] + ")";
    //if the values are text
    stmt.executeUpdate("INSERT INTO TEMP(<COLUMN NAME>,<COLUMN NAME>) "
    + "VALUES('" + carData[0] + "','" + carData[1] + "')";
    Notice that the last part of your original query was incorrect. You forgot to put the bracket in quotes again.

  • Read integer values from spreadsheet and display the values in a table

    Hi all,
    I have integer values to read from a spreadsheet and display them in a table. I am using 'Read from spreadsheet file' in 'integer' mode. I would like to display these values in a table. The problem is that the table takes only 2d-array of string as input but not integer.  
    It works fine if I change the mode of 'Read from spreadsheet file' from 'integer' to 'string' but I want to read integers and have to use the integer values for further calculations. Please give any suggestions on displaying integers to a table.
    Thank you. 
    Solved!
    Go to Solution.

    No don't take element by element just convert as a whole. See the attached example
    Good luck
    The best solution is the one you find it by yourself

  • Data Table Fixed rows and Scroll Bar

    Hi
    I have data table which displays the data dynamically, but when there is no data , the table is shrinking and moving the other elements of the page. Is there any way i can keep to fixed number of rows irrespective of data presence?
    Like i need to display only 10 rows at a time, if there are 7 rows in DB, i have t o display 7 rows containing data and rest as blank .
    If my data increases more than 10 rows how can i enable Scroll Bar Automatically on this?
    Thanks in advance.

    Then add empty row objects to the collection or datamodel which is been passed to the datatable value.

  • How to Display string array in jsp page using netui-data:repeater tag ??

    hi,
    I am trying to display a string array in a table using the netui-data:repeater tag.
    I have to use a page flow controller Array(1 Dimensional) to be displayed in the jsp.
    Can any one tell me how to print the array in a table of 3rows & 5 columns.
    Here is the code on which I am crrently working on.
    <netui-data:repeater dataSource="{pageFlow.strWorkObject_Array}">
    <netui-data:repeaterHeader>
    <table cellpadding="4" border="1" class="tablebody">
    </netui-data:repeaterHeader>
    <netui-data:repeaterItem>
    <tr>
    <td><netui:label value="{container.item}" >
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    </tr>
    </netui-data:repeaterItem>
    <netui-data:repeaterFooter>
    </table>
    </netui-data:repeaterFooter>
    </netui-data:repeater>

    weblogic.developer.interest.workshop
    Mansoor Naseem wrote:
    I would like to know where the pageflow newsgroup is.
    These are all the groups in weblogic.developer.interest:
    weblogic.developer.interest.60beta.* (5 groups) weblogic.developer.interest.management
    weblogic.developer.interest.61beta.* (2 groups) weblogic.developer.interest.misc
    weblogic.developer.interest.clustering.* (1 group) weblogic.developer.interest.performance
    weblogic.developer.interest.commerce weblogic.developer.interest.personalization
    weblogic.developer.interest.ejb.* (3 groups) weblogic.developer.interest.portal
    weblogic.developer.interest.environment weblogic.developer.interest.rmi-iiop
    weblogic.developer.interest.jdbc weblogic.developer.interest.security
    weblogic.developer.interest.jms weblogic.developer.interest.servlet
    weblogic.developer.interest.jndi weblogic.developer.interest.tools
    weblogic.developer.interest.jsp weblogic.developer.interest.weblogicenterprise
    MN

  • How to display an array in a VB form

    I am new to Measurement Studio. This could be a silly question.
    I am so used to the front panel in Labview where you can have control/indicator arrays. You can expand an array to see several values at the same time. Plus you have an index display to scroll.
    Is there any similar feature in Measurement Studio for Visual Basic or Visual C? If not, why not.
    cheers

    No, there isn't currently a tabular or array control provided with Measurement Studio. There are a few reasons for this. First off, remember, LabVIEW is a graphical language, there isn't anything that isn't a control or indicator on a front panel. The array control in LabVIEW is mainly there as the datatype for arrays, not specifically as a UI object, although it is frequently used that way.
    In Measurement Studio, the focus of the User Interface components is adding the controls to Visual Studio that are needed for test and measurement applications. Visual Studio comes with a tabular type interface called the DataGrid control for displaying numeric and string data in a table format built-in. This is what you would want to use to display arrays. We
    would definately consider adding a table type interface if our users needed a lot more functionality than was provided by the Visual Studio DataGrid control.
    I know it can be frustrating going back and forth between the tools and seeing different things available. Remember, they are designed for different users though. Measurement Studio is designed to equip Visual Studio programmers to do Test & Measurement programming easily, it isn't designed to provide LabVIEW type functionality to Visual Studio users. So some LabVIEW functionality won't exist in Measurement Studio purposefully, and also some functionality in Measurement Studio that isn't in LabVIEW since it doesn't suit graphical programming.
    Try the DataGrid control, and let us know if it doesn't meet your needs.
    Best Regards,
    Chris Matthews
    National Instruments

  • Display X line of a table

    hi,
    I have a table of 100 lines. How can I display with a select request only the 10 first lines or display lines 10 by 10 until 100. Like in the web site.
    Thanks you.

    The following example demonstrates how to select 10 rows at a time using a .sql script:
    SQL> EDIT test
    Type or copy the following, substituting the name of your table for table_name:
    ACCEPT starting_number PROMPT 'Enter starting row number: '
    SELECT row_num, a.*
    FROM (SELECT ROWNUM row_num, b.*
    FROM (SELECT *
    FROM table_name
    ORDER BY ROWID) b) a
    WHERE row_num < &starting_number + 10
    AND row_num >= &starting_number
    Save the file.
    SQL> START test
    It will then prompt you to enter the starting row number and display the next 10 rows starting with that number.
    The next example demonstrates how to select 10 rows at a time using a pl/sql stored procedure within a package and returning the results in a ref cursor:
    SQL> EDIT getemployees_pkg
    Type or copy the following, substituting your table name for emp and your column names for empno, ename, and sal:
    CREATE OR REPLACE PACKAGE getemployees_pkg
    AS
    TYPE emp_curtype IS REF CURSOR;
    PROCEDURE getemployees
    (p_start_no IN NUMBER,
    emp_cur OUT emp_curtype);
    END getemployees_pkg;
    CREATE OR REPLACE PACKAGE BODY getemployees_pkg
    IS
    PROCEDURE getemployees
    (p_start_no IN NUMBER,
    emp_cur OUT emp_curtype)
    IS
    BEGIN
    OPEN emp_cur FOR
    SELECT empno, ename, sal
    FROM (SELECT empno, ename, sal, rn
    FROM (SELECT empno, ename, sal, ROWNUM rn
    FROM (SELECT empno, ename, sal
    FROM emp
    ORDER BY empno))
    WHERE rn >= p_start_no
    AND rn < p_start_no + 10);
    END getemployees;
    END getemployees_pkg;
    Save the file.
    SQL> START getemployees_pkg
    Package created.
    Package body created.
    The procedure can then be executed from the SQL prompt:
    SQL> VARIABLE g_out REFCURSOR
    SQL> EXEC getemployees_pkg.getemployees(1, :g_out)
    SQL> PRINT g_out
    or the procedure can be called from within another procedure or from another calling environment.
    null

  • How to repeat 2 table header rows in adobe form

    Can anybody suggest me how to repeat 2 table header rows .
    one header row is for displaying only columns header list
    second header row is for displaying 'from date' and 'to date'.
    and i want this to be done using layout tab(palletes) in the form.  will it be?
    Message was edited by:
            M Madhu

    loop at ot into wa.
    at first header one
    write second header.
    endloop.
    declear one internal table append both values in come internal table .
    pass the header in comen internal table.
    Message was edited by:
            Karthikeyan Pandurangan

  • SAP Query Display data from 2 internal tables

    Hi ABAP Gurus,
    I am developing a SAP Query.
    I have created an infoset with the custom infotype 9050 and added the table ZPA9050 into the Infoset.
    How do I input values to the ZPA9050 fields? A checkbox for making a Selection field is not available in the Query (SQ01)
    For every pa9050 entry there exist multiple records of ZPA9050. I need to display the pa9050 fields in the 1st row and the corresponding zpa9050 fields in the subsequent rows.
    Kindly advise how to accomplish this task. 
    A quick reply is highly appreciated.
    Useful answers will be rewarded.
    Thanks
    Sriram

    Hi Deepika,
       Your reqirement is to print data from the two internal tables ..and if u r not using interactive alv  then u need to merge data into single internal table... if anycase u dont want to merge in the table itab as u told u can use another final internal table in which u can merge data from the two previous interal tables then u pass this final internal table to ur FM.
    Thanks & Regards
    Ashu Singh

  • Table Rendering - Row level vs Column level

    Normally renderers are specified for a given class of data or column of data.
    So, how would you handle rendering requirements that are row or table dependent? For example, how do I:
    a) color alternate lines in a table
    b) change the border of the selected cell
    Traditional Approach
    Most answers in the forum would be something like "use a custom render". Sounds great, but what does it really mean? If all your data is displayed as a String then it really isn't too difficult to create a single renderer with the required logic and add it to the table as the default renderer.
    However, what if you table contains, String's, Dates, Integer's, Double's and Boolean's and you want your cell to retain the default formatting of each data type in addition to the above requirement? Now you have two options:
    a) render by class (multiple renderers). Each renderer would need to implement the default "formatting" of the data (dates: dd-MMM-yyy, numbers: right justified, etc) in addition to the "row/table" rendering requirements. So the answer really becomes "use five custom renderers". Now the "row/table" rendering code is found in 5 classes. Of course you could always move the "row/table" rendering code up to a common base class.
    b) render by table (single renderer). A single custom renderer would be created and would need to implement the default "formatting" for all data types in the table, in addition to the "row/table" rendering. The benefit is that all the rendering code is in one class. An example solution is include for this approach.
    Alternative Approach
    I recently came across an approach where the "formatting" of the data is still done by the default renderers and the "row/table" rendering is done at the table level by overriding the prepareRenderer() method. This approach is much simpler, but the rendering is done in two different places. Is this a problem?
    So, my question is which approach do you prefer:
    a) Traditional Approach - multiple renderers
    b) Triditional Approach - single renderer
    c) Alternative Approach
    Me, I like the alternative approach, but I'm more of a problem solver than I am a designer, so I don't know how the solution fits in a large scale application.
    Hopefully your response will consider:
    a) OO design principles
    b) class reusability
    c) class maintenance
    d) anything else you can think of
    import java.awt.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.table.*;
    public class TableRowRendering extends JFrame
        JTable table;
        Border selected = new LineBorder(Color.GREEN);
        public TableRowRendering()
            //  Model used by both tables
            Object[] columnNames = {"Type", "Date", "Company", "Shares", "Price"};
            Object[][] data =
                {"Buy", new Date(), "IBM", new Integer(1000), new Double(80.50)},
                {"Sell",new Date(), "MicroSoft", new Integer(2000), new Double(6.25)},
                {"Sell",new Date(), "Apple", new Integer(3000), new Double(7.35)},
                {"Buy", new Date(), "Nortel", new Integer(4000), new Double(20.00)}
            DefaultTableModel model = new DefaultTableModel(data, columnNames)
                public Class getColumnClass(int column)
                    return getValueAt(0, column).getClass();
            //  Traditional Approach
            table = new JTable( model );
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            getContentPane().add(new JScrollPane( table ), BorderLayout.WEST);
            TableCellRenderer custom = new CustomRenderer();
            table.setDefaultRenderer(Object.class, custom);
            table.setDefaultRenderer(String.class, custom);
            table.setDefaultRenderer(Date.class, custom);
            table.setDefaultRenderer(Number.class, custom);
            table.setDefaultRenderer(Double.class, custom);
            //  Alternative Approach
            table = new JTable( model )
                public Component prepareRenderer(
                    TableCellRenderer renderer, int row, int column)
                    Component c = super.prepareRenderer(renderer, row, column);
                    if (!isRowSelected(row))
                        String type = (String)getModel().getValueAt(row, 0);
                        c.setBackground(row % 2 == 0 ? null : Color.LIGHT_GRAY );
                    if (isRowSelected(row) && isColumnSelected(column))
                        ((JComponent)c).setBorder(selected);
                    return c;
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            getContentPane().add(new JScrollPane( table ), BorderLayout.EAST);
        //  Custom renderer used by Traditional approach
        class CustomRenderer extends DefaultTableCellRenderer
            DateFormat dateFormatter = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
            NumberFormat numberFormatter = NumberFormat.getInstance();
            public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column)
                super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
                //  Code for data formatting
                setHorizontalAlignment(SwingConstants.LEFT);
                if ( value instanceof Date)
                    setText(dateFormatter.format((Date)value));
                if (value instanceof Number)
                    setHorizontalAlignment(SwingConstants.RIGHT);
                    if (value instanceof Double)
                        setText(numberFormatter.format(((Number) value).floatValue()));
                //  Code for highlighting
                if (!isSelected)
                    String type = (String)table.getModel().getValueAt(row, 0);
                    setBackground(row % 2 == 0 ? null : Color.LIGHT_GRAY );
                if (table.isRowSelected(row) && table.isColumnSelected(column))
                    setBorder(selected);
                return this;
        public static void main(String[] args)
            TableRowRendering frame = new TableRowRendering();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }Before you make your final decision. What changes would be required for each solution in the following "what if " scenarios:
    a) what if, you added a Boolean column to the table
    b) what if, you added a second Double column to the table which should be formatted as a currency (ie. 1,234.5 --> $1,234.50).
    Here is an example of a currency renderer:
    class CurrencyRenderer extends DefaultTableCellRenderer
         private NumberFormat formatter;
         public CurrencyRenderer()
              super();
              formatter = NumberFormat.getCurrencyInstance();
              setHorizontalAlignment( SwingConstants.RIGHT );
         public void setValue(Object value)
              if ((value != null) && (value instanceof Number))
                   value = formatter.format(value);
              super.setValue(value);
    }

    Well, here's a partila solution using technique from a link you cited in another thread.
    import tests.basic.tables.ColorProvider;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.text.NumberFormat;
    public class DecoratedTablePrepareRenderer extends JFrame {
        JTable table;
        private DefaultTableModel model;
        public DecoratedTablePrepareRenderer() {
            Object[] columnNames = {"Type", "Company", "Price", "Shares", "Closed"};
            Object[][] data =
                        {"Buy", "IBM", new Double(80.50), new Double(1000), Boolean.TRUE},
                        {"Sell", "MicroSoft", new Double(6.25), new Double(2000), Boolean.FALSE},
                        {"Sell", "Apple", new Double(7.35), new Double(3000), Boolean.TRUE},
                        {"Buy", "Nortel", new Double(20.00), new Double(4000), Boolean.FALSE}
            model = new DefaultTableModel(data, columnNames);
            table = new JTable(model) {
                //  Returning the Class of each column will allow different
                //  renderers to be used based on Class
                public Class getColumnClass(int column) {
                    return getValueAt(0, column).getClass();
                public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
                    Component c = super.prepareRenderer(renderer, row, column);
                    if (isRowSelected(row))
                        c.setFont(c.getFont().deriveFont(Font.BOLD));
                    return c;
            ColorProvider prov = new TransactionColorProvider();
            ColorTableCellRenderer renderer = new ColorTableCellRenderer(table.getDefaultRenderer(Object.class),prov);
            ColorTableCellRenderer boolrenderer = new ColorTableCellRenderer(table.getDefaultRenderer(Boolean.class),prov);
            ColorTableCellRenderer doublerenderer = new ColorTableCellRenderer(table.getDefaultRenderer(Double.class),prov);
                    int priceIndex = model.findColumn("Price");
              table.getColumnModel().getColumn(priceIndex).setCellRenderer( new EtchedBorderTableCellRenderer(new ColorTableCellRenderer(new CurrencyRenderer(),prov) ));
            table.setDefaultRenderer(Object.class,new EtchedBorderTableCellRenderer(renderer));
            table.setDefaultRenderer(Double.class,new EtchedBorderTableCellRenderer(doublerenderer));
            table.setDefaultRenderer(Boolean.class, new EtchedBorderTableCellRenderer(boolrenderer));
            JScrollPane scrollPane = new JScrollPane(table);
            getContentPane().add(scrollPane);
        class CurrencyRenderer extends DefaultTableCellRenderer {
            private NumberFormat formatter;
            public CurrencyRenderer() {
                super();
                formatter = NumberFormat.getCurrencyInstance();
                setHorizontalAlignment(SwingConstants.RIGHT);
            public void setValue(Object value) {
                if ((value != null) && (value instanceof Number)) {
                    value = formatter.format(value);
                super.setValue(value);
        public static void main(String[] args) {
            DecoratedTablePrepareRenderer frame = new DecoratedTablePrepareRenderer();
            frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        class ColorTableCellRenderer implements TableCellRenderer{
            protected TableCellRenderer delegate;
            protected ColorProvider provider;
            public ColorTableCellRenderer(TableCellRenderer delegate, ColorProvider provider) {
                this.delegate = delegate;
                this.provider = provider;
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                Component c = delegate.getTableCellRendererComponent(table, value,isSelected,hasFocus,row, column);
                  c.setBackground(provider.getBackgroundColor(row, column));
                return c;
          class EtchedBorderTableCellRenderer implements TableCellRenderer{
            protected TableCellRenderer delegate;
            public EtchedBorderTableCellRenderer(TableCellRenderer delegate) {
                this.delegate = delegate;
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                JComponent c = (JComponent)delegate.getTableCellRendererComponent(table, value,isSelected,hasFocus,row, column);
                  JPanel panel = new JPanel(new GridLayout(0,1));
                  panel.add(c);
                  panel.setBorder(BorderFactory.createEtchedBorder());
                return panel;
        class TransactionColorProvider implements ColorProvider {
            private int keyIndex = 0;
            private Color sellColor = Color.yellow;
            private Color buyColor = Color.green;
            public TransactionColorProvider() {
                keyIndex = model.findColumn("Type");
            public Color getBackgroundColor(int row, int column) {
                 if( model.getValueAt(row,keyIndex).equals("Sell")){
                     return sellColor;
                else {
                     return buyColor;
            public Color getForegroundColor(int row, int column) {
                return Color.black;
    }Boolean values are problematical since JCheckBox does seem to like borders, using a panel as I did in the Etched renderer seems to work. This solution need a little more work, this is submitted as a prototype
    Cheers
    DB

Maybe you are looking for