954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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
Team Colleague
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
 

I have built web browser in java.It compile and gives following error

note:browser.java uses or overwrides a deprecacted api.
note:recompile with -xint:dprecation for details.

but execute it proprly . when I open Google It opens page with html tag.
So,please Someone can help me how to display html files or websites properly.
If It's java code is available please post here or send in my Email address: sahbinesh@yahoo.com

Binesh SAh
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

See the Desktop class.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You