首页 > 解决方案 > 如何使用 Java Swing 绘制完整的网页?

问题描述

我试图在 Java Swing 中绘制一个完整的网页,但它看起来很糟糕。它需要在 Chrome 或其他浏览器中看起来像什么?

它看起来像这样:

不像 youtube 上的普通视频。
资源:

    JEditorPane jep = new JEditorPane();
    jep.setEditable(false);   

    try {
      jep.setPage("https://www.youtube.com/watch?v=EcdbEax46bA");
    }catch (IOException e) {
      jep.setContentType("text/html");
      jep.setText("<html>Could not load</html>");
    } 

    JScrollPane scrollPane = new JScrollPane(jep);     
    JFrame f = new JFrame("Test HTML");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(scrollPane);
    f.setPreferredSize(new Dimension(800,600));
    f.setVisible(true);

那么我需要什么才能查看完整的网页?

标签: javahtmlswingwebpagejeditorpane

解决方案


推荐阅读