【发布时间】:2017-02-24 05:03:42
【问题描述】:
我编写了一个创建空 JTable 的简单程序。但是当我显示表格时,表格下方会出现一个额外的空白。现在我想删除表格行下方的空白。
JTable 程序:
public class Table extends JFrame {
Table()
{
int numColoumns=5;
int numRows=10 ;
String[] colHeadings = {"COLUMN1","COLUMN2","COLUMN3","COLUMN4","COLUMN5"};
DefaultTableModel model = new DefaultTableModel(numRows, numColoumns) ;
model.setColumnIdentifiers(colHeadings);
JTable table = new JTable(model);
JTableHeader head = table.getTableHeader();
Container c = getContentPane();
c.setLayout(new BorderLayout());
c.add("North", head);
c.add("Center",table);
}
public static void main(String[] args) throws NumberFormatException, IOException
{
Table t = new Table();
t.setSize(500,400);
t.setVisible(true);
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}}
程序给了我一个表格,但是行没有完全填满窗口。它显示了一个窗口,具有以像素为单位的给定高度和宽度以及相应的行数。在创建的行下方,它显示了一个额外的空间,因为行没有填充到窗口中。任何人都可以帮我从窗口中删除多余的空间。
抱歉,我创建了输出图像,但上传图像时出现问题。
【问题讨论】:
标签: java swing jtable jscrollpane