package Common.Visual.Tables;
import Common.MainModule_;
import Common.Visual.Fonts.VisualiserFonts;

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
public class RendererWrapText extends JTextArea implements TableCellRenderer {
    public RendererWrapText() {
        setLineWrap(true);
        setWrapStyleWord(true);
        // setOpaque(false);
        setFont(MainModule_.instance.getUI().getTheme().Fonts.get(VisualiserFonts.Distribution).deriveFont(14.0f));
    }
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
        setText((value == null) ? "" : value.toString());
        setSize(table.getColumnModel().getColumn(column).getWidth(),
                getPreferredSize().height);
        if (table.getRowHeight(row) != getPreferredSize().height) {
            table.setRowHeight(row, getPreferredSize().height);
        }
        return this;
    }
}
