film2000
CJSDN高级会员
发贴: 57
积分: 50
|
于 2003-04-28 09:24
其实table即使可编辑也可以选中一行.
import javax.swing.*;
public class Test { public static void main(String[] args) { JFrame f = new JFrame(); JTable table = new JTable(new NoEditableModel(new String[]{"a","b","c",},10)); //JTable table = new JTable(new String[10][3],new String[]{"a","b","c",}); f.getContentPane().add(new JScrollPane(table)); table.getSelectionModel().setSelectionInterval(0,0); f.setSize(300,400); f.show(); } }
class NoEditableModel extends javax.swing.table.DefaultTableModel { public boolean isCellEditable(int row, int column) { return false; }
public NoEditableModel(Object[] columns,int row) { super(columns,row); } }
|