zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    奇异值分解(SVD)与在降维中的应用
    拉格朗日乘子法&KKT条件
    有监督学习、无监督学习、半监督学习
    LSTM学习—Long Short Term Memory networks
    Ubuntu16.04+CUDA8.0+cuDNN5.1+Python2.7+TensorFlow1.2.0环境搭建
    激活函数
    C基础学习笔记
    Hive
    Fragment跳转至Activity片段随笔
    冒泡排序和选择排序
  • 原文地址:https://www.cnblogs.com/borter/p/9596177.html
Copyright © 2011-2022 走看看