public FileNameRenderer(JTable table) {
    Border b = UIManager.getBorder("Table.noFocusBorder");
    if (Objects.isNull(b)) { // Nimbus???
      Insets i = focusCellHighlightBorder.getBorderInsets(textLabel);
      b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right);
    }
    noFocusBorder = b;

    p.setOpaque(false);
    panel.setOpaque(false);

    // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons
    nicon = new ImageIcon(getClass().getResource("wi0063-16.png"));
    sicon =
        new ImageIcon(
            p.createImage(
                new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter())));

    iconLabel = new JLabel(nicon);
    iconLabel.setBorder(BorderFactory.createEmptyBorder());

    p.add(iconLabel, BorderLayout.WEST);
    p.add(textLabel);
    panel.add(p, BorderLayout.WEST);

    Dimension d = iconLabel.getPreferredSize();
    dim.setSize(d);
    table.setRowHeight(d.height);
  }
Beispiel #2
0
 // Set the width/height of columns/rows by the largest rendering entry
 private void customiseMinimumDimensions(Dimension dim, int row, int column) {
   TableColumn tableColumn = getColumnModel().getColumn(column);
   // this required extra margin padding is a mystery to me...
   dim.setSize(dim.width + getColumnMargin(), dim.height + getRowMargin());
   // potential bug: refresh() is needed to reduce size of unusually large temporary entries
   if (tableColumn.getWidth() < dim.width) {
     tableColumn.setMinWidth(dim.width);
     if (column == 0) {
       tableColumn.setMaxWidth(dim.width);
     }
   }
   if (getRowHeight(row) < dim.height) {
     setRowHeight(row, dim.height);
   }
 }