e806. 创建进程监听对话框
A common feature of a user interface is to show a progress dialog that visually displays the progress of a long-running task. The dialog automatically disappears when the task is done. The ProgressMonitor
class is a convenient dialog that implements a progress dialog.
The progress monitor contains a message which describes the long-running task. The message does not change for the duration of the task. The progress monitor also allows for a note which is a description of the current subtask. For example, if the task is copying a set of files, the note could be the name of the current file being copied.
Note: A progress monitor should not be reused. The properties that control when the dialog should appear are set when the monitor is constructed and cannot be reset.
See also e801 创建一个JProgressBar组件.
// This message describes the task that is running String message = "Description of Task"; // This string describes a subtask; set to null if not needed String note = "subtask"; // Set the title of the dialog if desired String title = "Task Title"; UIManager.put("ProgressMonitor.progressText", title); // Create a progress monitor dialog. // The dialog will use the supplied component's frame as the parent. int min = 0; int max = 100; ProgressMonitor pm = new ProgressMonitor(component, message, note, min, max);
As the task progresses, check to see if the task has been cancelled and if not, call setProgress()
and supply its current state.
// Check if the dialog has been cancelled boolean cancelled = pm.isCanceled(); if (cancelled) { // Stop task } else { // Set new state pm.setProgress(newValue); // Change the note if desired pm.setNote("New Note"); }
Related Examples |
相关文章
- mysql中kill掉所有锁表的进程
- GO系列(3)-协程 线程 进程 基础
- Linux进程是如何创建出来的?
- Windows 进程创建通知回调通知例程的学习笔记
- 【错误记录】前台进程报错 ( Bad notification for startForeground invalid channel for service notification )
- 如何使用cThreadHijack实现远程进程注入研究
- SQLServer 错误 17883 计划程序 %ld 的进程 %ld:%ld:%ld (0x%lx)工作线程 0x%p 似乎无法完成。 线程创建时间: %I64d。 线程占用 CPU 的近似时间: 内核 %I64d 毫秒,用户 %I64d 毫秒。 进程使用率 %d%%。 系统空闲率 %d%%。 间隔: %I64d 毫秒。 故障 处理 修复 支持远程
- sqlserver进程死锁关闭的方法
- Linux进程的类型及其功能研究(linux进程种类)
- Linux下创建一个进程的步骤(linux创建一个进程)
- Linux查看进程端口信息指南(linux查进程端口)
- 进程、线程和协程的区别详解编程语言
- 进程的创建和终止(超详细)
- Linux进程切换:开销详解(linux进程切换的开销)
- Linux下线程创建进程的方法研究(linux线程创建进程)
- Linux进程:如何创建和管理(linux进程创建)
- Linux C程序中创建进程的方法(linuxc创建进程)
- 暂停Linux线程:停止进程的重要手段(线程暂停linux)
- Linux系统下如何创建子进程(linux创建子进程)
- Linux进程:启动参数优化指南(linux进程启动参数)
- Linux下快速创建实时进程的方法研究(linux创建实时进程)
- Linux如何强制结束进程:实用技巧分享(linux强制结束进程)
- Linux下如何创建进程并使用线程?(linux进程创建线程)
- 轻松学会Linux多进程管理(linux创建多个进程)
- 如何在Linux上启动一个进程(linux启动一个进程)
- Linux下开启进程的一种实现方式(开启进程命令linux)
- Linux如何快速杀死某个进程(linux杀死某个进程)
- 新建Redis服务进程,大幅度提升性能(创建redis服务进程)
- 如何利用多进程优化Redis性能(多进程处理redis)
- SQLserver2000企业版出现"进程51发生了严重的异常"错误的处理方法
- Node.js中创建和管理外部进程详解