日期:2014-05-20 浏览次数:20719 次
import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; ;
------解决方案--------------------
我测试下来也没显示
import javax.swing.JFrame; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; public class Test { public static void main(String[] args) { JFrame jf = new JFrame(); Object[][] playerInfo = new Object[1][5]; String[] Names = { "ID", "地区", "学校代码", "学校名称", "详细地址" }; playerInfo[0][0]="1"; playerInfo[0][1]="2"; playerInfo[0][2]="3"; playerInfo[0][3]="4"; playerInfo[0][4]="5"; DefaultTableModel defaultModel = new DefaultTableModel(playerInfo,Names); JTable table = new JTable(defaultModel); TableColumnModel columnModel = table.getColumnModel(); TableColumn column = columnModel.getColumn(0); jf.add(table); jf.setVisible(true); column.setMinWidth(0); column.setMaxWidth(0); column.setWidth(0); column.setPreferredWidth(0); System.out.println(table.getModel().getValueAt(0, 0)); } }