Changing a row colour in JTable, depending on a column value

Hi,
I need assistance with the following:
I need to change the colour of a row in a JTable, depending on a column value. I have been successful on changing one column's colour in each cell, depending on the value by using a CellRenderer extending DefaultTableCellRenderer.I am unable to set the other 2 columns's cell's depending on the first column value's.
I would appreciate any help, source would be a bonus.
Thx
Charl

Ok, here follows the code as requested. Note that this is the code setting each row in one of my columns depending on the value. Now i have to cgange column0 and column1 's foreground the same as what this column (column2) 's foreground is. Thx
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
class ColorizedCell extends DefaultTableCellRenderer {
static Hashtable cache;
static {
cache = new Hashtable();
cache.put ("Device Responding to Poll",Color.green);
cache.put ("Wan link Recovered",Color.green);
cache.put ("No Response to Device Poll",Color.yellow);
cache.put ("Wan Link Failure",Color.red);
cache.put ("Lan Link Failure down",Color.red);
cache.put ("Device Down",Color.red);
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected,
boolean hasFocus, int row, int column)
JLabel label = (JLabel) super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
label.setText((String)value);
if(column == 2) {
//setFont(bold);
Color c = (Color)cache.get(value);
label.setForeground(c);
if (isSelected) {
label.setOpaque(true);
label.setBackground(Color.white);
else {
//setFont(plain);
label.setForeground(Color.white);
return label;
}

Similar Messages

  • Assigning rows in JTable a set text colour depending on a column value

    Hi Guys
    I am sending my table a vector containing data from an Oracle db.
    The data will have one column named type, and it will be either 'Training' or 'Holiday'.
    I want the text of the entire row in the table to be Blue if the Type is 'Training', and red if the type is 'Holiday'.
    The type column is the 3rd column in the table.
    How can I set the Color of my table rows?
    whatr is the best way to do it?

    I dont understand how to do my selection code:
    I want to check the Type column of each row and set colour = blue if type = "training" and color = red if type = "holiday".
    What code should i put in the expression braces?
    and whats the correct syntax to cghange the colour of the text in the ENTIRE row please?
    heres my code as it is.
    public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value,
                                                                          boolean isSelected, boolean hasFocus, int row, int column)
         JLabel cell = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
         if (Type.equals("Training"))
              setForeground(Red);
         else
              setForeground(Blue);
         return cell;
    }

  • Color a row in JTable according to specific column value

