private String[] columnNames=
private Object[][] rowData=new Object[0][4]
private DefaultTableModel tableModel=new DefaultTableModel(rowData,columnNames)
private JTable jTable=new JTable(tableModel)
//设置居中
DefaultTableCellRenderer r = new DefaultTableCellRenderer()
r.setHorizontalAlignment(JLabel.CENTER)
jTable.setDefaultRenderer(Object.class, r)
在netbeans调试运行过啦,改动如下:(1)最后一句jp7.add(jtable)改成jp0.add(jsp)
(2)你这里JTable jtable = new JTable(new String[][] {
{"哈","飞","飞","飞","我"," 的","爱情"},{"哈","飞","飞","飞","我"," 的","爱情"}
},
new String[] { "书名", "价格", "出版时间", "入库时间","作家","入库数","书类别" }
欠一半括号,我看不太懂,暂且改成JTable jtable = new JTable(new String[][] {
{"哈","飞","飞","飞","我"," 的","爱情"},{"哈","飞","飞","飞","我"," 的","爱情"}
},
new String[] { "书名", "价格", "出版时间", "入库时间","作家","入库数","书类别" })
(3)B ab = new B()应该加,ab.setVisible(true)
(4)这点只是建议.你里面大量使用的jPassordField可改用jTextField
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)