In this post, we are to discuss how to create help for your swing application using swing components. The idea is to create text file for each help file, the content can be formatted with html, then on click of a button you display a particular file in a panel. To make the panel (help page) stay on top of other opened windows of your application we can choose to display it as a dialog.check https://gilbertadjin.wordpress.com/2009/10/21/form-showdialog-in-java/ how to show a panel as dialog.
To start with we create a class that will load a help file from a source(which you have save it in the settings of your application) by passing the file name without the extension….below is the class
Then we create a panel and name it “helpdetailPanel”. We then add a JEditorPane to the Panel and then add the constructor below to the panel class
Then in the application,on click of a button we add the code below to show a help based on the name (help file name) we pass to the “helpfile” class. Below shows the code to show the panel with the help content
In the code above, “customers” is the name of a help file with a content below.
The picture below shows how the help content that is displayed at runtime on click of a help button in the Customers Panel.