1
열 클래스를 정의하여 정렬하도록 열을 관리 한 후 - 이제 내 셀 렌더링이 문자열 값을 포함하고 정수 열에 적용되지 않는 열에만 적용됩니까?열 클래스의 정수 정의는 표 셀 렌더러를 나누거나 건너 뜁니 까?
이 문자열과 정수 클래스에 대한 열 클래스 정의를 보여줍니다
JTable compTable5 = new JTable();
compTable5.setEnabled(false);
DefaultTableModel model5 = new DefaultTableModel(){
@Override
public Class getColumnClass(int column) {
switch (column) {
case 0:
return String.class;
case 1:
return Integer.class;
default:
return String.class;
}
}
};
이이 렌더러
compTable5.setDefaultRenderer(Object.class, new DefaultTableCellRenderer(){
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int col) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
int status = (int)table.getValueAt(row, 1);
String status2 = (String)table.getValueAt(row, 5);
if ("Not Used".equals(status2)) {setBackground(Color.lightGray);setForeground(Color.black);}
else if (status2.equals("Priority 1")) {setBackground(scaleRed);}
else if (status == 0 && !status2.equals("Working") && !status2.equals("Not Used") && !status2.equals("Priority 1")) {setBackground(pink);setForeground(Color.black);}
else if (status < 20) {setBackground(scaleRed);}
else if (status >= 20 && status < 40) {setBackground(scaleOrange);setForeground(Color.black);}
else if (status >= 40 && status < 60) {setBackground(scaleYellow);setForeground(Color.black);}
else if (status >= 60 && status < 80) {setBackground(scaleGreen1);setForeground(Color.black);}
else if (status >= 80 && status < 100) {setBackground(scaleGreen2);setForeground(Color.black);}
else if (status > 100) {setBackground(scaleBlue);setForeground(Color.white);}
else {
setBackground(table.getBackground());
setForeground(table.getForeground());
}
return this;
}
});
내가 자바 멍청한 놈이고이 처음 유래입니다 게시,이 포럼에서 이미 제공 한 모든 도움에 감사드립니다.
당신이 내 문제를 해결 도움을 위해 너무 많은 감사합니다! – BlueSteel