我正在使用一个扩展 JPanel 的类 RefreshablePanel
public class RefreshablePanel extends JPanel {
static String description="";
protected void paintComponent(Graphics g){
g.drawString(description, 10, 11);
}
void updateDescription(String dataToAppend){
description = description.concat("\n").concat(dataToAppend);
}
}
JPanel descriptionPanel = new JPanel();
scrollPane_2.setViewportView(descriptionPanel);
descriptionPanel.setBackground(Color.WHITE);
descriptionPanel.setLayout(null);
现在当我这样做时
RefreshablePanel descriptionPanel = new RefreshablePanel();
scrollPane_2.setViewportView(descriptionPanel);
descriptionPanel.setBackground(Color.WHITE);
descriptionPanel.setLayout(null);