mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 15:03:21 -04:00
added a number column to the test result table
This commit is contained in:
parent
a7ec6b73c6
commit
70fe4f8d77
@ -55,7 +55,9 @@ public class TestResultDialog extends JDialog {
|
||||
TestResult tr = new TestResult(ts.data).create(model);
|
||||
|
||||
JTable table = new JTable(new TestResultModel(tr));
|
||||
table.setDefaultRenderer(MatchedValue.class, new MyRenderer());
|
||||
table.setDefaultRenderer(MatchedValue.class, new MatchedValueRenderer());
|
||||
table.setDefaultRenderer(Integer.class, new NumberRenderer());
|
||||
table.getColumnModel().getColumn(0).setMaxWidth(40);
|
||||
|
||||
String tabName;
|
||||
Icon tabIcon;
|
||||
@ -120,7 +122,7 @@ public class TestResultDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyRenderer extends DefaultTableCellRenderer {
|
||||
private static class MatchedValueRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
@ -141,4 +143,16 @@ public class TestResultDialog extends JDialog {
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
private static class NumberRenderer extends DefaultTableCellRenderer {
|
||||
private static final Color NUM_BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel comp = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
comp.setBackground(NUM_BACKGROUND_COLOR);
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,17 +31,23 @@ public class TestResultModel implements TableModel {
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return testResult.getSignalCount();
|
||||
return testResult.getSignalCount() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
return testResult.getSignalName(columnIndex);
|
||||
if (columnIndex == 0)
|
||||
return "No";
|
||||
else
|
||||
return testResult.getSignalName(columnIndex - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
return MatchedValue.class;
|
||||
if (columnIndex == 0)
|
||||
return Integer.class;
|
||||
else
|
||||
return MatchedValue.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,7 +57,10 @@ public class TestResultModel implements TableModel {
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
return testResult.getResultValue(rowIndex, columnIndex);
|
||||
if (columnIndex == 0)
|
||||
return rowIndex;
|
||||
else
|
||||
return testResult.getResultValue(rowIndex, columnIndex - 1);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user