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

📄 abstractguiapplication.java~1~

📁 具有不同语法高亮的编辑器实例
💻 JAVA~1~
📖 第 1 页 / 共 3 页
字号:
   * application.  This is used by <code>getResourceBundle</code> to locate
   * the class.
   *
   * @return The fully-qualified class name of the resource bundle.
   * @see #getResourceBundle
   */
  public abstract String getResourceBundleClassName();

      /*****************************************************************************/

  /**
   * Returns the status bar this application is using.
   *
   * @return The status bar.
   * @see #setStatusBar
   */
  public StatusBar getStatusBar() {
    return statusBar;
  }

      /*****************************************************************************/

  /**
   * Returns whether the status bar is visible.
   *
   * @return Whether the status bar is visible.  If this application does not
   *         have a status bar, <code>null</code> is returned.
   * @see #setStatusBarVisible
   */
  public boolean getStatusBarVisible() {
    return statusBar != null ? statusBar.isVisible() : false;
  }

      /*****************************************************************************/

  /**
   * Returns the toolbar this application is using.
   *
   * @return The toolbar.
   * @see #setToolBar
   */
  public CustomizableToolBar getToolBar() {
    return toolBar;
  }

      /*****************************************************************************/

  /**
   * Returns whether the toolbar is visible in this application.
   *
   * @return Whether the toolbar is visible.  If this application has no
   *         toolbar, <code>false</code> is returned.
   * @see #setToolBarVisible
   */
  public boolean getToolBarVisible() {
    return toolBar != null ? toolBar.isVisible() : false;
  }

      /*****************************************************************************/

  /**
   * Returns the version string for this application.
   *
   * @return The version string.
   */
  public abstract String getVersionString();

      /*****************************************************************************/

  /**
   * Returns true if this application's main window is maximized.
   *
   * @return <code>true</code> if this applicaiton's window is maximized,
   *         or <code>false</code> if it isn't.
   */
  public boolean isMaximized() {
    return getExtendedState() == MAXIMIZED_BOTH;
  }

      /*****************************************************************************/

  /**
   * Loads the preferences for this GUI application.  If this application
   * does not use preferences or something, <code>null</code> is
   * goes wrong, <code>null</code> is returned.
   *
   * @return This application's preferences.
   */
  public GUIApplicationPreferences loadPreferences() {
    GUIApplicationPreferences prefs = null;
    String prefsClassName = getPreferencesClassName();
    if (prefsClassName != null) {
      try {
        Class prefsClass = Class.forName(prefsClassName);
        Class[] nullClass = null; // Stops JDK 1.5 varargs warnings.
        Method method = prefsClass.getMethod("loadPreferences",
                                             nullClass);
        prefs = (GUIApplicationPreferences) method.invoke(
            prefsClass, nullClass);
      }
      catch (Exception e) {
        displayException(e);
      }
    }
    return prefs;
  }

      /*****************************************************************************/

  /**
   * Gets called from the OSXAdapter; this method is needed by the Mac OS X
   * JVM.  This is a hook for the standard Apple application menu.  This
   * method gets called when we receive an open event from the finder on
   * Mac OS X, and should be overridden to do whatever makes sense in your
   * application to "open a file."
   */
  public abstract void openFile(final String fileName);

      /*****************************************************************************/

  /**
   * 1.5.2004/pwy: Generic registration with the Mac OS X application menu.
   * Checks the platform, then attempts to register with the Apple EAWT.
   * This method calls OSXAdapter.registerMacOSXApplication() and
   * OSXAdapter.enablePrefs().
   * See OSXAdapter.java for the signatures of these methods.
   */
  private void possibleMacOSXRegistration() {

    if (getOS() == OS_MAC_OSX) {

      try {
        Class osxAdapter = Class.forName(
            "com.apple.osxadapter.OSXAdapter");

        Class[] defArgs = {
            this.getClass()};
        Method registerMethod = osxAdapter.getDeclaredMethod(
            "registerMacOSXApplication", defArgs);
        if (registerMethod != null) {
          Object[] args = {
              this};
          registerMethod.invoke(osxAdapter, args);
        }
        // This is slightly gross.  to reflectively access methods
        // with boolean args, use "boolean.class", then pass a
        // Boolean object in as the arg, which apparently gets
        // converted for you by the reflection system.
        defArgs[0] = boolean.class;
        Method prefsEnableMethod = osxAdapter.getDeclaredMethod(
            "enablePrefs", defArgs);
        if (prefsEnableMethod != null) {
          Object args[] = {
              Boolean.TRUE};
          prefsEnableMethod.invoke(osxAdapter, args);
        }
      }
      catch (NoClassDefFoundError e) {
        // This will be thrown first if the OSXAdapter is loaded on
        // a system without the EAWT because OSXAdapter extends
        // ApplicationAdapter in its def
        displayException(e);
      }
      catch (ClassNotFoundException e) {
        // This shouldn't be reached; if there's a problem with the
        // OSXAdapter we should get the above NoClassDefFoundError
        // first.
        displayException(e);
      }
      catch (Exception e) {
        displayException(e);
      }

    } // End of if (getOS()==OS_MAC_OSX).

  }

      /*****************************************************************************/

  /**
   * Gets called from the OSXAdapter; this method is needed by the Mac OS X
   * JVM.  This is a hook for the standard Apple application menu.  This
   * method should be overridden to show the Options dialog.
   */
  public abstract void preferences();

      /*****************************************************************************/

  /**
   * This is called in the GUI application's constructor.  It is a chance
   * for subclasses to do initialization of stuff that will be needed
   * by the class before the appliction is displayed on-screen.
   *
   * @param prefs The preferences of the application.
   * @param splashScreen The "splash screen" for this application.  This
   *                            value may be <code>null</code>.
   */
  public abstract void preDisplayInit(GUIApplicationPreferences prefs,
                                      SplashScreen splashScreen);

      /*****************************************************************************/

  /**
   * This is called in the GUI application's constructor.  It is a chance
   * for subclasses to do initialization of stuff that will be needed by
   * their menu bar before it gets created.
   *
   * @param prefs The preferences of the application.
   * @param splashScreen The "splash screen" for this application.  This
   *                            value may be <code>null</code>.
   */
  protected abstract void preMenuBarInit(GUIApplicationPreferences prefs,
                                         SplashScreen splashScreen);

      /*****************************************************************************/

  /**
   * This is called in the GUI application's constructor.  It is a chance
   * for subclasses to do initialization of stuff that will be needed by
   * their status bar before it gets created.
   *
   * @param prefs The preferences of the application.
   * @param splashScreen The "splash screen" for this application.  This
   *                            value may be <code>null</code>.
   */
  protected abstract void preStatusBarInit(GUIApplicationPreferences prefs,
                                           SplashScreen splashScreen);

      /*****************************************************************************/

  /**
   * This is called in the GUI application's constructor.  It is a chance
   * for subclasses to do initialization of stuff that will be needed by
   * their toolbar before it gets created.
   *
   * @param prefs The preferences of the application.
   * @param splashScreen The "splash screen" for this application.  This
   *                            value may be <code>null</code>.
   */
  protected abstract void preToolBarInit(GUIApplicationPreferences prefs,
                                         SplashScreen splashScreen);

      /*****************************************************************************/

  /**
   * Called when a window event occurs for this application.
   *
   * @param e The window event.
   */
  protected void processWindowEvent(WindowEvent e) {

    switch (e.getID()) {

      case WindowEvent.WINDOW_CLOSING:
        doExit(); // Closes the application cleanly.
        break;

      case WindowEvent.WINDOW_DEACTIVATED:

        // Make popup menus not stay up when the frame loses focus.
        // This "bug" is fixed in 1.5 JRE's.
        MenuSelectionManager.defaultManager().clearSelectedPath();
        break;

    }

    super.processWindowEvent(e);

  }

      /*****************************************************************************/

  /**
   * Gets called from the OSXAdapter; this method is needed by the Mac OS X
   * JVM.  This is a hook for the standard Apple application menu.  This
   * method calls <code>doExit</code>.
   *
   * @see #doExit()
   */
  public void quit() {
    doExit();
  }

      /*****************************************************************************/

  /**
   * This method sets the content pane.  It is overridden so it does not
   * meddle with the status bar, toolbar, etc.
   *
   * @param contentPane The new content pane.
   * @see #getContentPane
   */
  public void setContentPane(Container contentPane) {
    if (contentPane != null && !contentPane.equals(actualContentPane)) {
      if (actualContentPane != null) {
        mainContentPanel.remove(actualContentPane);
      }
      mainContentPanel.add(contentPane);
    }
  }

      /*****************************************************************************/

  /**
   * Sets the "install location" of this application.
   *
   * @param location The directory in which this application is installed.
   * @see #getInstallLocation
   */
  private void setInstallLocation(String location) {
    File temp = new File(location);
    if (temp.isDirectory()) {
      installLocation = temp.getAbsolutePath();
    }
    else {
      installLocation = System.getProperty("user.dir");
    }
  }

      /*****************************************************************************/

  /**
   * Sets the language for this GUI application and all of its dialogs,
   * UI widgets, etc.<p>
   *
   * @param language The language to use.  If <code>null</code>,
   *                 English will be used.
   */
  public void setLanguage(final String language) {
    this.language = language == null ? "en" : language;
  }

      /*****************************************************************************/

  /**
   * Sets the status bar to use in this application.  This method fires a
   * property change of type <code>STATUS_BAR_PROPERTY</code>.
   *
   * @param statusBar The status bar to use.
   * @see #getStatusBar
   */
  public void setStatusBar(StatusBar statusBar) {
    if (statusBar != null && !statusBar.equals(this.statusBar)) {
      StatusBar old = this.statusBar;
      if (old != null) {
        contentPane.remove(old);
      }
      this.statusBar = statusBar;
      contentPane.add(statusBar, STATUS_BAR_LOCATION);
      firePropertyChange(STATUS_BAR_PROPERTY, old, statusBar);
    }
  }

      /*****************************************************************************/

  /**
   * Sets whether the status bar is visible.  This method fires a property
   * change of type <code>STATUS_BAR_VISIBLE_PROPERTY</code>.
   *
   * @param visible Whether the status bar is to be visible.
   * @see #getStatusBarVisible
   */
  public void setStatusBarVisible(boolean visible) {
    if (statusBar != null && statusBar.isVisible() != visible) {
      statusBar.setVisible(visible);
      firePropertyChange(STATUS_BAR_VISIBLE_PROPERTY,
                         !visible, visible);
    }
  }

      /*****************************************************************************/

  /**
   * Sets the toolbar used by this GUI application.  This method fires a
   * property change of type <code>TOOL_BAR_PROPERTY</code>.
   *
   * @param toolBar The toolbar to use.
   * @see #getToolBar
   */
  public void setToolBar(CustomizableToolBar toolBar) {
    if (toolBar != null && !toolBar.equals(this.toolBar)) {
      CustomizableToolBar old = this.toolBar;
      if (old != null) {
        toolBarPanels[0].remove(old);
      }
      this.toolBar = toolBar;
      toolBarPanels[0].add(toolBar, TOOL_BAR_LOCATION);
      firePropertyChange(TOOL_BAR_PROPERTY, old, toolBar);
    }
  }

      /*****************************************************************************/

  /**
   * Sets whether the toolbar used by this GUI application is visible.
   * This method fires a property change of type
   * <code>TOOL_BAR_VISIBLE_PROPERTY</code>.
   *
   * @param visible Whether the toolbar should be visible.
   * @see #getToolBarVisible
   */
  public void setToolBarVisible(boolean visible) {
    if (toolBar != null && toolBar.isVisible() != visible) {
      toolBar.setVisible(visible);
      firePropertyChange(TOOL_BAR_VISIBLE_PROPERTY, !visible,
                         visible);
    }
  }

      /*****************************************************************************/

}

⌨️ 快捷键说明

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