How to display a HTML file (in browser window) from Java Program...?
'ellos
So I'm making a Hangman game, and for the sake of completeness I want to have a HELP feature. When the Help button is clicked, a browser window should open up (not *within* the game frame... but just generally) and display the HTML Help file. How do I do this?
So I have a full GUI, with a HELP button (a JButton) with an added Action Listener defined as follows:
(this is actually an inner class within another GUI class)
HelpListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
//...insert code here, that will open up a browser window displaying a HTML help file (containing Hangman Help information)
}
}
Any help would be much appreciated. :idea:
apcxpc
Junior Poster in Training
55 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
Actually, to display either a HTML or text file in a browser window ...OR... just a text file in like Notepad or something.
apcxpc
Junior Poster in Training
55 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
You should be using a dialog box or a new frame ( as you like ) with a JEditorPane in it .... JEditorPane can display html/rich text format contents ... you can use the methods ... read or setText or setPage of JEditorPane to show the respective content.
For further information .. consult java api for javax.swing.JEditorPane
nanosani
Unauthenticated Liar
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494