Render a single cell in a table using Java

19 visualizaciones (últimos 30 días)
Yuval Mika
Yuval Mika el 30 de En. de 2019
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);

Respuestas (0)

Categorías

Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by