    I'm having problem setting row color according to specific values set in listData. Color values are also stored inside the listData. Each row has a specific color value assigned to it(either black or blue).
    ColorRenderer is called from table.setDefaultRenderer(Object.class, new ColorRenderer(listData))
    The color values are passed through to ColorRender constructor but not to the getTableCellRendererComponent() method.
    Here is my code. Any help is much appreciated.
    class ColorRenderer extends DefaultTableCellRenderer {
    Color[] colors;
    public ColorRenderer(ListData[] listData) {
    if (listData != null) {
    for (int i=0; i<listData.length; i++) {
         if (listData[i] != null) {
         colors = new Color[listData.length];
         colors[i] = listData.getForegroundColor();
         System.out.println(colors[i].toString());
    else System.out.println("null listData");
    public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    JLabel c =(JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    c.setOpaque(true);
    System.out.println("colors.length: " + colors.length);
    for (int i=0; i<colors.length; i++) {
    if (colors[i] != null) {        
    System.out.println("colors["+i+"]: " + colors[i]);
    c.setForeground(colors[i]);
    } else c.setForeground(Color.black);
    return c;

    Well, first of all, you didn't use the code tokens for your posting. Second, this source won't even compile how you have it. But anyway...
    If you want to change the color of the cell based on the row, assuming you have a matching color in your color list for each row, in your getTableCellRendererComponent() method, just do something like this.
    c.setForeground( colors[row] );

  • Showing particular row in a color depending on a column in classical report

    Hi,
    I have a classical report with a column as "Affirmation Status". This column can take three value as "Affirmed, Rejected or NA". My requirement is I have to show all row in one color like red wherever it has value affirmed, and all row in color like green wherever it is rejected.
    Pls give some idea.

    Hi chandra Bhanu,
    create PL/SQL Dynamic content region for your report for showing the row in different color on the basis of conditions
    i am giving you sample code..you can modify according to your requirement
    declare
    cursor emp_data
    is
    select empno,ename,sal,status from emp;
    begin
    htp.p('<table width="100%" bgcolor="#DCE6F1"><tr>');
    htp.p('<td width ="20%"><b>Empno</b></td>');
    htp.p('<td width ="20%"><b>Employee Name</b></td>');
    htp.p('<td width ="20%"><b>Salary</b></td>');
    htp.p('<td width ="20%"><b>Status</b></td>');
    htp.p('</tr></table>');
    for c_emp_data in emp_data
    loop
    htp.p('<table width="100%"><tr><td>');
    if c_emp_data.status = 'Affirmed' then
    htp.p('<TABLE width="100%"><tr bgcolor="#FF0000">');
    htp.p('<td width ="25%">'||c_emp_data.empno||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.ename||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.sal||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.status||'</td>');
    htp.p('</tr></table>');
    elsif  c_emp_data.status = 'Rejected' then
    htp.p('<TABLE width="100%"><tr bgcolor="#006400">');
    htp.p('<td width ="25%">'||c_emp_data.empno||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.ename||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.sal||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.status||'</td>');
    htp.p('</tr></table>');
    else
    htp.p('<TABLE width="100%"><tr>');
    htp.p('<td width ="25%">'||c_emp_data.empno||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.ename||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.sal||'</td>');
    htp.p('<td width ="25%">'||c_emp_data.status||'</td>');
    htp.p('</tr></table>');
    end if;
    htp.p('</td></tr></table>');
    end loop;
    end;Hope this will helps you.
    Regards,
    Jitendra

  • How to get a specific Row based on filter on a specific column value

    Friends,
    I have a requirement to fetch a row, maximum salary of an employee row from employee table using ADF View object, I have a view object with result set based on some critieria, now I have to get a row out of result set which is having maximum employee salary.
    Please put your thoughts or experiences!!
    Thanks

    You should be able to add a transient attribute called maxSalary and use groovy functions to find vo.max(Salary) like -
    https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in
    How to calculate ADF table column [check Laura Akel's post]Then you can create a view criteria which equates the salaryfield to maxSalary and returns just one row.

  • How to display the rows number of times by giving the column values?

    Hi All,
    I want to display the rows number of times as the value exists in num column in the below query
    with t AS
       ( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
         UNION ALL
         SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
         UNION ALL
         SELECT 'krishna' NAME,     'hyd' LOC, 1 NUM FROM DUAL )
      SELECT T.* FROM T
      CONNECT BY ROWNUM <= NUM
    Expected output:
             venkatesh            hyd      2
             venkatesh            hyd        2
             prasad                 hyd        3
             prasad                   hyd      3
             prasad                   hyd      3
             krishna           hyd       1Edited by: Nag Aswadhati on Nov 1, 2012 12:34 AM

    Nag Aswadhati wrote:
    Hi All,
    I want to display the rows number of times as the value exists in num column in the below query
    Expected output:
    venkatesh            hyd      2
    venkatesh            hyd        2
    prasad                 hyd        3
    prasad                   hyd      3
    prasad                   hyd      3
    krishna           hyd       1Using Connect By:-
    with t AS
       ( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
         UNION ALL
         SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
         UNION ALL
         select 'krishna' name,     'hyd' loc, 1 num from dual )
      select t.name, t.loc
      from t
      connect by level <= num
             and name = prior name
             and (prior sys_guid() is not null);
    NAME      LOC
    krishna   hyd
    prasad    hyd
    prasad    hyd
    prasad    hyd
    venkatesh hyd
    venkatesh hyd
    6 rows selected

  • How to change row colour without using WDTableCellDesign

    Hi
    I change the row colour of my tree table depending on the level of the tree.
    WDTableCellDesign doesn't have the colours that I want.
    I want to use different shades of blue.
    How do i do this?
    I have a variable of type type     com.sap.ide.webdynpro.uielementdefinitions.TableCellDesign which I change with WDTableCellDesign elements.
    Is there another type that I can use?

    Anton,
    You may only used limited(?) set of standard table cell designs.
    Alternatevily, you must create complete WD theme using Theme Editor.
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • Need to  color a Table row based on a Column value

    Dear Alll
    I have a requirement to color the rows of a table based on a column value in it. I have tried and surfed many useful materials over the net. but none of them solves my purpose. Please help me, I know that i can used OADataBoundValueViewObject and create a custom css file and apply color to a particular column of a table using a decode in the select statement of that VO.
    But all i need is to color a particular row with a particular color. Need your help with this ........
    Please do reply
    Best Regards
    Edited by: Antony Jayaraj on Mar 27, 2012 8:54 PM

    These posts might help you.
    How to change the row color based on Condition
    Can we colour the rows in the column of a table
    Regards,
    Peddi.

  • Change the color of a particular row in a jtable

    I have a jtable and i want to change the color of one particular column and few rows to blue and underline the text depending on some condition. In my view class if a condition is true
    for( count=0;count<grdTest.getRowcount;count++)
    if(some condition true)
    grdTest.getColumnModel().getColumn(0).
    setCellRenderer(new MyTestCellRenderer(count));
    And my cell renderer
    public class MyTestCellRenderer extends DefaultTableCellRenderer {
    int rowIndex=-1;
    public MyTestCellRenderer(int rowcount) {
    super();
    rowIndex=rowcount;
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value,
    isSelected, hasFocus, row, column);
    if(row == rowIndex)
    setText("<html> <u> <font color='blue'>" + value.toString());
    return this;
    This is behaving very wierd . If suppose there are 50 rows and all of them have the condition true then only the last one in the row color is changes.
    However if only one out othe say10 has the condition true then it changes the color and underlines the particular row,column.
    Is there any other way to do this or what i am doing wrong
    Thanks

    if(row == rowIndex)Your code is a shambles because of the lack of tags, but I don't believe I see anything being called when this boolean condition is not true. That would be a problem.                                                                                                                                                                                                                                                                                                                                                                                                           

  • Changing background color in JTable, only changes one row at a time...

    I'm trying to change the color of rows when the 5th column meets certain criteria. I think I'm very close, but I've hit a wall.
    What's happening is the row will change color as intended when the text in the 5th column is "KEY WORD", but when I type "KEY WORD" in a different column it will set the first row back to the regular colors. I can easily see why it's doing this, everytime something is changed it rerenders every cell, and the listener only checks the cell that was just changed if it met the "KEY WORD" condition, so it sets every cell (including the previous row that still meets the condition) to the normal colors. I can't come up with a good approach to changing the color for ALL rows that meet the condition. Any help would be appreciated.
    In this part of the CellRenderer:
            if (isSelected)
                color = Color.red;
            else
                color = Color.blue;
            if (hasFocus)
                color = Color.yellow;
            //row that meets special conditions
            if(row == specRow && col == specCol)
                color = color.white; I was thinking an approach would be to set them to their current color except for the one that meets special conditions, but the two problems with that are I can't figure out how to getColor() from the table, and I'm not sure how I would initially set the colors.
    Here's the rest of the relevant code:
        public void tableChanged(TableModelEvent e)
            int firstRow = e.getFirstRow();
            int lastRow  = e.getLastRow();
            int colIndex = e.getColumn();
            if(colIndex == 4)
                String value = (String)centerTable.getValueAt(firstRow, colIndex);
                // check for our special selection criteria
                if(value.equals("KEY WORD"))
                    for(int j = 0; j < centerTable.getColumnCount(); j++)
                        CellRenderer renderer =
                            (CellRenderer)centerTable.getCellRenderer(firstRow, j);
                        renderer.setSpecialSelection(firstRow, j);
    import javax.swing.table.*;
    import javax.swing.*;
    import java.awt.Component;
    import java.awt.Color;
    public class CellRenderer extends DefaultTableCellRenderer
        int specRow, specCol;
        public CellRenderer()
            specRow = -1;
            specCol = -1;
        public Component getTableCellRendererComponent(JTable table,
                                                       Object value,
                                                       boolean isSelected,
                                                       boolean hasFocus,
                                                       int row, int col)
            setHorizontalAlignment(JLabel.CENTER);
            Color color = Color.green;
            if (isSelected)
                color = Color.red;
            else
                color = Color.blue;
            if (hasFocus)
                color = Color.yellow;
            if(row == specRow && col == specCol)
                color = color.white;
            //setForeground(color);
            setBackground(color);
            setText((String)value);
            return this;
        public void setSpecialSelection(int row, int col)
            specRow = row;
            specCol = col;
    }If I'm still stuck and more of my code is needed, I'll put together a smaller program that will isolate the problem tomorrow.

    That worked perfectly for what I was trying to do, but I've run into another problem. I'd like to change the row height when the conditions are met. What I discovered is that this creates an infinite loop since the resizing triggers the renderer, which resizes the row again, etc,. What would be the proper way to do this?
    Here's the modified code from the program given in the link. All I did was declare the table for the class, and modify the if so I could add the "table.setRowHeight(row, 30);" line.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    public class TableRowRenderingTip extends JPanel
        JTable table;
        public TableRowRenderingTip()
            Object[] columnNames = {"Type", "Company", "Shares", "Price", "Boolean"};
            Object[][] data =
                {"Buy", "IBM", new Integer(1000), new Double(80.5), Boolean.TRUE},
                {"Sell", "Dell", new Integer(2000), new Double(6.25), Boolean.FALSE},
                {"Short Sell", "Apple", new Integer(3000), new Double(7.35), Boolean.TRUE},
                {"Buy", "MicroSoft", new Integer(4000), new Double(27.50), Boolean.FALSE},
                {"Short Sell", "Cisco", new Integer(5000), new Double(20), Boolean.TRUE}
            DefaultTableModel model = new DefaultTableModel(data, columnNames)
                public Class getColumnClass(int column)
                    return getValueAt(0, column).getClass();
            JTabbedPane tabbedPane = new JTabbedPane();
            tabbedPane.addTab("Alternating", createAlternating(model));
            tabbedPane.addTab("Border", createBorder(model));
            tabbedPane.addTab("Data", createData(model));
            add( tabbedPane );
        private JComponent createAlternating(DefaultTableModel model)
            JTable table = new JTable( model )
                public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
                    Component c = super.prepareRenderer(renderer, row, column);
                    //  Alternate row color
                    if (!isRowSelected(row))
                        c.setBackground(row % 2 == 0 ? getBackground() : Color.LIGHT_GRAY);
                    return c;
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            table.changeSelection(0, 0, false, false);
            return new JScrollPane( table );
        private JComponent createBorder(DefaultTableModel model)
            JTable table = new JTable( model )
                private Border outside = new MatteBorder(1, 0, 1, 0, Color.RED);
                private Border inside = new EmptyBorder(0, 1, 0, 1);
                private Border highlight = new CompoundBorder(outside, inside);
                public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
                    Component c = super.prepareRenderer(renderer, row, column);
                    JComponent jc = (JComponent)c;
                    // Add a border to the selected row
                    if (isRowSelected(row))
                        jc.setBorder( highlight );
                    return c;
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            table.changeSelection(0, 0, false, false);
            return new JScrollPane( table );
        public JComponent createData(DefaultTableModel model)
            table = new JTable( model )
                public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
                    Component c = super.prepareRenderer(renderer, row, column);
                    //  Color row based on a cell value
                    if (!isRowSelected(row))
                        c.setBackground(getBackground());
                        String type = (String)getModel().getValueAt(row, 0);
                        if ("Buy".equals(type)) {
                            table.setRowHeight(row, 30);
                            c.setBackground(Color.GREEN);
                        if ("Sell".equals(type)) c.setBackground(Color.YELLOW);
                    return c;
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            table.changeSelection(0, 0, false, false);
            return new JScrollPane( table );
        public static void main(String[] args)
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
        public static void createAndShowGUI()
            JFrame.setDefaultLookAndFeelDecorated(true);
            JFrame frame = new JFrame("Table Row Rendering");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add( new TableRowRenderingTip() );
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    }Edited by: scavok on Apr 26, 2010 6:43 PM

  • To change the font of a selected row in a Jtable

    Hello,
    Is it possible to change the font of a selected row in a jtable?
    i.e. if all the table is set to a bold font, how would you change the font of the row selected to a normal (not bold) font?
    thank you.

    String will be left justified
    Integer will be right justified
    Date will be a simple date without the time.
    As it will with this renderer.Only if your custom renderer duplicates the code
    found in each of the above renderers. This is a waste
    of time to duplicate code. The idea is to reuse code
    not duplicate and debug again.
    No, no, no there will be NO duplicated code.
    A single renderer class can handle all types ofdata.
    Sure you can fit a square peg into a round hole if
    you work hard enough. Why does the JDK come with
    separate renderers for Date, Integer, Double, Icon,
    Boolean? So that, by default the rendering for common classes is done correctly.
    Because its a better design then having code
    with a bunch of "instanceof" checks and nested
    if...else code.This is only required for customization BEYOND what the default renderers provide
    >
    And you would only have to use instanceof checkswhen you required custom
    rendering for a particular classAgreed, but as soon as you do require custom
    renderering you need to customize your renderer.
    which you would also have to do with theprepareRenderer calls too
    Not true. The code is the same whether you treat
    every cell as a String or whether you use a custom
    renderer for every cell. Here is the code to make the
    text of the selected line(s) bold:
    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;
    }It will work for any renderer used by the table since
    the prepareRenderer(...) method returns a Component.
    There is no need to do any kind of "instanceof"
    checking. It doesn't matter whether the cell is
    renderered with the "Object" renderer or the
    "Integer" renderer.
    If the user wants to treat all columns as Strings or
    treat individual columns as String, Integer, Data...,
    then they only need to override the getColumnClass()
    method. There is no change to the prepareRenderer()
    code.
    Have you actually tried the code to see how simple it
    is?
    I've posted my code. Why don't you post your solution
    that will allow the user to bold the text of a Date,
    Integer, and String data in separate column and then
    let the poster decide.Well, I don't see a compilable, runnable demo anywhere in this thread. So here's one
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Arrays;
    import java.util.Date;
    import java.util.Vector;
    public class TableRendererDemo extends JFrame{
        String[] headers = {"String","Integer","Float","Boolean","Date"};
        private JTable table;
        public TableRendererDemo() {
            buildGUI();
        private void buildGUI() {
            JPanel mainPanel = (JPanel) getContentPane();
            mainPanel.setLayout(new BorderLayout());
            Vector headerVector = new Vector(Arrays.asList(headers));
             Vector data = createDataVector();
            DefaultTableModel tableModel = new DefaultTableModel(data, headerVector){
                public Class getColumnClass(int columnIndex) {
                    return getValueAt(0,columnIndex).getClass();
            table = new JTable(tableModel);
    //        table.setDefaultRenderer(Object.class, new MyTableCellRenderer());
            table.setDefaultRenderer(String.class, new MyTableCellRenderer());
            table.setDefaultRenderer(Integer.class, new MyTableCellRenderer());
            table.setDefaultRenderer(Float.class, new MyTableCellRenderer());
            table.setDefaultRenderer(Date.class, new MyTableCellRenderer());
            JScrollPane jsp = new JScrollPane(table);
            mainPanel.add(jsp, BorderLayout.CENTER);
            pack();
            setLocationRelativeTo(null);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        private Vector createDataVector(){
            Vector dataVector = new Vector();
            for ( int i = 0 ; i < 10; i++){
                Vector rowVector = new Vector();
                rowVector.add(new String("String "+i));
                rowVector.add(new Integer(i));
                rowVector.add(new Float(1.23));
                rowVector.add( (i % 2 == 0 ? Boolean.TRUE : Boolean.FALSE));
                rowVector.add(new Date());
                dataVector.add(rowVector);
            return dataVector;
        public static void main(String[] args) {
            Runnable runnable = new Runnable() {
                public void run() {
                    TableRendererDemo tableRendererDemo = new TableRendererDemo();
                    tableRendererDemo.setVisible(true);
            SwingUtilities.invokeLater(runnable);
        class MyTableCellRenderer extends DefaultTableCellRenderer{
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                if ( isSelected){
                    setFont(getFont().deriveFont(Font.BOLD));
                else{
                    setFont(getFont().deriveFont(Font.PLAIN));
                if ( value instanceof Date){
                    SimpleDateFormat formatter =(SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
                    setText(formatter.format((Date)value));
                if(value instanceof Number){
                   setText(((Number)value).toString());
                return this;
    }Hardly a "bunch of instanceof or nested loops. I only used the Date instanceof to allow date format to be specified/ modified. If it was left out the Date column would be "18 Apr 2005" ( DateFormat.MEDIUM, which is default).
    Cheers
    DB

  • How to get more than 4 coloured rows in a report depending on column values

    Hi,
    I've looked through the forum and found some stuff on mutli-coloured reports and found the link to http://htmldb.oracle.com/pls/otn/f?p=11933:7:557008579481721819
    But I have several problems:
    This shows how to get 3 colours, but it's easy to get up to 4 by just using the "Column Templates" in a new report template.
    I don't understand where to put the snippets. It says to put them in "Row Templates" , "Before Rows" and "After Rows" but my report template page doesn't have these options! I've got "Column Templates" (4 of them), "Before Each Row" and "After Each Row".
    Am I looking at a link for an old version?
    What I want to do is set the row colour dependant on a column called "level" which is between 1 and 5.
    Thanks

    Hi Vikas,
    It's almost perfect now. My only problem is that the pagination table is, for some reason, enclosed within the results table (I've used FireFox web developer's tools and checked the souce HTML to be sure of this). So, if I have a border at table level, it appears on the row containing the pagination.
    I've had to remove table borders and put right borders on the table data cells, but I can't find a way to put left borders on the table rows, so I have a pretty table with 5 levels of colour, but no borders on the left-hand side.
    Ideally I'd like to avoid having the pagination stuff within the results table, but I can't see how/where to put a </table> to sort this out!
    Ros

  • How to chang the row's color in the Jtable?

    I have a table and many rows,I want chang the rows color,like row one's color is red,row tow's color is write,row three's color is green.How can do it? And if i want chang row 3,coloum 2's color.How can do it?
    thanks.

    hi,
    I use jdbtable to view data,I want them to chang row color when some cells equal the value.But interface getTableCellRendererComponent not run.I don't know why!
    jdbtable is extend jtable ,it made in borland jbuilder.
    //1 class
    package errorreport;
    import java.awt.Component;
    import java.awt.Color;
    import javax.swing.table.DefaultTableCellRenderer;
    import com.borland.dbswing.*;
    public class rowcolor extends DefaultTableCellRenderer {
    public Component getTableCellRendererComponent
    (JdbTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column)
    Component cell = super.getTableCellRendererComponent
    (table, value, isSelected, hasFocus, row, column);
    int iColcount = 0;
    iColcount = table.getColumnCount();
    if( value instanceof String )
    String strAlmlev = (String)value;
    if(strAlmlev.trim().equals("C1"))
    cell.setBackground( Color.red );
    // You can also customize the Font and Foreground this way
    // cell.setForeground();
    // cell.setFont();
    else
    if(strAlmlev.trim().equals("C2"))
    cell.setBackground( Color.orange );
    else
    if(strAlmlev.trim().equals("C3"))
    cell.setBackground( Color.yellow );
    else
    if(strAlmlev.trim().equals("ERR"))
    cell.setBackground( Color.green );
    return cell;
    //2 class
    JdbTable jdbTable2 = new JdbTable();
    TableCellRenderer renderer = new rowcolor();
    try
    jdbTable2.setDefaultRenderer( Class.forName( "java.lang.String" ), renderer );
    catch( ClassNotFoundException ex )
    System.exit( 0 );
    thanks

  • Colouring Rows of a Table depending on a particular condition.

    Hi,
        The problem I am facing is coloring specific rows of a table depending on the satisfaction of a particular condtion. For example: All rows having the value in the amount column greater than 1000 have to be coloured in red and the remaining yellow.
         Can anyone please help me out with this row-coloring problem?
    Regards,
    Gaurav.

    Hi Martin,
    Have used an image column to display image.
    You can define the condition in the URL field, to display the image. Something like:
    =IF(@img=="50",store@IMAGE_URL&"Green_dot.png",IF(@img=="40",store@IMAGE_URL&"Yellow_dot.png",IF(@img=="39",store@IMAGE_URL&"Red_dot.png","")))
    Where store@IMAGE_URL has the URL to the location where the images are stored.
    Let me if it helps.
    Regards,
    Dharmi

  • Reslut row colour changing in query desinger

    Hi All,
    I need to change my result row colour from yellow to some other for single query.
    How can i achive this please?
    regards
    Srini

    Hi Srini,
    I dont think you can change that. May be you need to change some of the SAP function modules for that.
    Some options are:
    1. Use Report designer and choose the colour you need. This is only available in BI 7.0
    2. You can save the report output as a workbook and make the formating changes.
    Bye
    Dinesh

Maybe you are looking for

  • How to connect to SAP AS JAVA?

    Hi, I am developing an JAVA application, which will connect to SAP AS Java dataSource. My environment don't have ABAP installed. So, I believe use of JCo connector is not an option. Is ther any other connector API jar available to connect to SAP AS J

  • Easy filing of messages in Yosemite mail?

    I'm trying Yosemite Mail. It looks nice, but I'm wondering if there are yet any easy ways of filing messages into mailboxes with shortcuts, or is the only way still to use the Move feature and scroll through all your mailboxes until you find the one

  • Is there a fix for an InDesign file with error code 3?

    I have: reset preferences, exported to older file type, opened it on a different machine, etc. Everytime I try to click a page at the beginning of the document, ID crashes and has to reboot. CS6.

  • Importing Word doc gives an error RoboHelp 10 trial

    Using the Trial version to evaulate the RoboHelp.  I get an error message "import session failed (0x80004005).  If this error continues please contact Techincal Support. Any assistance would be greatly appreciated. thanks Shammi

  • MacBook Pro Charger - Intermittantly Stops Working

    Hi All, I have had my macbook pro now for just over a year and unlucky for me im 20 days out of my 1 year warrenty and now not entitle to upgrade to apple care because of this when i phoned techincal support The macbook pro charger is working intermi