Home - nick-ivanov/icewolf GitHub Wiki
How to Create a Module for Icewolf Web Browser
Step 1. Add a Menu Item
Let’s create a module named “Foo Bar”.
- Open
IWMenuBar.java
- Find this line in the declarations part of class IWMenuBar:
final MenuItem sample_module = new MenuItem("Sample Module");
- Right above this line add the following line:
final MenuItem foo_bar = new MenuItem("Foo Bar");
- Then in function IWMenuBar(Stage stage) find the following line:
main_menu.getItems().addAll(sample_module, quit_item);
- Then add your item into the list of arguments of
addAll()
function, wherever you want the menu item to be, leavingquit_item
at the end of the list. For example:
main_menu.getItems().addAll(sample_module, foo_bar, quit_item);
- Make your menu item handled by a universal handler. Find this string in
IWMenuBar
class:
sample_module.setOnAction(MEHandler);
And add your handler to this list:
foo_bar.setOnAction(MEHandler);
- Now find this code:
if(name.equals("Sample Module")) {
IWSampleModule sampleModule = new IWSampleModule(stage, urlTextField, searchTextField, webView);
}
And add you own code below:
if(name.equals("Foo Bar")) {
IWFooBar sampleModule = new IWFooBar(stage, urlTextField, searchTextField, webView);
}
- Finally, copy file IWSampleModule.java and paste it under the name of your class, e.g. IWFooBar.java (keep the IW prefix). Rename class
IWSampleModule
(e.g.,IWFooBar
). *Test the result.
Congratulations! You’ve just created a new menu item and a separate class to handle it. This class has references to the stage, URL text field, search text field and the web view.