⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 taskmonitorhidestopoptionpanel.java

📁 一个用java写的地震分析软件(无源码)-used to write a seismic analysis software (without source)
💻 JAVA
字号:
package org.trinet.util.graphics.task;
import java.awt.*;
import java.beans.*;
import javax.swing.*; 

/**
  * Creates a task panel component containing a JOptionPane 
  * with  a "Stop" and an "Hide"  button. The "Stop" button
  * stops execution of a running task instance.
  * The "Hide" button disposes any enclosing dialog frame, but
  * a started task continues to run. 
  * The user must first start the task by invoking startTask()
  * which will make the component visible.
*/ 
public class TaskMonitorHideStopOptionPanel extends AbstractTaskMonitorOptionPanel {

    public TaskMonitorHideStopOptionPanel(AbstractMonitorableTask task) {
        super(task);
    }

/**
  * Task thread is controlled using JOptionPane  "Stop", options.
  * By default "Stop" option will stop task processing,
  * then dispose parent container if it is a dialog frame.
  * @see #addButtonControlPropertyChangeListener(PropertyChangeListener)
 */
    protected JOptionPane createOptionPane() {
        String [] stringOptions = { "Hide", "Stop"};
        final JOptionPane optionPane = 
            new JOptionPane( progressMeter,
                            JOptionPane.INFORMATION_MESSAGE,
                            JOptionPane.DEFAULT_OPTION,
                            null, stringOptions, stringOptions[0]);
        optionPane.addPropertyChangeListener(
            new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent e) {
                    String prop = e.getPropertyName();
                    if (isVisible() && (e.getSource() == optionPane)
                     && (prop.equals(JOptionPane.VALUE_PROPERTY) ||
                         prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
                        String value = (String) e.getNewValue();
                        if (value.equals("Stop")) {
                            stopTask();
                        }
                        else if (value.equals("Hide")) {
                            disposeDialog();
                        }
                        else {
                            System.out.println("Option UNKNOWN: " + value);
                        }
                    }
                }
        });
        return optionPane;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -