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

📄 helpframe.java

📁 这是一个用java编写的发音电子词典
💻 JAVA
字号:
/* * HelpFrame.java * * Created on 2007年12月17日, 下午12:04 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */package 电子词典;import java.awt.*;import java.net.*;import java.awt.event.*;import javax.swing.*;import javax.swing.text.*;import javax.swing.event.*;import java.io.*;/** * * @author baili */public class HelpFrame extends JFrame{        /** Creates a new instance of HelpFrame */    //Internal    public HelpFrame()     {//        super("Help",true,true,true,true);        super("Help");        setBounds(120, 50, 355, 340);        HtmlPane html=new HtmlPane();        this.setContentPane(html);        //setVisible(true);    }    }class HtmlPane extends JScrollPane implements HyperlinkListener{    JEditorPane html;    public HtmlPane()    {        try        {            File f=new File("F:/java/JavaApplication1/六类最佳水果蔬菜榜___51766_com.htm");            String s=f.getPath();                        s="file:"+s;            System.out.println(s);            URL url=new URL(s);            html=new JEditorPane(s);            html.setEditable(false);            html.addHyperlinkListener(this);            JViewport vp=this.getViewport();            vp.add(html);        }        catch(MalformedURLException e)        {            System.out.println("Malformed URL:"+e);        }        catch(IOException e)        {            System.out.println("IOException:"+e);        }    }    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));    }    class PageLoader implements Runnable    {        URL url;        Cursor cursor;        PageLoader(URL u,Cursor c)        {            url=u;            cursor=c;        }        public void run()        {            if(url==null)            {                html.setCursor(cursor);                Container parent=html.getParent();                parent.repaint();            }            else             {                Document doc=html.getDocument();                try                {                    html.setPage(url);                }                catch(IOException ioe)                {                    html.setDocument(doc);                    getToolkit().beep();                }                finally                {                    url=null;                    SwingUtilities.invokeLater(this);                }                            }        }    }}

⌨️ 快捷键说明

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