这是我的代码:
public LMSPanel() {
setLayout(new GridLayout(3,3,10,10));
grid = new JLabel [10];
int k = 1;
while (k <= 9) {
grid[k] = new JLabel("", JLabel.LEFT);
grid[k].setText("");
grid[k].setForeground(Color.BLACK);
grid[k].setBackground(Color.GRAY);
grid[k].setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
add(grid[k]);
k++;
}
}
public void setHolding(Holding holding, int count2) {
holdingCode = holding.getCode();
if (holdingCode < 2000000) {
lastBookCode = holdingCode;
grid[count2].setForeground(Color.BLACK);
grid[count2].setBackground(Color.GRAY);
grid[count2].setBorder(BorderFactory.createLineBorder(Color.BLUE,10));
grid[count2].setLayout(new GridLayout(4,1,5,5));
JLabel text1 = new JLabel();
JLabel text2 = new JLabel();
JLabel text3 = new JLabel();
JLabel text4 = new JLabel();
text1.setText(" Holding Code: " + holding.getCode());
text2.setText(" Book Title: " + holding.getTitle());
text3.setText(" Standard Loan Fee: " + holding.getDefaultLoanFee());
text4.setText(" Loan Period" + holding.getMaxLoanPeriod());
grid[count2].add(text1);
grid[count2].add(text2);
grid[count2].add(text3);
grid[count2].add(text4);
} else if ...
}
}
我需要阻止此代码复制内部网格内容,我需要为超大内容添加水平滚动操作,但无法弄清楚如何操作。
这是一个截图:http://phuket.qsischool.org/downloads/DavesTempFolder/downloads.jpg
有什么想法吗? 大卫。