Home How to apply Zebra-Color-Style row render method to jTables (JAVA)?
Reply: 0

How to apply Zebra-Color-Style row render method to jTables (JAVA)?

Tissera
1#
Tissera Published in 2018-02-14 05:54:50Z

I would like to add RowRender Zebra-Color-Style (as Nimber) for Windows Look and Feel. But I haven't any idea, how can I do it. So please support to find an correct answer as a simple solution.

(Note: This is my very first application in java and first question in Stackoverflow.)

    Method I have wrote in a java class ("TableRowColor.java")

    package Config;

    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.table.TableCellRenderer;

     /**
     *
     * @author ABC
     */
     public class TableRowColor extends JTable{

     public Component prepareRender(TableCellRenderer ren,int r,int c){

     Component comp = super.prepareRenderer(ren, r, c);

         if(r%2==0 && !isCellSelected(r, c)){

             comp.setBackground(new Color(144,136,136));

         }else if(!isCellSelected(r, c)){

             comp.setBackground(new Color(252,252,252));

         }else {

             comp.setBackground(Color.WHITE);     
    }       
    return comp;
}    
}

And I have few frames with Tables. So I would like to add this method for all that tables. As an example, How can apply this method to HomePanel.jTable_1 (HomePanel - Jframe Form)?

Thanx!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.338743 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO