Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java swing stripes

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import java.awt.*;

public class MyTable extends JTable {
    public MyTable(TableModel model) {
        super(model);
    }

    @Override
    public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
        Component c = super.prepareRenderer(renderer, row, column);
        if (!c.getBackground().equals(getSelectionBackground())) {
            Color colour = (row % 2 == 0 ? Color.WHITE : Color.LIGHT_GRAY);
            c.setBackground(colour);
        }
        return c;
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: Get the first Monday of a month in Java 
Java :: how to use base64.getdecoder() android 
Java :: rates api 
Java :: data to string format java 
Java :: how to navigate to last back stack in android studio 
Java :: traversing 2d array java 
Java :: convert string to sql date in java 
Java :: public static int to String java 
Java :: close searchview android java 
Java :: how to make an arraylist java 
Java :: check if string has a valid number java 
Java :: how to iterate hashmap in java 
Java :: java string multiply 
Java :: android onlcik java 
Java :: java retirer derniere caractere sting 
Java :: android studio float to int 
Java :: jframe button 
Java :: java coding problems 
Java :: how to import java.util 
Java :: groovy string to json 
Java :: kotlin textview center text 
Java :: send variable intent 
Java :: change color of jframe 
Java :: change status bar color android programmatically 
Java :: convert double to in in java 
Java :: java csv 
Java :: loop through a 2d array java 
Java :: java outer class 
Java :: Failed to determine a suitable driver class 
Java :: import random java 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =