JScrollPane無法正常工作。我在裏面創建了一個面板,我添加了JForm Layout。然後我添加標籤和一個動態面板添加JScrollPane,我在其中添加表。JScrollPane無法正常工作我用JForm Layout
問題是這個JScrollPane無法正常工作。它沒有顯示垂直和水平線條,它只是像表格數據一樣反映一個常量面板。
public LedgerPanel_UI() {
setLayout(new FormLayout(new ColumnSpec[] {
FormSpecs.RELATED_GAP_COLSPEC,
ColumnSpec.decode("244dlu"),
FormSpecs.RELATED_GAP_COLSPEC,
ColumnSpec.decode("250dlu"),},
new RowSpec[] {
FormSpecs.RELATED_GAP_ROWSPEC,
RowSpec.decode("20dlu"),
FormSpecs.RELATED_GAP_ROWSPEC,
RowSpec.decode("fill:207dlu"),
FormSpecs.RELATED_GAP_ROWSPEC,
RowSpec.decode("fill:179dlu"),}));
style = new Style();
TableModel_Ledgers model = new TableModel_Ledgers();
JTable table = new JTable(model);
model.setColumnSize(table);
style.style_Table(table, table.getTableHeader(), false);
//scrollPane.getViewport().setPreferredSize(this.getPreferredSize());
model.setData();
model.fireTableDataChanged();
JLabel lblNewLabel = new JLabel("Add New Customer");
JScrollPane scrollPane = new JScrollPane();
//scrollPane = style.style_JScrollPane(scrollPane, table);
scrollPane.setViewportView(table);
add(new AddNewLedgerAccountp_UI().init_UI(), "4, 4");
add(lblNewLabel, "4, 2, center, fill");
add(scrollPane, "2, 4, 1, 3, fill, fill");
}
爲了更快得到更好的幫助,請發佈[MCVE]或[簡短,獨立,正確的示例](http://www.sscce.org/)。 –