Reputation: 105
I am writing a Java program that creates HTML code.
What's the best/easiest possibility to have a preview of the code?
JFrame
: How can I do this? Upvotes: 3
Views: 1728
Reputation: 81684
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:
Desktop.getDesktop().browse(new URI("file://myfile.html"));
Alternately, save the data in a file with the *.html
extension and use
Desktop.getDesktop().open(new File("myfile.html"));
Upvotes: 4