Introduction to JLevel by Kogonuso

JLevel (@JLevel1) | TwitterAbout / How To

 

What is JLevel?

JLevel is a fast new way to write Html in Java Application without actually writing any Html Tag. It is a non-standard
Java library. The idea behind JLevel is simple! It was around
providing Java developer a sort of multi-line coma or plus sign
separated String Array that replaces any amount of Html that developer
desires. One the content is code the Array is passed over to a processing method as implemented and that’s it. In no time the developer will be presented with a more beautiful DOM/Browser-looking GUI text.
JLevel allows the developer to be creative and more productive, code fast, and even write less code than using standard Java Html style. It makes things like HTML document traversal and manipulation, event handling, and animation
simpler. With an easy-to-use in-line and embedded CSS style developer
armed with Java Swing Frame and text display components such as labels,
buttons, EditorPane, etc can develop GUI without writing too much Java code.
Its syntax
follows that of pure Java code but once inside the JLevel-style-Array
Developers can code thinking outside the box. All the limitation that
that standard Java style Html posed on the developer has been eradicated
completely by JLevel and this is why this project is far from
reinventing the wheel. 
JLevel is an opensource library and will remain so, ensure you read the MIT-License before you use the product. Download JLevel 2.0 here

About the Author

JLevel is a project developed by Kelechi C Ofoleta (goes by the Trademark
Kogonuso), as a 2012 summer project. Kelechi C Ofoleta graduated in
Computer Science (Major) and Information Systems(Major) from Victoria
University of Wellington New Zealand.
The author can be contacted below:
[email protected] 

Now See How To Use JLevel Below:

JLevel 2.0 Short Demos

JLevel version 2.0 is now ready and will be available for download on Friday the 15th March by 9 pm NZ time. It will be available on SourceForge.net and will also be downloadable from this page.  
Meanwhile  here are the preview codes to enlighten you on how to use JLevel 2.0. As mention in the previous announcements that we released regarding JLevel 2.0, it has a very significant deviation from what version 1.0.0 offered before. But for the benefit of those that have used JLevel 1.0.0 Beta we have retained the variable version but have made some changes to make the variable easier to code than was previously allowed. Instead of starting a variable with $ sign and ending the variable with $ sign each variable now starts with either :
 

 

  • s – for the styled open variable (ready to accept in-line style see demo code for details)
  • o – for an open variable (ready to accept attributes see dome for details)
  • c – for a closed opening variable (does not accept style nor attributes)
  • e – for end variable (ends all three opening variables above)
     
    More demos will be available soon and even more, can be made available on demand
import com.kogonuso.JLevel;

/**
 * @author Kogonuso
 * since 08/03/2013
 *
 */
public class Weather extends JLevel {

 public String DOMFormer (){
  String data ="";
  int number = 32; 
  for(int i = 1;i <.number;i++){
   data += i+" ";
  }
  
  String htmlComponents = 
    html(
    head(
     title("Welcome to JLevel"),
     attachStyle("style.css")),
    body("color:red;",
    h1("color:green;",data),br,
    comment("Kogonuso short logo image"),
    attachImage("k.gif", 300, 300),br2,
    attachApplet("applet/WriteFile.class", 200, 400),
    login("weather2.html","Username","Password","Submit"
    )
    ));
  
  
  saveAsHtml("login2", htmlComponents);
  return htmlComponents;
 }
 
}




 public static void main(String[] args) {
  Weather cot = new Weather();
  cot.processRequest();
  System.out.println("\n\n\n");
  cot.DOMFormer ();

 }




 static final int currentTemp = 70;
 static final String currentImage = "K.gif";
 static final String[] forecastDay = { "Thursday",
  "Friday",
 "Saturday" };
 static final String[] forecastImage = { "fb.png", 
  "g+.png",
 "t.png" };
 static final int[] forecastHi = { 82, 82, 73 };
 static final int[] forecastLo = { 58, 65, 48 };

 
 /*The main purpose of this demo is to demonstrate how to use JLevel 
  * 2.0 to create html table as well as how to include 
  * loop in the document former method.*/
 public void processRequest(){

  try {
   /*utput your page here. You may use following sample code. */
   String dailyForecast ="";
   for (int i = 0; i < forecastDay.length; i++) {
    dailyForecast += tr(td(nbsp,font(size$("+1"),
     t(forecastDay[i]))),
     td(center(img(width$("48"),height$("35"), src$(forecastImage[i]))
     )),
     td(center(font(size$,"+1",
     t(forecastHi[i])))),     
     td(center(font(size$,"+1",
     t(forecastLo[i])))) 
     );

   }
   String[] documnent ={
     doctype(),
     html(
     head(
     title("Sebastopol Weather Forecast"),
     attachStyle("style.css")),
     body("color:red;","the man:",//,id("red"),border("0"),
     center(
     table("color:red;",border("1"), cellpadding("0"), cellspacing$("0"), width$("70%"),
        // first row
     tr(
     td(center("",b(font(size$,"+2",t("Current Conditions"))))),
     td(center(img(width$("48"),height$,"32",src$,currentImage))),
     td( colspan$("2"),center(b(font(size$,"+2",t(currentTemp + "°")))))

     ),
       // Second row
     tr(
     td( colspan$("2"),t(""),center(b(font(size$,"+1",t("Extended Forecast"))))),
     td(center(b(font(size$,"+1",t("Hi"))))),
     td(center(b(font(size$,"+1",t("Lo")))))    

     ),

     // Daily forecast rows loop
     dailyForecast

     )//end table
     //                    tab(center(),b(),"")
     ),//end center

     br2,inputCheckbox,t("Check me")
     )//end body


     )//end html

   };//end document


   System.out.println(level(documnent));
   saveAsHtml("weather2", level(documnent));
  } finally {            
   //        out.close();
  }



 }
 
 

