Cell Paint « JTable « Java Swing Q&A





1. Can we paint a JTable cell partially?    stackoverflow.com

Is it possible to paint a JTable cell alone partially?Like 40% of it is green remaining is red?

2. JTable paint the cells    coderanch.com

import java.awt.*; import javax.swing.*; import javax.swing.table.*; public class TableHighlights { private JTable getTable() { JTable table = new JTable(new CustomModel()) { public Class getColumnClass(int column) { return ((CustomModel)getModel()).data[0][column].getClass(); } }; table.setDefaultRenderer(String.class, new GPARenderer()); return table; } public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(new JScrollPane(new TableHighlights().getTable())); f.setSize(400,400); f.setLocation(200,200); f.setVisible(true); } } class CustomModel extends AbstractTableModel { ...