런타임 중에 CardLayout에 카드 (JPanels)를 추가하는 응용 프로그램을 작성하고 있습니다. 문제는 카드의 일부 구성 요소가 다른 구성 요소보다 빠르게로드되어 표시되기 전에 오류가 발생하여 제대로 렌더링되지 않는 것입니다.JPanel의 내용로드가 완료되었는지 여부를 확인하는 방법이 있습니까?
처음으로 표시 할 때 준비가 되길 원합니다.
스레드를 1500ms 동안 잠자기 상태로 만드는 로딩 화면에서 임시로 문제를 해결했습니다. 패널에있는 모든 항목이로드되었는지 알 수있는 더 훌륭한 방법이 있습니까?
private void showLoadingScreen() {
final Component glassPane = getGlassPane();
setGlassPane(loadingPanel);
loadingPanel.setVisible(true);
Thread thread = new Thread() {
public void run() {
try {;
Thread.sleep(1500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setGlassPane(glassPane);
}
};
thread.start();
}