使用JTable的Nimbus外观和感觉

时间:2013-03-25 16:14:26

标签: java swing jtable look-and-feel nimbus

我正在制作一个下载管理器,我正在使用JTable。在JTable显示JProgressbar我使用表格单元格渲染器时,由于表格单元格渲染器应用了nimbus外观,我的程序会给出异常,但没有单元格渲染器表格,外观和感觉运行良好。“ / p>

表格单元格渲染器的代码是:

public class TableRender implements TableCellRenderer {    
    @Override
    public Component getTableCellRendererComponent(JTable table, 
        Object value, boolean isSelected, boolean hasFocus, 
        int row, int column) {

        return (JProgressBar) value;
    }        
}

对于Nimbus Look and Feel来说是:

try {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
    | UnsupportedLookAndFeelException e) {
    // If Nimbus is not available, you can set the GUI to another look and feel.
}

0 个答案:

没有答案