Java Swing:模态加载屏幕?

问题描述:

我有一个加载网页的 Java swing 应用程序.有时,网页需要一段时间才能加载,具体取决于用户的互联网连接.

I have a Java swing application which loads a web page. Sometimes, the web page takes a while to load depending on the user's internet connection.

我想阻止这个框架直到页面加载完毕.

I want to block this frame until page has loaded.

最简单的选择就是弹出一个模态对话框:

The simplest option is to pop up a modal dialog:

JDialog modalDialog = new JDialog(frame, "Busy", ModalityType.DOCUMENT_MODAL);
modalDialog.setSize(200, 150);
modalDialog.setLocationRelativeTo(frame);
modalDialog.setVisible(true);

您可能想在其中放置一个进度条.

You may want to put a progress bar in it.