@Override public void updateUI() { // Bug ID: 6788475 Changing to Nimbus LAF and back doesn't reset look and feel of JTable // completely // http://bugs.java.com/view_bug.do?bug_id=6788475 // XXX: set dummy ColorUIResource setSelectionForeground(new ColorUIResource(Color.RED)); setSelectionBackground(new ColorUIResource(Color.RED)); super.updateUI(); putClientProperty("Table.isFileList", Boolean.TRUE); setCellSelectionEnabled(true); setIntercellSpacing(new Dimension()); setShowGrid(false); setAutoCreateRowSorter(true); setFillsViewportHeight(true); setDefaultRenderer( Object.class, new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return super.getTableCellRendererComponent(table, value, false, false, row, column); } }); TableColumn col = getColumnModel().getColumn(0); col.setCellRenderer(new FileNameRenderer(this)); col.setPreferredWidth(200); col = getColumnModel().getColumn(1); col.setPreferredWidth(300); }
//////////////////////////////////////////////////////// // Column processing //////////////////////////////////////////////////////// public void addColumn(String strName, int iModelIndex, int iWidth) { TableColumn col = new TableColumn(iModelIndex, iWidth); col.setHeaderValue(strName); col.setCellRenderer(new HeaderCellRenderer(this)); getColumnModel().addColumn(col); }