我已经动态地向网格视图添加了行。当行数超过屏幕上显示的行数时,其余内容将被隐藏。如何启用滚动以查看未显示行的其余部分?
JPanel billItemsPanel = new JPanel();
GridLayout billItemsLayout = new GridLayout(0,6);
billItemsLayout.setVgap(20);
billItemsPanel.setLayout(billItemsLayout);
billItemsPanel.add(new Label("Mobile Number"));
billItemsPanel.add(new TextField(20));
billItemsPanel.add(new Label(""));
billItemsPanel.add(new Label(""));
billItemsPanel.add(new Label(""));
billItemsPanel.add(new Label(""));
for(int i=0; i<10; i++){
billItemsPanel.add(new TextField("Hi SKU"));
billItemsPanel.add(new Label("Hi Title"));
billItemsPanel.add(new Label("Hi Type"));
billItemsPanel.add(new TextField("Hi Qty"));
billItemsPanel.add(new Label("Hi Price"));
billItemsPanel.add(new Label("Hi Amount"));
billItemsPanel.add(new TextField("Bye SKU"));
billItemsPanel.add(new Label("Bye Title"));
billItemsPanel.add(new Label("Bye Type"));
billItemsPanel.add(new TextField("Bye Qty"));
billItemsPanel.add(new Label("Bye Price"));
billItemsPanel.add(new Label("Bye Amount"));
}
用新的JScrollPane()包装