Demo web page written using JLevel 2.0

JLevel version 2.0 is now ready and will be available for download on Friday the 15th March by 9pm NZ time. It will be available on SourceForge.net and will also be downloadable from this page.
Meanwhile here are the preview codes to enlighten you on how to use JLevel 2.0. As mention in the previous announcements that we released regarding JLevel 2.0, it has a very significant deviation from what version 1.0.0 offered before. But for the benefit of those that have used JLevel 1.0.0 Beta we have retained the variable version but have made some changes to make the variable easier to code than was previously allowed. Instead of starting a variable with $ sign and ending the variable with $ sign each variable now starts with either :s – for the styled open variable (ready to accept in-line style see demo code for details)

o – for an open variable (ready to accept attributes see dome for details)

c – for a closed opening variable (does not accept style nor attributes)

e – for end variable (ends all three opening variables above)

It might interest you to know that this content was generated using JLevel inside Servlet. Use JLevel freely for your Java codes of any form you can experiment and see what works best for you to enhance your productivity.
It is simple as you can see below just call a method that has the name of HTML tags that we are all familiar with and get you tags form and properly closed for you by JLevel. Apply CSS as you would on any HTML web page, this time with JLevel if you start the content within any method that you called with CSS, JLevel detects it and inserts the style attribute for you and yet format things as it should but if you choose not to use in-line still it will omit the style. This does not mean that if you did not start your content with CSS that you cannot define it at any point by calling the style method. Pay proper attention to our sample codes and you will learn a lot of simple tricks to make your coding faster and even more rewarding.Never waste your time looking for HTML parser as JLevel has taken over and provided you with a new and improved experience on parsing HTML with Java without writing much code.

/**
 * @author Kogonuso
 * @since 09/03/13
 *
 */



import com.kogonuso.JLevel;

public class Transition extends JLevel{

   /*This method demonstrates how JLevel 2.0 can be written using only methods 
    * instead of variables as in the content in the method 
    * below it is your choice to pick the method you prefer and stick to it*/
    protected String processRequest(){
       
            String[] document ={
    doctype(),
    html( 
     head(
      title(t("JavaScript testing in JLevel")),

               includeStyle("stylesheet1.css"),

               attachJQuery("//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js")

    ),
    body(

    div(id$("mainContent"),
    div(id$("nav"),br,
                                //header and navigation called as a separate method
                                headerAndNavigation(),
                                br7,
                               
    //menu a
     dl(class$("dropdown"),
     dt( id$("one-ddheader"),onmouseover$("ddMenu('one',1)"),
       onmouseout("ddMenu('one',-1)"),t("Menu One")),
     dd( id$("one-ddcontent"),onmouseover$("cancelHide('one')"),
       onmouseout("ddMenu('one',-1)"),
     ul(
     li(a (href$("#"),class$("underline"), t(" Item 1"))),
     li(a (href$("#"),class$("underline"), t("Item 2" ))),
    li(a( href$("#"),class$("underline"), t("Item 3") )),
    li(a(href$("#"),class$("underline"), t(" Item 4" ))),
    li(a(href$("#"),t("Item 5")))
     ))),
//     //menu 2
     dl(class$("dropdown"),
       dt( id$("two-ddheader"),onmouseover$("ddMenu('two',1)"),
         onmouseout("ddMenu('two',-1)"),t("Menu two")),
       dd( id$("two-ddcontent"),onmouseover$("cancelHide('two')"),
         onmouseout("ddMenu('two',-1)"),
       ul(
       li(a(href$("#"),class$("underline"),t("Item 1"))),
       li(a(href$("#"),class$("underline"),t("Item 2"))),
      li(a(href$("#"),class$("underline"),t(" Item 3"))),
      li(a(href$("#"),class$("underline"),t("Item 4"))),
      li(a(href$("#"),t("Item 5")))
       ))),
     //menu3
     //menu 2
       dl(class$("dropdown"),
         dt( id$("three-ddheader"),onmouseover$("ddMenu('three',1)"), 
           onmouseout("ddMenu('three',-1)"),t("Menu three")),
         dd( id$("three-ddcontent"),onmouseover$("cancelHide('three')"),
           onmouseout("ddMenu('three',-1)"),
         ul(
         li(a(href$("#"),class$("underline"),t("Item 1"))),
         li(a(href$("#"),class$("underline"),t("Item 2"))),
        li(a(href$("#"),class$("underline"),t("Item 3"))),
        li(a(href$("#"),class$("underline"),t("Item 4"))),
        li(a(href$("#"),t(" Item 5")))
         ))),
     div("margin-left:30px;clear:both;",
     //Content area
       
     p("font-weight:900;color:green;",t(br+"Pure JLevel tag free Java made possible Html page")),
     pre(big(t("Get Ready for JLevel 2.0 - the simple tag free html java code library"+br+
     "Go ahead and start forgetting what they taught you regarding counting HTML " +br+
     "Tags both in web Development and java coding as these will become obsolete with JLevel 2.0."+br+

     "It will provide experience that will seem fulfilling just like when web 2.0 took over the norm" +br+
     "of WWW/Internet interaction and remained so today."+br+

     "Nothing new to learn if you already know Java and Html. Your knowledge of JLevel 1.0.0 Beta " +br+
     "WILL NOT BE useful with JLevel 2.0 as this is totally re-engineered library."+br+
     "The purpose is still the same - to make programing and web development never feel like a drag " +br+
     "anymore for developer that uses Html,Css JavaScript,jQuery and other scripts."+br+

     "It will be simple that you will forget that Html ever has close set (tags). That is you will " +br+
     "never worry about closing the open tag that takes attributes or in-line style and closing tag " +br+
     "at all, all these have be automated. Furthermore,all self closing tags are have been taken care of."+br+

     "Watch out for the preview code this week!")))
      
 
       ))),br2,
    

                                //footer method
                                footer(),

                                
    insertScript("C:/Users/Kogonuso/Desktop/Portables/Sites/Servlet+JSP/Test/WebContent/dropdown.js"),
                insertScript("C:/Users/Kogonuso/Desktop/Portables/Sites/Servlet+JSP/Test/WebContent/js2.js")
    
    ))
  };
  saveAsHtml("transition", level(document));
  return(level(document));
        }

