Render a single cell in a table using Java
19 ビュー (過去 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!