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

📄 helpframe.java

📁 八数码拼图程序源码,可以实现初始8个数码顺序到目标8个数码顺序的自动拼图
💻 JAVA
字号:
package com.will.eightnums;

import java.io.*;
import java.net.*;

import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author Will Wang
 * @version 1.0
 */

public class HelpFrame
    extends JInternalFrame {

  public HelpFrame() {
    super("Help", true, true, true, true);
    setBounds(200, 25, 400, 400);
    HtmlPane html = new HtmlPane();
    setContentPane(html);
  }

}

class HtmlPane
    extends JScrollPane implements HyperlinkListener {
  JEditorPane html;

  public HtmlPane() {
    try {
      File f = new File("help.html");
      String s = f.getAbsolutePath();
      s = "file:" + s;
      URL url = new URL(s);
      html = new JEditorPane(s);
      html.setEditable(false);
      html.addHyperlinkListener(this);

      JViewport vp = getViewport();
      vp.add(html);
    }
    catch (MalformedURLException e) {
      System.out.println("Malformed URL: " + e);
    }
    catch (IOException e) {
      System.out.println("IOException: " + e);
    }
  }

  /**
   * Notification of a change relative to a
   * hyperlink.
   */
  public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      linkActivated(e.getURL());
    }
  }

  protected void linkActivated(URL u) {
    Cursor c = html.getCursor();
    Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
    html.setCursor(waitCursor);
    SwingUtilities.invokeLater(new PageLoader(u, c));
  }

  /**
   * temporary class that loads synchronously (although
   * later than the request so that a cursor change
   * can be done).
   */
  class PageLoader
      implements Runnable {

    PageLoader(URL u, Cursor c) {
      url = u;
      cursor = c;
    }

    public void run() {
      if (url == null) {
        // restore the original cursor
        html.setCursor(cursor);

        // PENDING(prinz) remove this hack when
        // automatic validation is activated.
        Container parent = html.getParent();
        parent.repaint();
      }
      else {
        Document doc = html.getDocument();
        try {
          html.setPage(url);
        }
        catch (IOException ioe) {
          html.setDocument(doc);
          getToolkit().beep();
        }
        finally {
          // schedule the cursor to revert after
          // the paint has happended.
          url = null;
          SwingUtilities.invokeLater(this);
        }
      }
    }

    URL url;
    Cursor cursor;
  }

}

⌨️ 快捷键说明

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