如何显示加载中

发布于 2024-12-05 02:32:03 字数 211 浏览 1 评论 0 原文

我想知道如何显示应用程序的加载。通常(假设 Netbeans IDE) 该应用程序将显示其已加载的程度以及要加载的程度。此外,还可以在欢迎页面中看到加载类。这是如何完成的以及我们如何在应用程序中显示类加载和加载状态(在进度栏中)?另外,假设我们已经使用了 Hibernate,并且首页上有一个登录,启动需要时间,但只是启动(我认为这是因为 Hibernate 工厂正在启动并加载其类)。答案寄希望于Java。

I want to know how to show the loading of an application. Normally (let's say Netbeans IDE,)
the application will show how far it has loaded and how far to load. Also, loading classes as well can be seen in welcome page. How is this is done and how we can show our classes loading and loaded status (in a progress bar) in our applications? Also let's say that we have used Hibernate, and there is a login on first page, it takes time to start but only for the starting (I think it is because that the Hibernate factory is getting started and load its classes). The answer is hoped in Java.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

智商已欠费 2024-12-12 02:32:03

我想知道如何显示应用程序的加载情况。

请参阅 java.awt.SplashScreen 类。但是..

带有进度条的启动栏

..显示它已加载多远以及要加载多远。

..带有定制图像。调用 SplashScreen.createGraphics() 获取可以在其上绘制的 Graphics 对象(来自清单中定义为启动画面的图像)。在 Graphics 对象上的适当位置绘制进度条。对于进度条,可以使用前面提到的 JProgressBar,或者为了保持简洁(使用纯 AWT),绘制一个大的 矩形 来表示进度条,并填充较小的矩形来表示进度。

另请参阅 Java 教程中的如何创建启动屏幕 。 (您可以在上面看到该图片。)

I want to know how to show the loading of an application.

See the java.awt.SplashScreen class. But..

Splash with progress bar

..show how far it has loaded and how far to load.

..with a customized image. Call SplashScreen.createGraphics() to get a Graphics object (from the image defined as a splash in the manifest) which can be drawn on. Draw the progress bar at an appropriate location on the Graphics object. For the progress bar, either use a JProgressBar as already mentioned, or to keep it lean (using pure AWT), draw one big Rectangle to represent the bar, and fill a smaller Rectangle to represent the progress.

See also How to Create a Splash Screen in the Java Tutorial. (Where you can see that image above.)

度的依靠╰つ 2024-12-12 02:32:03

这听起来适合使用 JProgressBar ,结合 启动屏幕JDialog

确保必须在 事件上更新 JProgressBar调度线程,更多关于并发性Swing

那么您有两种选择如何正确更新 JProgressBar - 将代码包装到:

That sounds for using JProgressBar, combined with Splash Screen or JDialog.

Be sure that JProgressBar must be updated on the Event Dispatch Thread, more about that in Concurrency in Swing,

Then you have two choices as to how to update a JProgressBar correctly - by wrapping code into:

云醉月微眠 2024-12-12 02:32:03

swing 中为此内置了一些支持。请参阅有关如何使用进度条的教程来开始使用。

There is some support built into swing for this. See the tutorial on How to Use Progress Bars to get started.

情泪▽动烟 2024-12-12 02:32:03

这是一个非常基本的代码:

JProgressBar progressBar;
progressBar = new JProgressBar(0, task.getLengthOfTask());
progressBar.setValue(33); // put here the percentage you want to display...
progressBar.setStringPainted(true);

Here is a very basic code:

JProgressBar progressBar;
progressBar = new JProgressBar(0, task.getLengthOfTask());
progressBar.setValue(33); // put here the percentage you want to display...
progressBar.setStringPainted(true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文