Menu

Home

Dylan Parsons

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:

    :::java
    final MenuItem sample_module = new MenuItem("Sample Module");
    * Right above this line add the following line:

    :::java
    final MenuItem foo_bar = new MenuItem("Foo Bar");
    * Then in function IWMenuBar(Stage stage) find the following line:

    :::java
    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, leaving quit_item at the end of the list. For example:

    :::java
    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:

    :::java
    sample_module.setOnAction(MEHandler);
    And add your handler to this list:

    :::java
    foo_bar.setOnAction(MEHandler);
    * Now find this code:

    :::java
    if(name.equals("Sample Module")) {
    IWSampleModule sampleModule = new IWSampleModule(stage, urlTextField, searchTextField, webView);
    }
    And add you own code below:

    :::java
    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.


MongoDB Logo MongoDB