Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

public class Main {
    public static void main(String[] argv) throws Exception {

        JTable table = new JTable();
        int vColIndex = 0;
        TableColumn col = table.getColumnModel().getColumn(vColIndex);
        col.setHeaderRenderer(new MyTableHeaderRenderer());

    }
}

class MyTableHeaderRenderer extends JLabel implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
            int rowIndex, int vColIndex) {
        setText(value.toString());
        setToolTipText((String) value);
        return this;
    }

}