Render a single cell in a table using Java
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a sample code creating a simple uitable object and trying to render one of its cells. The code is running with no exceptions but the cell's color does not change. Any ideas what might be the problem?
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
f = figure;
hTable = uitable(f,'Data',randi(100,10,3));
jScroll = findjobj(hTable);
jTable = jScroll.getViewport.getView;
row = 1;
col = 1;
renderer = jTable.getCellRenderer(row, col);
value = jTable.getValueAt(row, col);
comp = renderer.getTableCellRendererComponent(...
jTable, value, false, false, row,...
col);
comp.setBackground(Color(1,1,0));
column = jTable.getColumnModel().getColumn(col);
column.setCellRenderer(comp);
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Construct and Work with Object Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!