JTextPane抓取网页

来源:互联网 发布:慈溪行知职高论坛 编辑:程序博客网 时间:2024/06/04 17:43
public class JTextPaneDemo extends JFrame
{
  public JTextPaneDemo()
  {
     JTextPane tp=new JTextPane();
     
     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
     JScrollPane jsp=new JScrollPane(tp,v,h);
     
     Container cp=getContentPane();
     cp.add(jsp);
     setSize(400,300);
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     show();
     
     try
     {
       URL myurl = new URL("http://www.baidu.com");
       tp.setPage(myurl);
     }catch (Exception e)
     {
        e.printStackTrace();
     }
  }
 
  public static void main(String args[])
  {
     new JTextPaneDemo();    
  }

}



实验后发现
对js 支持 不好  很多网页打开有问题

原创粉丝点击