ElanBean For Hierarchical-Menus
Index |
Contents |
Samples |
Excercises |
The above DHTML component is generated by ElanBean for DHTML-Hierarchial
Menu. This is a crossbrowser component, that can be created
using the following few lines of code. Simple! isn't
it? Here is the code to create Hierarchial Menu. // Initializing the menu-items lists. Notice that Sub-menues are indented. String items[] = { "Index","Contents","Samples","Exercises"}; // Level 1 sub items. String sitems1[] = {"Index1","Index2","Index3"}; // Level 2 sub items. String sitems11[] = {"Index11","Index12","Index13"}; // Level 3 sub items. String sitems113[] = {"Index131","Index132","Index133"}; String sitems2[] = {"Experts","Contents"}; // Sub Items for "Contents" String sitems3[] = {"Java","Servlets"}; // Sub Items for "Samples" // Sub Items for "Servlets" String sitems32[] = {"Features","Forum","How-to","New","Hot Sites"}; // Sub Items for "Excrcises" String sitems4[] = {"ASP","Cold Fusion"}; // Following few lines of code creates vanila DHTML-Hierarchial Menu. HierMenuCB hm = new HierMenuCB( ); hm.addMMItems(items); hm.addSMItems(sitems1, 1, sitems11,3,sitems113); hm.addSMItems(sitems2); hm.addSMItems(sitems3, 2, sitems32); hm.addSMItems(sitems4,1,sitems41); Note: You can add upto 5 levels of hierarchical submenus. In the first release of ElanBeans, you can have only one DHTML-Hierarchial Menu per a page. Also we need to put some DHTML code in the header part of the page. This code can be generated by calling the following static method, then user can place the above code anywhere in the Servlet. HierMenuCB.createWCHead(out); // Static method, to generate Header Code. The ElanBean supports many simple methods to set every aspect of the style of the Component. For Example, User can customize background, foreground color of each-item, font, size, border of each lable etc. Some of the methods are illustrated below: hm.setMMBGColor("green"); // To set Main-Menu BG color. hm.setMMFontStyle("black","Times new roman",14); // To set Lable Style // If you need each sub-menu different BG-color use the following method. String colors[]={"blue","green","red","purple"); hm.setSMBGColor(colors) // If you need each sub-menu different FG-color use the following method. String colors[] = {"white","yellow","white","white"); hm.setSMFGColor(colors); // Method to set border colors for the sub-menues. String colors[] = {"black","brown","yellow","white"); hm.setSMBorderColor(colors); Note: User can also configure the style using properties file. |