How do you open web pages in Java?

后端 未结 6 1495
庸人自扰
庸人自扰 2021-02-13 04:19

Is there a simple way to open a web page within a GUI\'s JPanel?

If not, how do you open a web page with the computer\'s default web browser?

I am hoping for so

6条回答
  •  遥遥无期
    2021-02-13 04:43

    Opening a web page with the default web browser is easy:

    java.awt.Desktop.getDesktop().browse(theURI);
    

    Embedding a browser is not so easy. JEditorPane has some HTML ability (if I remember my limited Swing-knowledge correctly), but it's very limited and not suiteable for a general-purpose browser.

提交回复
热议问题