import java
import java
import java
import javax
import javax
import javax
import javax
import javax
public class TableTip {
private JFrame jFrame;
private JTable jTable;
private JScrollPane jScrollPane;
private int row;
private int column;
/**
* @param args
*/
public static void main(String[] args) {
TableTip tableTip = new TableTip();
tableTip
}
private void show() {
jFrame = new JFrame();
jFrame
jFrame
final Object jtText[][] = { {
{
final String jtHead[] = {
TableModel dataModel = new AbstractTableModel() {
private static final long serialVersionUID =
public int getColumnCount() {
return jtHead
}
public int getRowCount() {
return jtText
}
public Object getValueAt(int rowIndex
return jtText[rowIndex][columnIndex];
}
public String getColumnName(int column) {
return jtHead[column];
}
public boolean isCellEditable(int row
return false;
}
public void setValueAt(Object aValue
jtText[row][column] = aValue;
}
};
jTable = new JTable(dataModel);
jTable
// 設置不能重新調整列寬
jTable
// 設置不能重新排序各列
jTable
// 監聽鼠標移動
jTable
@Override
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
Point point = e
int x = jTable
int y = lumnAtPoint(point);
if (x != row || y != column) {
row = x;
column = y;
}
Object tip = jTable
if (tip != null) {
jTable
}
}
});
jScrollPane = new JScrollPane(jTable);
jScrollPane
jFrame
jFrame
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26035.html