[英]Show HTML mark-up in JFrame or open Browser
I am writing a Java program that creates HTML code. 我正在编写一个创建HTML代码的Java程序。
What's the best/easiest possibility to have a preview of the code? 预览代码的最佳/最简单的可能性是什么?
JFrame
: How can I do this? JFrame
显示代码:我该怎么做? Both are quite easy to do. 两者都很容易做到。 Here is a page from the Java tutorial that shows how to display HTML in Swing (you'd use a
file:
URL to display the contents of a file.) You can display a URL in an external browser using Java 6's Desktop
class: 以下是Java教程中的一个页面,其中显示了如何在Swing中显示HTML(您使用
file:
URL来显示文件的内容。)您可以使用Java 6的Desktop
类在外部浏览器中显示URL:
Desktop.getDesktop().browse(new URI("file://myfile.html"));
Alternately, save the data in a file with the *.html
extension and use 或者,将数据保存在扩展名为
*.html
的文件中并使用
Desktop.getDesktop().open(new File("myfile.html"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.