我想調整在TabPanel視圖中scrollPanels中的兩個JTable。我設法將幀的大小設置爲12000,5000,但Jtable/scrollPanel不玩球。調整一個Jtable來填充JFrame,並仍然滾動
我發現一些代碼來設置表的是工作,但不是填充的JFrame它只是在表的底部增加了一個滾動條列的尺寸/ scrollPanel
誰能拿出一個如何讓表格填充框架並仍然滾動?
的表文件是:
public class ViewInTablePET extends JPanel {
private String[][] rowData = new String[0][];
private String columnNames[] = {"Shop", "Type", "price", "dateAcquired", "notes"};
private DefaultTableModel tableMod = new DefaultTableModel(rowData, columnNames);
private JTable table = new JTable(tableMod);
public ViewInTablePET() {
String bob;
String[] dan;
for (Integer i = 0; i < AppModel.getArrayListPet().size(); i++) {
bob = AppModel.getArrayListPet().get(i).toString();
dan = AppModel.getStringAsArray(bob, "\t");
tableMod.insertRow(i, new Object[]{dan[0], dan[1], dan[2], dan[3], dan[4]});
}
JScrollPane scrollPane = new JScrollPane(table);
this.add(scrollPane, BorderLayout.CENTER);
}
}
FRAM的文件是:
public class ViewInTabbs extends JFrame {
JLabel Average = new JLabel("Click a table row to get the average price");
public ViewInTabbs() {
JTabbedPane tabs = new JTabbedPane();
ViewInTablePetShope petShop = new ViewInTablePetShope();
ViewInTablePET pet = new ViewInTablePET();
tabs.add("Pet Shope", (JPanel) petShop);
tabs.add("Pets in the shop", (JPanel) pet);
this.setTitle("Tabb View of Data");
this.add(tabs, BorderLayout.CENTER);
this.setSize(12000, 5000);
this.setVisible(true);
this.add(Average, BorderLayout.SOUTH);
}
public void setAverage(String ave) {
this.Average.setText(ave);
}
}