如何在 Swing 中的模型表中以红色显示数据?
表数据正确。如果结果是通过,它应该显示为绿色并且结果失败,那么在摇摆的模型表中同样应该是红色
if (newResultSet.isEmpty() != true) {
// System.out.println("final calculated summary records size : "+newResultSet.size());
for (int indx = 0; indx < newResultSet.size(); indx++) {
Resultset rs = (Resultset) newResultSet.get(indx);
Object[] row = new Object[6];
row[0] = rs.getTestCaseNumber();
row[1] = rs.getTestExecution();
row[2] = rs.getTestCasePass();
row[3] = rs.getTestCaseFail();
row[4] = rs.getTestResult();
row[5] = rs.getTestCaseDateTime();
//System.out.println(row[0].toString()+" "+row[2].toString()+" "+row[3].toString());
model.addRow(row);
}
} else {
JOptionPane.showMessageDialog(null, "NO DATA IS AVAILABLE TO DISPLAY", "Empty Message", JOptionPane.ERROR_MESSAGE);
}
}
public void createAndShowGUI() {
JFrame frame = new JFrame("Execution Report Table");
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
summarizeData();
final JTable table = new JTable(model);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane);
setOpaque(true); //content panes must be opaque
frame.setLayout(new GridLayout(1, 0));
frame.pack();
frame.setVisible(true);
}
我想在 ModelTable 中以红色和绿色行显示结果。