【问题标题】:Display wait cursor when 'Next' clicked - Netbeans WizardDescriptor单击“下一步”时显示等待光标 - Netbeans WizardDescriptor
【发布时间】:2016-07-27 12:03:42
【问题描述】:

我有一个带有几个 PanelDescriptor 的向导迭代器。 当在一个实现 WizardDescriptor.ValidatingPanel 的 PanelDescriptor 上单击“下一步”时,我试图显示等待光标。其中的 validate() 方法需要时间执行。

到目前为止,我尝试了几种方法,但没有一个对我有用。

  1. http://dev.platform.netbeans.narkive.com/ofiffInN/finally-a-waitcursor-routine-that-works-in-netbeans
  2. http://netbeans-org.1045718.n5.nabble.com/Setting-wait-cursor-td3026613.html#a3026614

    private static void changeCursorWaitStatus(final boolean isWaiting) {
        Mutex.EVENT.writeAccess(new Runnable() {
            public void run() {
                try {
                    JFrame mainFrame = (JFrame) WindowManager.getDefault().getMainWindow();
                    Component glassPane = mainFrame.getGlassPane();
                    if (isWaiting) {
                        glassPane.setVisible(true);
                        glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    } else {
                        glassPane.setVisible(false);
                        glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    }
                } catch (Exception e) {
                    // probably not worth handling 
                }
            }
        });
    }
    
  3. https://community.oracle.com/message/5322657#5322657

    try {            
        TopComponent.getRegistry().getActivated().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        doBusyStuff();
    } finally {
        TopComponent.getRegistry().getActivated().setCursor(Cursor.getDefaultCursor());
    }
    

任何能指出我正确方向的提示都将不胜感激。

【问题讨论】:

    标签: java swing cursor netbeans-platform glasspane


    【解决方案1】:

    试试这个

        private static final java.awt.event.MouseAdapter mouseAdapter = new java.awt.event.MouseAdapter() {
    
        };
    
        protected static final Cursor READY_CSR = new Cursor(Cursor.DEFAULT_CURSOR);
        protected static final Cursor WAIT_CSR  = new Cursor(Cursor.WAIT_CURSOR);
    
        public void setBusy(boolean busy) {
    
            if(busy) {
                setCursor(WAIT_CSR);
                frame.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                frame.getGlassPane().addMouseListener(mouseAdapter);
                frame.getGlassPane().setVisible(true);
            }else {
                setCursor(READY_CSR);
                frame.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                frame.getGlassPane().removeMouseListener(mouseAdapter);
                frame.getGlassPane().setVisible(false);
            }
        }
    

    【讨论】:

    • First link 包含这样的解决方案,它在我的情况下不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-15
    • 2011-01-08
    • 2013-10-23
    • 1970-01-01
    • 1970-01-01
    • 2013-07-10
    相关资源
    最近更新 更多