2

我需要帮助。

我有两张桌子。 在此处输入图像描述

在指令表中,必须根据流水线阶段正在执行的指令突出显示每一行。比如说,在t10时刻,I5处于IS阶段,所以指令表中的I5必须高亮或者指令表中的行颜色必须改变。比如说,I5行是红色,I6行是粉红色, I7是绿色,I8是灰色,I9是橙色。

我真的需要你的专业知识。,谢谢你.. :)

4

1 回答 1

3

请尝试使用自定义渲染,这将轻松解决您的问题

JTable myTable = new JTable();
// You can specify the columns you need to do the required action
myTable.getColumnModel().getColumn(0).setCellRenderer(new MyRenderer());

public class MyRenderer extends DefaultTableCellRenderer {

    // This is a overridden function which gets executed for each action to
    /// your Jtable
    public Component getTableCellRendererComponent (JTable table, 
        Object obj, boolean isSelected, boolean hasFocus, int row, int column) {

       // Use this row, column to change color for the row you need, e.g.
        if (isSelected) { // Cell selected
           cell.setBackground(Color.green);
        }
    }
} 

注意:这个渲染器不仅仅可以做颜色高亮,请参考自定义 Jtable 渲染。为了对响应队列的更改计时,您可以将其安排在单独的线程中。

于 2012-03-21T13:35:56.233 回答