    /*This method demonstrates how JLevel 2.0 can be written using only variable instead of methods as in the content above
     * it is your choice to pick the method you prefer and stick to it*/
    protected String headerAndNavigation(){
     String[] headerNav ={
                //header
                 div("width:1000px;height:70px;", id$("header"),
                 h1(id$("head"),a(href$("#"),
                 t("JLevel 2.0 - Java Library")))
                 ),
                 
                 //the navigation bar
                 sdiv,"width:1000px;height:60px;line-height:50px;background-color:#0D2A4F;margin:auto;",ct,
                 odiv,id$,"navdiv",ct,
         oul,id$,"nav",ct,
         cli,aHref,"#",ct,"Home",ea,eli,
                                            cli,aHref,"#",ct,"JLevel v2.0",ea,eli,
            cli,
             aHref,"http://jlevel4java.blogspot.co.nz/",ct,"Products",ea,
                oul,class$,"child",ct,
                    cli,aHref,"#",ct,"Animation",ea,eli,
                                                cli,aHref,"#",ct,"Transition",ea,eli,
                    cli,aHref,"#",ct,"Content",ea,eli,
                    cli,aHref,"#",ct,"Speakers",ea,
                                                  cul,
                            cli,aHref,"#",ct,"10 watt",ea,eli,
                            cli,aHref,"#",ct,"20 watt",ea,eli,
                            cli,aHref,"#",ct,"30 watt",ea,eli,
                        eul,
                    cli,
                    cli,aHref,"#",ct,"Random Equipment",ea,eli,
                eul,
            eli,
            cli,
                aHref,"http://kogonuso.blogspot.co.nz/",ct,"Services",ea,
                oul,class$,"child",ct,
                    cli,aHref,"#",ct,"Repairs",ea,eli,
                    cli,aHref,"#",ct,"Installations",ea,eli,
                    cli,aHref,"#",ct,"Setups",ea,eli,
                eul,
            eli,
            cli,aHref,"http://jlevel4java.blogspot.com/p/about.html",ct,"About",ea,eli,
            cli,aHref,"http://jlevel4java.blogspot.com/p/spport.html",ct,"Contact",ea,eli,
        eul,
        ediv,ediv
                                        
                                    };
            
            return level(headerNav);
        }
        
    /*One of short methods to show how methods can be used inside a JLevel document former method*/
        protected String footer(){
            String[] footer ={
            cdiv,ccenter,ofooter,id$,"footer",ct,"© JLevel 2013. All Rights Reserved!",efooter,ecenter,ediv,
             };
         
         return level(footer);
        }
        
        
        
        /*One of short methods to show how methods can be used inside a JLevel document former method*/
        protected String advert(){
         return br6+"That's what JLevel can do for you!";
        }

    

 public static void main(String[] args) {
  Transition t = new Transition();
  t.processRequest();

 }

}

JLevel documentation as  package in com.kogonuso:


<!– Generated by javadoc (version 1.7.0_05) on Sat Jan 26 17:37:51 NZDT 2013
 

com.kogonuso

Interfaces

Classes

https://www.geezwild.com/