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

📄 guiutils.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                    "Error in EDT thread execution: " +                                     e.getMessage(), e);                         }                     });                 }                 return null;             }         };         worker.start();     }        /**     * Runs the specified runnable in the EDT using      * <code>SwingUtilities.invokeLater(...)</code>.     *     * @param runnable - the runnable to be executed     */    public static void invokeLater(Runnable runnable) {        if (!SwingUtilities.isEventDispatchThread()) {            SwingUtilities.invokeLater(runnable);        } else {            runnable.run();        }    }    /**     * Runs the specified runnable in the EDT using      * <code>SwingUtilities.invokeAndWait(...)</code>.     * Note: This method 'supresses' the method's      * thrown exceptions - InvocationTargetException and     * InterruptedException.     *     * @param runnable - the runnable to be executed     */    public static void invokeAndWait(Runnable runnable) {        if (!SwingUtilities.isEventDispatchThread()) {            try {                //System.err.println("Not EDT");                SwingUtilities.invokeAndWait(runnable);            }            catch (InterruptedException e) {}            catch (InvocationTargetException e) {}        } else {            runnable.run();        }    }    /**      * Sets the application cursor to the system wait cursor on     * the specified component.     *     * @param component - the component to set the cursor onto     */    public static void showWaitCursor(Component component) {        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR), component);    }    // -------------------------------------------------------    // ------ Helper methods for various option dialogs ------    // -------------------------------------------------------        // These have been revised to use JDialog as the wrapper to    // ensure the dialog is centered within the dektop pane and not    // within the entire screen as you get with JOptionPane.showXXX()        public static final void displayInformationMessage(Component parent, String message) {        displayDialog(parent,                      JOptionPane.DEFAULT_OPTION,                       JOptionPane.INFORMATION_MESSAGE,                       false,                      "OptionPane.informationIcon",                       "Message",                       message);    }        public static final String displayInputMessage(Component parent, String title, String message) {        return displayDialog(parent,                             JOptionPane.OK_CANCEL_OPTION,                              JOptionPane.QUESTION_MESSAGE,                              true,                             "OptionPane.questionIcon",                              title,                              message).toString();    }        public static final void displayWarningMessage(Component parent, String message) {        displayDialog(parent,                      JOptionPane.DEFAULT_OPTION,                       JOptionPane.WARNING_MESSAGE,                       false,                      "OptionPane.warningIcon",                       "Warning",                       message);    }        /** The dialog return value - where applicable */    private static Object dialogReturnValue;        private static Object displayDialog(final Component parent,                                         final int optionType,                                         final int messageType,                                        final boolean wantsInput,                                         final String icon,                                        final String title,                                         final String message) {                dialogReturnValue = null;        Runnable runnable = new Runnable() {            public void run() {                showNormalCursor(parent);                JOptionPane pane = new JOptionPane(message, messageType,                                            optionType, UIManager.getIcon(icon));                pane.setWantsInput(wantsInput);                JDialog dialog = pane.createDialog(parent, title);                dialog.setLocation(getLocationForDialog(parent, dialog.getSize()));                dialog.setVisible(true);                dialog.dispose();                if (wantsInput) {                    dialogReturnValue = pane.getInputValue();                } else {                    dialogReturnValue = pane.getValue();                }                            }        };        invokeAndWait(runnable);        return dialogReturnValue;                /*        showNormalCursor(parent);        JOptionPane pane = new JOptionPane(message, messageType,                                    optionType, UIManager.getIcon(icon));        pane.setWantsInput(wantsInput);                JDialog dialog = pane.createDialog(parent, title);        dialog.setLocation(getLocationForDialog(parent, dialog.getSize()));        dialog.setVisible(true);        dialog.dispose();        if (wantsInput) {            return pane.getInputValue();        } else {            return pane.getValue();        }        */    }        public static final void displayErrorMessage(Component parent, String message) {        displayDialog(parent,                      JOptionPane.DEFAULT_OPTION,                       JOptionPane.ERROR_MESSAGE,                      false,                       "OptionPane.errorIcon",                      "Error Message",                       message);    }    public static final int displayConfirmCancelErrorMessage(Component parent, String message) {        return ((Integer)displayDialog(                             parent,                             JOptionPane.OK_CANCEL_OPTION,                             JOptionPane.ERROR_MESSAGE,                             false,                              "OptionPane.errorIcon",                             "Error Message",                              message)).intValue();    }    public static final int displayYesNoDialog(Component parent, String message, String title) {        return ((Integer)displayDialog(parent,                                       JOptionPane.YES_NO_OPTION,                                       JOptionPane.QUESTION_MESSAGE,                                        false,                                       "OptionPane.questionIcon",                                        title,                                        message)).intValue();    }        public static final int displayConfirmCancelDialog(Component parent, String message) {        return ((Integer)displayDialog(parent,                                       JOptionPane.YES_NO_CANCEL_OPTION,                                       JOptionPane.QUESTION_MESSAGE,                                        false,                                       "OptionPane.questionIcon",                                        "Confirmation",                                        message)).intValue();    }        public static final int displayConfirmDialog(Component parent, String message) {        return ((Integer)displayDialog(parent,                                       JOptionPane.YES_NO_OPTION,                                       JOptionPane.WARNING_MESSAGE,                                        false,                                       "OptionPane.questionIcon",                                        "Confirmation",                                        message)).intValue();    }        /**      * Schedules the garbage collector to run      */    public static void scheduleGC() {        SwingUtilities.invokeLater(new Runnable() {            public void run() {                System.gc();            }        });    }    /**     * Returns whether the current applied look and feel is     * the EQ default look and feel (or the metal look with ocean theme).     *     * @return true | false     */    public static boolean isDefaultLookAndFeel() {        return UIUtils.isDefaultLookAndFeel() ||                UIUtils.usingOcean();    }    /**     * Returns true if we're using the Ocean Theme under the     * MetalLookAndFeel.     */    public static boolean usingOcean() {        return UIUtils.usingOcean();    }    /**     * Returns whether the current applied look and feel is     * the MetalLookAndFeel;     *     * @return true | false     */    public static boolean isMetalLookAndFeel() {        return UIUtils.isMetalLookAndFeel();    }        }

⌨️ 快捷键说明

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