Render a single cell in a table using Java
18 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!