Non-blocking modal Swing progress dialog

前端 未结 2 1588
梦如初夏
梦如初夏 2020-12-31 05:02

A daft question, but I really cannot get this to work: I have some long-running process in a Swing application which may take several minutes. I want to display a progress d

相关标签:
2条回答
  • 2020-12-31 05:38

    You must be doing something wrong. Try the tutorial on How to Use Progress Bars. If you can understand how that code works, it should give you the direction for achieving the required feature.

    Note that progress bars are usually modal.

    0 讨论(0)
  • 2020-12-31 05:44

    You should be using the GlassPane from preventing the user from interacting. The good thing is this is modal for the user and not your program so your thread won't get blocked.

    The great news is that you can also use it for cool GUI effects like shading the GUI portion busy and the user can't interact with. You can also display a busy gif image in the GlassPane.

    Links:-

    1. Official tutorial on GlassPane
    2. Some helpful tutorials
    3. Another tut
    4. Oreilly's Swing Hacks is excellent.
    0 讨论(0)
提交回复
热议问题