Monday, December 28, 2015

Difference between Comparable and Comparator Interface

Comparable 
1) Comparable is an interface.

2) Comparable is located in the java.lang package

3) It is in the collections framework of java since java 1.2.

4) Its author is Josh Bloch.

5) Comparable interface contains  one methos i.e "int compareTo(Object o)" to implement.

6) It compares this object with the argument object for sorting order. and it returns the
negative integer or zero or positive integer value based on this object is greater than
or equal to the specified argument object.

7) It throws ClassCastException if the specified object prevents it from being compare to this object.

8) Except Number class most of the

Interface

package java.lang;
import java.util.*;
public interface Comparable {
  public int compareTo(T o);
}

Example:

/**
 * @author raj
 *
 */
public class Planet implements Comparable{
private int size;
private String name;

public Planet(String name, int size) {
this.setName(name);
this.setSize(size);
}

public int compareTo(Planet planet) {

return  this.getSize() == planet.getSize() ? 0
  : this.getSize() < planet.getSize() ? -1
  : 1;

}

public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getName());
builder.append(" : ");
builder.append(getSize());
return builder.toString();
}

public int getSize() {
return size;
}

public void setSize(int size) {
this.size = size;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


public class PlanetEngine {
public static void main(String[] args) {
Planet p0 = new Planet("sun",0);
Planet p1 = new Planet("mercury",1);
Planet p2 = new Planet("venus",2);
Planet p3 = new Planet("earth",3);
Planet p4 = new Planet("mars",4);
Planet p5 = new Planet("saturn",5);
Planet p6 = new Planet("jupiter",6);
Planet p7 = new Planet("uranus",7);
Planet p8 = new Planet("neptune",8);
Planet p9 = new Planet("pluto",9);

List list = new ArrayList();
list.add(p0);
list.add(p1);
list.add(p2);
list.add(p3);
list.add(p4);
list.add(p5);
list.add(p6);
list.add(p7);
list.add(p8);
list.add(p9);

System.out.println("\n\nSORGING BYE SIZE USING COMPARABLE ");
Collections.sort(list);

for(Planet p : list) {
System.out.println(p);
}
}
}


In this example the compare to method returns the negative , zero, or positive integer values based on the size of the planet. means based on the planet size the sorting will be done.

Comparator
1) Comparator is an Interface
2) It is resides into the java.util package
3) It is in the java since java 1.2
4) Its author is Josh Bloch and Neal Gafter.
5) Comparator contains two methods 1) int compare(Object o1, Object o2) 2) boolean equals(Object objt).
6) The compare method compares two objects. It compares the first object with
the second object and based on the comparision it returs negative, zero or positive integer value.
7) It throws ClassCastException if the object
8) One can create multiple comparator based on the required sorting types.

Interface code

package java.util;
public interface Comparator {
  int compare(T o1, T o2);
  boolean equals(Object obj);
}

Example
import java.util.Comparator;


public class PlanetComparatorByName implements Comparator{

public int compare(Planet p1, Planet p2) {

if(p1.getName()==null && p2.getName()==null) {
return 0;

} else if(p1.getName()==null && p2.getName()!=null) {
return -1;

} else if(p1.getName()!=null && p2.getName()==null) {
return 1;

} else if(p1.getName().length()>p2.getName().length()) {
return 1;

} else if(p1.getName().length() return -1;

} else {
return p1.compareTo(p2);
}

}

}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


public class PlanetEngine {
public static void main(String[] args) {
Planet p0 = new Planet("sun",0);
Planet p1 = new Planet("mercury",1);
Planet p2 = new Planet("venus",2);
Planet p3 = new Planet("earth",3);
Planet p4 = new Planet("mars",4);
Planet p5 = new Planet("saturn",5);
Planet p6 = new Planet("jupiter",6);
Planet p7 = new Planet("uranus",7);
Planet p8 = new Planet("neptune",8);
Planet p9 = new Planet("pluto",9);

List list = new ArrayList();
list.add(p0);
list.add(p1);
list.add(p2);
list.add(p3);
list.add(p4);
list.add(p5);
list.add(p6);
list.add(p7);
list.add(p8);
list.add(p9);

System.out.println("\n\nSORGING BYE NAME LENGTH USING COMPARATOR ");
Collections.sort(list, new PlanetComparatorByName());

for(Planet p : list) {
System.out.println(p);
}
}
}

Friday, December 11, 2015

Struts actions redirect and action chaining

Action redirect jsp code:
 <package name="default" extends="struts-default">  
   <action name="user" class="com.raj.UserAction">  
     <result name="success" type="redirect">REDIRECT_ACTION</result>  
   </action>  
   <action name="saveAction" class="com.raj.SaveAction">  
     <result name="success">/success.jsp</result>  
   </action>  
 </package>  
In Action redirect it makes a complete a new call to the new action. so the values in to the stack will be of the new actions. while in the case of the action chaining it will make the call to the new action with the values of the previous action and the values of the new actions. Action Chaining jsp code:
 <package name="default" extends="struts-default">  
   <action name="user" class="com.raj.UserAction">  
     <result name="success" type="chain">CHAIN_ACTION</result>  
   </action>  
   <action name="saveAction" class="com.raj.SaveAction">  
     <result name="success">/success.jsp</result>  
   </action>  
 </package>  

How to use Filter in Hibernate ?

visit : http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/filters.html
for complete detail information about the Filter usage with example.

How to use projection in Hibernate ?

The projections concept is introduced in hibernate
3.0 and mainly we can do the following two operations using the projection
We can load partial object from the database
We can find the Result of Aggregate functions
Projection is an Interface given in “org.hibernate.criterion” package, Projections is a class
given in same package, actually Projection is an interface, and Projections is a class and is a
factory for producing projection objects.
In Projections class, we have all static methods and each method of this class returns
Projection interface object.
If we want to add a Projection object to Criteria then we need to call a
method setProjection()
Remember : while adding projection object to criteria, it is possible to add one object at a
time. It means if we add 2nd projection object then this 2nd one will overrides the first one
(first one wont be work), so at a time we can have only one projection object to criteria
object.
Using criteria, if we want to load partial object from the database, then we need to create a
projection object for property that is to be loaded from the database

How to use?
Criteria criteria = session.createCriteria(Entity.class);
criteria.setProjection(Projections.property("name"));
List list = criteria.list();
Iterator iterator = list.iterator();
while(iterator.hasNext())
{
             String s = (String) iterator.next();
             // ---- further code -----
}

If we add multiple projections to criteria then the last projection added will be considered
to execute

Criteria criteria = session.createCriteria(Entity.class);
Projection p1 = Projection.property("id");
Projection p2 = Projection.property("name");
criteria.setProjection(p1):
criteria.setProjection(p2):
List list=crit.list();

Here collectiions list, is going to contain the name in the form of String objects, but Entity id are
over ridden, second projection over rides the first one, i mean p2 only will works p1 will not works,
actually there is a way to add multiple projections to criteria to select more than one column value.

SessionFactory sessionFactoryObj = configurationObj.buildSessionFactory();
Session sessionObj = sessionFactoryObj.openSession();

Criteria criteriaObj = sessionObj.createCriteria(Entity.class);
criteriaObj.addOrder(Order.desc("id"));

ProjectionList projList = Projections.projectionList();
projList.add(Projections.property("id"));
projList.add(Projections.property("category"));
criteriaObj.setProjection(projList);

List entityList = criteriaObj.list();
Iterator iteratorObj = entityList.iterator();
System.out.println("ID \t CATEGORY ");

while(iteratorObj.hasNext()){
       Object data[] = (Object[])iteratorObj.next();
      System.out.println(data[0]+" \t "+data[1]);
}

How to use criterion in Hibernate ?

Criterion 
Criteria criteria = session.createCriteria(Entity.class);
Criterion criterion =Restrictions.gt("id", new Integer(11));
// .gt() : means greater than
// id is a variable of our POJO class Entity.java
criteria.add(criterion); // adding criterion object to criteria class object
List l = criteria.list(); // executing criteria query


In our above example we are fetching the data by comparing id greater than (>) 11
If we want to put more conditions on the data (multiple conditions) then we can use
.and() method ,. or() method , .eq() method using the Restrictions class


Restrictions
Criteria criteria = session.createCriteria(Entity.class);
criteria.add(Restrictions.and(Restrictions.like("name","%M%"),Restrictions.eq("category",ne
w String(“bird”))));
List list = criteria.list();
Iterator it = list.iterator();


Configuration configurationObj = new Configuration();
configurationObj.configure("hibernate.cfg.xml");


SessionFactory sessionFactoryObj = configurationObj.buildSessionFactory();
Session sessionObj = sessionFactoryObj.openSession();


Criteria criteriaObj = sessionObj.createCriteria(Entity.class);
Criterion criterion = Restrictions.gt("id", new Integer(0)); 

// means : where id > 0

criteriaObj.add(criterion);


criteriaObj.addOrder(Order.desc("id")); 

// will fetch the data into descending order
//criteriaObj.addOrder(Order.asc("id")); 


// will fetch the data into ascending order
List entityList = criteriaObj.list();
Iterator entityListIterator=entityList.iterator();
System.out.println("ID\t NAME \t CATEGORY");
System.out.println("-------------------------");
while(entityListIterator.hasNext()){
            Entity entityObj=(Entity)entityListIterator.next();
            System.out.print(entityObj.getId());            System.out.print(" \t"+entityObj.getName());            System.out.println(" \t"+entityObj.getCategory());
}
System.out.println("-------------------------");
sessionObj.close();
sessionFactoryObj.close();



Thursday, December 10, 2015

Hibernate + How to add condition in annotation ?

There are two ways to add the condition/where clause into the annotation class
1) at the class level
2) at the field method or field declaration

@Entity
@Table(name = "TBLM_PACKAGE")
@Where(clause = "PACKAGE_MODE!='DESIGN'")
public class PkgData{

       private String packageMode;


      @Column(name = "PACKAGE_MODE")
public String getPackageMode() {
return packageMode;
}

public void setPackageMode(String packageMode) {
this.packageMode = packageMode;
}

}


Monday, December 7, 2015

Everything about java main(String[] args) method


main method is the first method which get called automatically when the program executes.
there  must be only one main in a java program which you want to execute.
in main method signature/prototype 
public
It is a access specifier which defines the scope of the method it must be public

static
makes the method  to be called with the class name as to run the program we use the class name. thats is the reason static is there in main method.

void:
void states that the main method doesnt return anything. and it must be void only.

main : it is a name of method.

(String[] args) :  here args is an array of String class and it must be string class array only.
here instead of String[] args you can use varargs i.e String... args

main method cannot be override
main method can be overloaded. 

Sunday, December 6, 2015

J2ME : complete J2ME code for the converter application


j2me converter
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * @author RajPalace
 */
public class  Converter extends MIDlet implements CommandListener, ItemCommandListener {

    float flag = 0;
    private boolean midletPaused = false;
    ////GEN-BEGIN:|fields|0|
    private Command exitCommand;
    private Command ConverterImage;
    private Command exitCommand1;
    private Command backCommand;
    private Command itemCommand;
    private Command okCommand;
    private Command BitByte;
    private Command Weight;
    private Command Time;
    private Command Day;
    private Command cancelCommand1;
    private Command cancelCommand;
    private Command itemCommand1;
    private Command okCommand1;
    private Command screenCommand;
    private Command Distance;
    private Form WelCome;
    private StringItem stringItem;
    private ImageItem imageItem;
    private Form Distances;
    private TextField cm_Tf;
    private TextField km_Tf;
    private TextField mm_Tf;
    private TextField mt_Tf;
    private Form BitBytes;
    private TextField mbs_Tf;
    private TextField kbs_Tf;
    private TextField bytes_Tf;
    private TextField bits_Tf;
    private TextField gbs_Tf;
    private TextField tbs_Tf;
    private Form Weights;
    private TextField gm_Tf;
    private TextField mg_Tf;
    private TextField tn_Tf;
    private TextField kg_Tf;
    private Form Times;
    private TextField minutes_Tf;
    private TextField mili_Tf;
    private TextField seconds_Tf;
    private TextField hours_Tf;
    private Form Days;
    private TextField days_Tf;
    private TextField weeks_Tf;
    private TextField years_Tf;
    private TextField months_Tf;
    private Ticker ticker;
    private Image Converter;
    private Ticker o2Sol;
    //
//GEN-END:|fields|0|    public Display disply = null;

    /**
     * The  Converter constructor.
     */
    public  Converter() {
    }

    ////GEN-BEGIN:|methods|0|
    //
//GEN-END:|methods|0|    ////GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the startMIDlet method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
    //
//GEN-END:|0-initialize|2|
    ////GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getWelCome());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
    //
//GEN-END:|3-startMIDlet|2|
    ////GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //
//GEN-END:|4-resumeMIDlet|2|
    ////GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The display instance is taken from getDisplay method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if null, then nextDisplayable is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //
//GEN-END:|5-switchDisplayable|2|
    ////GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        try {
            if (displayable == BitBytes) {//GEN-BEGIN:|7-commandAction|1|52-preAction
                if (command == backCommand) {//GEN-END:|7-commandAction|1|52-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getWelCome());//GEN-LINE:|7-commandAction|2|52-postAction
                    // write post-action user code here
                } else if (command == cancelCommand) {//GEN-LINE:|7-commandAction|3|131-preAction
                    // write pre-action user code here
                    bits_Tf.setString("");
                    bytes_Tf.setString("");
                    kbs_Tf.setString("");
                    mbs_Tf.setString("");
                    tbs_Tf.setString("");
                    gbs_Tf.setString("");
//GEN-LINE:|7-commandAction|4|131-postAction
                    // write post-action user code here
                } else if (command == okCommand) {//GEN-LINE:|7-commandAction|5|130-preAction
                    // write pre-action user code here
                    try {
                        float ibits = 0, ibytes = 0, ikbs = 0, imbs = 0, igbs = 0, itbs = 0;

                        String sbits = bits_Tf.getString();
                        String sbytes = bytes_Tf.getString();
                        String skbs = kbs_Tf.getString();
                        String smbs = mbs_Tf.getString();
                        String sgbs = gbs_Tf.getString();
                        String stbs = tbs_Tf.getString();

                        if (sbits.length() > 0) {
                            ibits = Float.parseFloat(sbits);
                            ibytes = ibits / 8;
                            ikbs = ibytes / 1024;
                            imbs = ikbs / 1024;
                            igbs = imbs / 1024;
                            itbs = igbs / 1024;
                        } else if (sbytes.length() > 0) {
                            ibytes = Float.parseFloat(sbytes);
                            ibits = ibytes * 8;
                            ikbs = ibytes / 1024;
                            imbs = ikbs / 1024;
                            igbs = imbs / 1024;
                            itbs = igbs / 1024;
                        } else if (skbs.length() > 0) {
                            ikbs = Float.parseFloat(skbs);
                            ibytes = ikbs * 1024;
                            ibits = ibytes * 8;
                            imbs = ikbs / 1024;
                            igbs = imbs / 1024;
                            itbs = igbs / 1024;
                        } else if (smbs.length() > 0) {
                            imbs = Float.parseFloat(smbs);
                            ikbs = imbs * 1024;
                            ibytes = ikbs * 1024;
                            ibits = ibytes * 8;
                            igbs = imbs / 1024;
                            itbs = igbs / 1024;
                        } else if (sgbs.length() > 0) {
                            igbs = Float.parseFloat(sgbs);
                            itbs = igbs / 1024;
                            imbs = igbs * 1024;
                            ikbs = imbs * 1024;
                            ibytes = ikbs * 1024;
                            ibits = ibytes * 8;
                        } else if (stbs.length() > 0) {
                            itbs = Float.parseFloat(stbs);
                            imbs = itbs * 1024;
                            igbs = imbs / 1024;
                            ikbs = imbs * 1024;
                            ibytes = ikbs * 1024;
                            ibits = ibytes * 8;
                        }

                        bits_Tf.setString("" + ibits);
                        bytes_Tf.setString("" + ibytes);
                        kbs_Tf.setString("" + ikbs);
                        mbs_Tf.setString("" + imbs);
                        gbs_Tf.setString("" + igbs);
                        tbs_Tf.setString("" + itbs);
                    } catch (Exception e) {
                        Alert error = new Alert("Ups !!", "Invalid Value !!", null, AlertType.ERROR);
                        switchDisplayable(error, displayable);
                    }
//GEN-LINE:|7-commandAction|6|130-postAction
                    // write post-action user code here
                }//GEN-BEGIN:|7-commandAction|7|118-preAction
            } else if (displayable == Days) {
                if (command == backCommand) {//GEN-END:|7-commandAction|7|118-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getWelCome());//GEN-LINE:|7-commandAction|8|118-postAction
                    // write post-action user code here
                } else if (command == cancelCommand) {//GEN-LINE:|7-commandAction|9|127-preAction

                    weeks_Tf.setString("");
                    years_Tf.setString("");
                    months_Tf.setString("");
                    days_Tf.setString("");
                    // write pre-action user code here
//GEN-LINE:|7-commandAction|10|127-postAction
                    // write post-action user code here
                } else if (command == okCommand) {//GEN-LINE:|7-commandAction|11|124-preAction
                    // write pre-action user

                    try {
                        float idays = 0, iweeks = 0, imonths = 0, iyears = 0;
                        String sdays = days_Tf.getString();
                        String sweeks = weeks_Tf.getString();
                        String smonths = months_Tf.getString();
                        String syears = years_Tf.getString();

                        if (sdays.length() > 0) {
                            idays = Float.parseFloat(sdays);
                            iweeks = idays / 7;
                            imonths = idays / 30;
                            iyears = idays / 365;
                            weeks_Tf.setString("" + iweeks);
                            months_Tf.setString("" + imonths);
                            years_Tf.setString("" + iyears);
                        } else if (sweeks.length() > 0) {
                            iweeks = Float.parseFloat(sweeks);
                            idays = iweeks * 7;
                            imonths = idays / 30;
                            iyears = idays / 365;
                            days_Tf.setString("" + idays);
                            months_Tf.setString("" + imonths);
                            years_Tf.setString("" + iyears);
                        } else if (smonths.length() > 0) {
                            imonths = Float.parseFloat(smonths);
                            idays = imonths * 30;
                            iweeks = idays / 7;
                            imonths = idays / 30;
                            iyears = idays / 365;
                            days_Tf.setString("" + idays);
                            weeks_Tf.setString("" + iweeks);
                            years_Tf.setString("" + iyears);
                        } else if (syears.length() > 0) {
                            iyears = Float.parseFloat(syears);
                            idays = iyears * 365;
                            iweeks = idays / 7;
                            imonths = idays / 30;
                            iyears = idays / 365;
                            days_Tf.setString("" + idays);
                            weeks_Tf.setString("" + iweeks);
                            months_Tf.setString("" + imonths);

                        }
                    } catch (Exception e) {
                        Alert error = new Alert("Ups !!", "Invalid Value !!", null, AlertType.ERROR);
                        switchDisplayable(error, displayable);
                    }
//GEN-LINE:|7-commandAction|12|124-postAction
                    // write post-action user code here
                }//GEN-BEGIN:|7-commandAction|13|37-preAction
            } else if (displayable == Distances) {
                if (command == backCommand) {//GEN-END:|7-commandAction|13|37-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getWelCome());//GEN-LINE:|7-commandAction|14|37-postAction
                    // write post-action user code here
                } else if (command == cancelCommand) {//GEN-LINE:|7-commandAction|15|123-preAction
                    // write pr
                    mm_Tf.setString("");
                    cm_Tf.setString("");
                    mt_Tf.setString("");
                    km_Tf.setString("");
//GEN-LINE:|7-commandAction|16|123-postAction
                    // write post-action user code here
                } else if (command == okCommand) {//GEN-LINE:|7-commandAction|17|121-preAction
                    // write pre-action user code here

                    try {
                        String smm = (mm_Tf.getString());
                        String scm = (cm_Tf.getString());
                        String smt = (mt_Tf.getString());
                        String skm = (km_Tf.getString());
                        float imm = 0, icm = 0, imt = 0, ikm = 0;

                        if (smm.length() > 0) {
                            imm = Float.parseFloat("" + smm);
                            icm = (imm * 100) / 1000;
                            cm_Tf.setString("" + icm);
                            mt_Tf.setString("" + (imm / 1000));
                            imt = Float.parseFloat(mt_Tf.getString());
                            km_Tf.setString("" + (imt / 1000));
                        } else if (scm.length() > 0) {
                            icm = Float.parseFloat("" + scm);
                            imm = (icm * 1000) / 100;
                            mm_Tf.setString("" + imm);
                            mt_Tf.setString("" + (imm / 1000));
                            imt = Float.parseFloat(mt_Tf.getString());
                            km_Tf.setString("" + (imt / 1000));
                        } else if (smt.length() > 0) {

                            imt = Float.parseFloat(mt_Tf.getString());
                            km_Tf.setString("" + (imt / 1000));
                            imm = imt * 1000;
                            mm_Tf.setString("" + (imm));
                            icm = (imm * 100) / 1000;
                            cm_Tf.setString("" + icm);

                        } else if (skm.length() > 0) {

                            ikm = Float.parseFloat(km_Tf.getString());
                            mt_Tf.setString("" + (ikm * 1000));
                            imt = Float.parseFloat(mt_Tf.getString());
                            imm = imt * 1000;
                            mm_Tf.setString("" + (imm));
                            icm = (imm * 100) / 1000;
                            cm_Tf.setString("" + icm);

                        }
                    } catch (Exception e) {
                        Alert error = new Alert("Ups !!", "Invalid Value !!", null, AlertType.ERROR);
                        switchDisplayable(error, displayable);
                    }


//GEN-LINE:|7-commandAction|18|121-postAction
                    // write post-action user code here
                }//GEN-BEGIN:|7-commandAction|19|100-preAction
            } else if (displayable == Times) {
                if (command == backCommand) {//GEN-END:|7-commandAction|19|100-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getWelCome());//GEN-LINE:|7-commandAction|20|100-postAction
                    // write post-action user code here
                } else if (command == cancelCommand) {//GEN-LINE:|7-commandAction|21|129-preAction
                    // write pre-action user code here
                    mili_Tf.setString("");
                    seconds_Tf.setString("");
                    minutes_Tf.setString("");
                    hours_Tf.setString("");
//GEN-LINE:|7-commandAction|22|129-postAction
                    // write post-action user code here
                } else if (command == okCommand) {//GEN-LINE:|7-commandAction|23|128-preAction
                    // write pre-action user code here
                    try {
                        float isecs = 0, imins = 0, imilis = 0, ihours = 0;
                        String ssecs = seconds_Tf.getString();
                        String smilis = mili_Tf.getString();
                        String smins = minutes_Tf.getString();
                        String shours = hours_Tf.getString();

                        if (smilis.length() > 0) {
                            imilis = Float.parseFloat(smilis);
                            isecs = imilis / 1000;
                            imins = isecs / 60;
                            ihours = imins / 60;


                        } else if (ssecs.length() > 0) {
                            isecs = Float.parseFloat(ssecs);
                            imilis = isecs * 1000;
                            imins = isecs / 60;
                            ihours = imins / 60;

                        } else if (smins.length() > 0) {
                            imins = Float.parseFloat(smins);
                            isecs = imins * 60;
                            imilis = isecs * 1000;
                            ihours = imins / 60;


                        } else if (shours.length() > 0) {
                            ihours = Float.parseFloat(shours);
                            imins = ihours * 60;
                            isecs = imins * 60;
                            imilis = isecs * 1000;



                        }

                        mili_Tf.setString("" + imilis);
                        seconds_Tf.setString("" + isecs);
                        minutes_Tf.setString("" + imins);
                        hours_Tf.setString("" + ihours);
                    } catch (Exception e) {
                        Alert error = new Alert("Ups !!", "Invalid Value !!", null, AlertType.ERROR);
                        switchDisplayable(error, displayable);
                    }
//GEN-LINE:|7-commandAction|24|128-postAction
                    // write post-action user code here
                }//GEN-BEGIN:|7-commandAction|25|76-preAction
            } else if (displayable == Weights) {
                if (command == backCommand) {//GEN-END:|7-commandAction|25|76-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getWelCome());//GEN-LINE:|7-commandAction|26|76-postAction
                    // write post-action user code here
                } else if (command == cancelCommand) {//GEN-LINE:|7-commandAction|27|133-preAction
                    // write pre-action user code here
                    mg_Tf.setString("");
                    gm_Tf.setString("");
                    kg_Tf.setString("");
                    tn_Tf.setString("");
//GEN-LINE:|7-commandAction|28|133-postAction
                    // write post-action user code here
                } else if (command == okCommand) {//GEN-LINE:|7-commandAction|29|132-preAction
                    // write pre-action user code here
                    try {
                        float img = 0, igm = 0, ikg = 0, itn = 0;
                        String smg = mg_Tf.getString();
                        String sgm = gm_Tf.getString();
                        String skg = kg_Tf.getString();
                        String stn = tn_Tf.getString();

                        if (smg.length() > 0) {
                            img = Float.parseFloat(smg);
                            igm = img / 1000;
                            ikg = igm / 1000;
                            itn = ikg / 1000;

                        } else if (sgm.length() > 0) {
                            igm = Float.parseFloat(sgm);
                            img = igm * 1000;
                            ikg = igm / 1000;
                            itn = ikg / 1000;


                        } else if (skg.length() > 0) {
                            ikg = Float.parseFloat(skg);
                            igm = ikg * 1000;
                            img = igm * 1000;
                            itn = ikg / 1000;

                        } else if (stn.length() > 0) {
                            itn = Float.parseFloat(stn);
                            ikg = itn * 1000;
                            igm = ikg * 1000;
                            img = img * 1000;

                        }
                        tn_Tf.setString("" + itn);
                        mg_Tf.setString("" + img);
                        gm_Tf.setString("" + igm);
                        kg_Tf.setString("" + ikg);
                    } catch (Exception e) {
                        Alert error = new Alert("Ups !!", "Invalid Value !!", null, AlertType.ERROR);
                        switchDisplayable(error, displayable);
                    }
//GEN-LINE:|7-commandAction|30|132-postAction
                    // write post-action user code here
                }//GEN-BEGIN:|7-commandAction|31|47-preAction
            } else if (displayable == WelCome) {
                if (command == BitByte) {//GEN-END:|7-commandAction|31|47-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getBitBytes());//GEN-LINE:|7-commandAction|32|47-postAction
                    // write post-action user code here
                } else if (command == Day) {//GEN-LINE:|7-commandAction|33|108-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getDays());//GEN-LINE:|7-commandAction|34|108-postAction
                    // write post-action user code here
                } else if (command == Distance) {//GEN-LINE:|7-commandAction|35|146-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getDistances());//GEN-LINE:|7-commandAction|36|146-postAction
                    // write post-action user code here
                } else if (command == Time) {//GEN-LINE:|7-commandAction|37|98-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getTimes());//GEN-LINE:|7-commandAction|38|98-postAction
                    // write post-action user code here
                } else if (command == Weight) {//GEN-LINE:|7-commandAction|39|71-preAction
                    // write pre-action user code here
                    switchDisplayable(null, getWeights());//GEN-LINE:|7-commandAction|40|71-postAction
                    // write post-action user code here
                } else if (command == exitCommand) {//GEN-LINE:|7-commandAction|41|19-preAction
                    // write pre-action user code here
                    exitMIDlet();//GEN-LINE:|7-commandAction|42|19-postAction
                    // write post-action user code here
                }//GEN-BEGIN:|7-commandAction|43|7-postCommandAction
            }//GEN-END:|7-commandAction|43|7-postCommandAction
            // wri
        } catch (Exception e) {
            Alert error = new Alert("Ups !!", "Invalid Value !!", null, AlertType.ERROR);
            switchDisplayable(error, Distances);
        }
    }//GEN-BEGIN:|7-commandAction|44|
    //
//GEN-END:|7-commandAction|44|

    ////GEN-BEGIN:|18-getter|0|18-preInit
    /**
     * Returns an initiliazed instance of exitCommand component.
     * @return the initialized component instance
     */
    public Command getExitCommand() {
        if (exitCommand == null) {//GEN-END:|18-getter|0|18-preInit
            // write pre-init user code here
            exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit
            // write post-init user code here
        }//GEN-BEGIN:|18-getter|2|
        return exitCommand;
    }
    //
//GEN-END:|18-getter|2|
    ////GEN-BEGIN:|14-getter|0|14-preInit
    /**
     * Returns an initiliazed instance of WelCome component.
     * @return the initialized component instance
     */
    public Form getWelCome() {
        if (WelCome == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
            WelCome = new Form("Welcome", new Item[] { getStringItem(), getImageItem() });//GEN-BEGIN:|14-getter|1|14-postInit
            WelCome.setTicker(getTicker());
            WelCome.addCommand(getExitCommand());
            WelCome.addCommand(getBitByte());
            WelCome.addCommand(getWeight());
            WelCome.addCommand(getTime());
            WelCome.addCommand(getDay());
            WelCome.addCommand(getDistance());
            WelCome.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit
            // write post-init user code here
        }//GEN-BEGIN:|14-getter|2|
        return WelCome;
    }
    //
//GEN-END:|14-getter|2|
    ////GEN-BEGIN:|16-getter|0|16-preInit
    /**
     * Returns an initiliazed instance of stringItem component.
     * @return the initialized component instance
     */
    public StringItem getStringItem() {
        if (stringItem == null) {//GEN-END:|16-getter|0|16-preInit
            // write pre-init user code here
            stringItem = new StringItem("O2 Solutions ", "Conveter Application.");//GEN-LINE:|16-getter|1|16-postInit
            // write post-init user code here
        }//GEN-BEGIN:|16-getter|2|
        return stringItem;
    }
    //
//GEN-END:|16-getter|2|
    ////GEN-BEGIN:|22-getter|0|22-preInit
    /**
     * Returns an initiliazed instance of ticker component.
     * @return the initialized component instance
     */
    public Ticker getTicker() {
        if (ticker == null) {//GEN-END:|22-getter|0|22-preInit
            // write pre-init user code here
            ticker = new Ticker("O2 Solutions [RK]");//GEN-LINE:|22-getter|1|22-postInit
            // write post-init user code here
        }//GEN-BEGIN:|22-getter|2|
        return ticker;
    }
    //
//GEN-END:|22-getter|2|
    ////GEN-BEGIN:|23-getter|0|23-preInit
    /**
     * Returns an initiliazed instance of imageItem component.
     * @return the initialized component instance
     */
    public ImageItem getImageItem() {
        if (imageItem == null) {//GEN-END:|23-getter|0|23-preInit
            // write pre-init user code here
// imageItem = new ImageItem("Converter", getConverter(),ImageItem.LAYOUT_CENTER|ImageItem.LAYOUT_VCENTER, "", //Item.PLAIN);//GEN-BEGIN:|23-getter|1|23-postInit
imageItem= new ImageItem("Converter",getConverter(),ImageItem.LAYOUT_CENTER|ImageItem.LAYOUT_VCENTER, "Converter");

            imageItem.addCommand(getConverterImage());
            imageItem.setItemCommandListener(this);//GEN-END:|23-getter|1|23-postInit
            // write post-init user code here
        }//GEN-BEGIN:|23-getter|2|
        return imageItem;
    }
    //
//GEN-END:|23-getter|2|    //

    ////GEN-BEGIN:|26-getter|0|26-preInit
    /**
     * Returns an initiliazed instance of Converter component.
     * @return the initialized component instance
     */
    public Image getConverter() {

        if (Converter == null) {//GEN-END:|26-getter|0|26-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|26-getter|1|26-@java.io.IOException
                Converter = Image.createImage("/Images/Converter.png");
  // Converter= new ImageItem("Converter",Converter,ImageItem.LAYOUT_CENTER|ImageItem.LAYOUT_VCENTER, "Converter");

            } catch (java.io.IOException e) {//GEN-END:|26-getter|1|26-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|26-getter|2|26-postInit
            // write post-init user code here
        }//GEN-BEGIN:|26-getter|3|
        return Converter;
    }
    //
//GEN-END:|26-getter|3|

    ////GEN-BEGIN:|27-getter|0|27-preInit
    /**
     * Returns an initiliazed instance of ConverterImage component.
     * @return the initialized component instance
     */
    public Command getConverterImage() {
        if (ConverterImage == null) {//GEN-END:|27-getter|0|27-preInit
            // write pre-init user code here
            ConverterImage = new Command("Types", Command.SCREEN, 0);//GEN-LINE:|27-getter|1|27-postInit
            // write post-init user code here
        }//GEN-BEGIN:|27-getter|2|
        return ConverterImage;
    }
    //
//GEN-END:|27-getter|2|
    ////GEN-BEGIN:|32-getter|0|32-preInit
    /**
     * Returns an initiliazed instance of exitCommand1 component.
     * @return the initialized component instance
     */
    public Command getExitCommand1() {
        if (exitCommand1 == null) {//GEN-END:|32-getter|0|32-preInit
            // write pre-init user code here
            exitCommand1 = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|32-getter|1|32-postInit
            // write post-init user code here
        }//GEN-BEGIN:|32-getter|2|
        return exitCommand1;
    }
    //
//GEN-END:|32-getter|2|
    ////GEN-BEGIN:|36-getter|0|36-preInit
    /**
     * Returns an initiliazed instance of backCommand component.
     * @return the initialized component instance
     */
    public Command getBackCommand() {
        if (backCommand == null) {//GEN-END:|36-getter|0|36-preInit
            // write pre-init user code here
            backCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|36-getter|1|36-postInit
            // write post-init user code here
        }//GEN-BEGIN:|36-getter|2|
        return backCommand;
    }
    //
//GEN-END:|36-getter|2|    //

    ////GEN-BEGIN:|29-getter|0|29-preInit
    /**
     * Returns an initiliazed instance of Distances component.
     * @return the initialized component instance
     */
    public Form getDistances() {
        if (Distances == null) {//GEN-END:|29-getter|0|29-preInit
            // write pre-init user code here
            Distances = new Form("Distance", new Item[] { getMm_Tf(), getCm_Tf(), getMt_Tf(), getKm_Tf() });//GEN-BEGIN:|29-getter|1|29-postInit
            Distances.setTicker(getO2Sol());
            Distances.addCommand(getBackCommand());
            Distances.addCommand(getOkCommand());
            Distances.addCommand(getCancelCommand());
            Distances.setCommandListener(this);//GEN-END:|29-getter|1|29-postInit
            // write post-init user code here
        }//GEN-BEGIN:|29-getter|2|
        return Distances;
    }
    //
//GEN-END:|29-getter|2|
    ////GEN-BEGIN:|41-getter|0|41-preInit
    /**
     * Returns an initiliazed instance of okCommand component.
     * @return the initialized component instance
     */
    public Command getOkCommand() {
        if (okCommand == null) {//GEN-END:|41-getter|0|41-preInit
            // write pre-init user code here
            okCommand = new Command("Ok", Command.OK, 0);//GEN-LINE:|41-getter|1|41-postInit
            // write post-init user code here
        }//GEN-BEGIN:|41-getter|2|
        return okCommand;
    }
    //
//GEN-END:|41-getter|2|
    ////GEN-BEGIN:|43-getter|0|43-preInit
    /**
     * Returns an initiliazed instance of itemCommand component.
     * @return the initialized component instance
     */
    public Command getItemCommand() {
        if (itemCommand == null) {//GEN-END:|43-getter|0|43-preInit
            // write pre-init user code here
            itemCommand = new Command("Item", Command.ITEM, 0);//GEN-LINE:|43-getter|1|43-postInit
            // write post-init user code here
        }//GEN-BEGIN:|43-getter|2|
        return itemCommand;
    }
    //
//GEN-END:|43-getter|2|
    ////GEN-BEGIN:|46-getter|0|46-preInit
    /**
     * Returns an initiliazed instance of BitByte component.
     * @return the initialized component instance
     */
    public Command getBitByte() {
        if (BitByte == null) {//GEN-END:|46-getter|0|46-preInit
            // write pre-init user code here
            BitByte = new Command("BitByte", Command.ITEM, 0);//GEN-LINE:|46-getter|1|46-postInit
            // write post-init user code here
        }//GEN-BEGIN:|46-getter|2|
        return BitByte;
    }
    //
//GEN-END:|46-getter|2|
    ////GEN-BEGIN:|48-getter|0|48-preInit
    /**
     * Returns an initiliazed instance of BitBytes component.
     * @return the initialized component instance
     */
    public Form getBitBytes() {
        if (BitBytes == null) {//GEN-END:|48-getter|0|48-preInit
            // write pre-init user code here
            BitBytes = new Form("Bit Bytes", new Item[] { getBits_Tf(), getBytes_Tf(), getKbs_Tf(), getMbs_Tf(), getGbs_Tf(), getTbs_Tf() });//GEN-BEGIN:|48-getter|1|48-postInit
            BitBytes.setTicker(getO2Sol());
            BitBytes.addCommand(getBackCommand());
            BitBytes.addCommand(getOkCommand());
            BitBytes.addCommand(getCancelCommand());
            BitBytes.setCommandListener(this);//GEN-END:|48-getter|1|48-postInit
            // write post-init user code here
        }//GEN-BEGIN:|48-getter|2|
        return BitBytes;
    }
    //
//GEN-END:|48-getter|2|    //

    ////GEN-BEGIN:|60-getter|0|60-preInit
    /**
     * Returns an initiliazed instance of bits_Tf component.
     * @return the initialized component instance
     */
    public TextField getBits_Tf() {
        if (bits_Tf == null) {//GEN-END:|60-getter|0|60-preInit
            // write pre-init user code here
            bits_Tf = new TextField("Bits", null, 32, TextField.ANY);//GEN-LINE:|60-getter|1|60-postInit
            // write post-init user code here
        }//GEN-BEGIN:|60-getter|2|
        return bits_Tf;
    }
    //
//GEN-END:|60-getter|2|    //

    ////GEN-BEGIN:|61-getter|0|61-preInit
    /**
     * Returns an initiliazed instance of bytes_Tf component.
     * @return the initialized component instance
     */
    public TextField getBytes_Tf() {
        if (bytes_Tf == null) {//GEN-END:|61-getter|0|61-preInit
            // write pre-init user code here
            bytes_Tf = new TextField("Bytes", null, 32, TextField.ANY);//GEN-LINE:|61-getter|1|61-postInit
            // write post-init user code here
        }//GEN-BEGIN:|61-getter|2|
        return bytes_Tf;
    }
    //
//GEN-END:|61-getter|2|    //

    ////GEN-BEGIN:|62-getter|0|62-preInit
    /**
     * Returns an initiliazed instance of kbs_Tf component.
     * @return the initialized component instance
     */
    public TextField getKbs_Tf() {
        if (kbs_Tf == null) {//GEN-END:|62-getter|0|62-preInit
            // write pre-init user code here
            kbs_Tf = new TextField("KiloBytes", null, 32, TextField.ANY);//GEN-LINE:|62-getter|1|62-postInit
            // write post-init user code here
        }//GEN-BEGIN:|62-getter|2|
        return kbs_Tf;
    }
    //
//GEN-END:|62-getter|2|    //

    ////GEN-BEGIN:|63-getter|0|63-preInit
    /**
     * Returns an initiliazed instance of mbs_Tf component.
     * @return the initialized component instance
     */
    public TextField getMbs_Tf() {
        if (mbs_Tf == null) {//GEN-END:|63-getter|0|63-preInit
            // write pre-init user code here
            mbs_Tf = new TextField("MegaBytes", null, 32, TextField.ANY);//GEN-LINE:|63-getter|1|63-postInit
            // write post-init user code here
        }//GEN-BEGIN:|63-getter|2|
        return mbs_Tf;
    }
    //
//GEN-END:|63-getter|2|    //

    ////GEN-BEGIN:|64-getter|0|64-preInit
    /**
     * Returns an initiliazed instance of gbs_Tf component.
     * @return the initialized component instance
     */
    public TextField getGbs_Tf() {
        if (gbs_Tf == null) {//GEN-END:|64-getter|0|64-preInit
            // write pre-init user code here
            gbs_Tf = new TextField("GigaBytes", null, 32, TextField.ANY);//GEN-LINE:|64-getter|1|64-postInit
            // write post-init user code here
        }//GEN-BEGIN:|64-getter|2|
        return gbs_Tf;
    }
    //
//GEN-END:|64-getter|2|    //

    ////GEN-BEGIN:|65-getter|0|65-preInit
    /**
     * Returns an initiliazed instance of tbs_Tf component.
     * @return the initialized component instance
     */
    public TextField getTbs_Tf() {
        if (tbs_Tf == null) {//GEN-END:|65-getter|0|65-preInit
            // write pre-init user code here
            tbs_Tf = new TextField("TeraBytes", null, 32, TextField.ANY);//GEN-LINE:|65-getter|1|65-postInit
            // write post-init user code here
        }//GEN-BEGIN:|65-getter|2|
        return tbs_Tf;
    }
    //
//GEN-END:|65-getter|2|
    ////GEN-BEGIN:|66-getter|0|66-preInit
    /**
     * Returns an initiliazed instance of mm_Tf component.
     * @return the initialized component instance
     */
    public TextField getMm_Tf() {
        if (mm_Tf == null) {//GEN-END:|66-getter|0|66-preInit
            // write pre-init user code here
            mm_Tf = new TextField("Mili Meter", null, 32, TextField.ANY);//GEN-LINE:|66-getter|1|66-postInit
            // write post-init user code here
        }//GEN-BEGIN:|66-getter|2|
        return mm_Tf;
    }
    //
//GEN-END:|66-getter|2|    //

    ////GEN-BEGIN:|67-getter|0|67-preInit
    /**
     * Returns an initiliazed instance of mt_Tf component.
     * @return the initialized component instance
     */
    public TextField getMt_Tf() {
        if (mt_Tf == null) {//GEN-END:|67-getter|0|67-preInit
            // write pre-init user code here
            mt_Tf = new TextField("Meter", null, 32, TextField.ANY);//GEN-LINE:|67-getter|1|67-postInit
            // write post-init user code here
        }//GEN-BEGIN:|67-getter|2|
        return mt_Tf;
    }
    //
//GEN-END:|67-getter|2|    //

    ////GEN-BEGIN:|68-getter|0|68-preInit
    /**
     * Returns an initiliazed instance of cm_Tf component.
     * @return the initialized component instance
     */
    public TextField getCm_Tf() {
        if (cm_Tf == null) {//GEN-END:|68-getter|0|68-preInit
            // write pre-init user code here
            cm_Tf = new TextField("Centi Meter", null, 32, TextField.ANY);//GEN-LINE:|68-getter|1|68-postInit
            // write post-init user code here
        }//GEN-BEGIN:|68-getter|2|
        return cm_Tf;
    }
    //
//GEN-END:|68-getter|2|
    ////GEN-BEGIN:|69-getter|0|69-preInit
    /**
     * Returns an initiliazed instance of km_Tf component.
     * @return the initialized component instance
     */
    public TextField getKm_Tf() {
        if (km_Tf == null) {//GEN-END:|69-getter|0|69-preInit
            // write pre-init user code here
            km_Tf = new TextField("Kilo Meter", null, 32, TextField.ANY);//GEN-BEGIN:|69-getter|1|69-postInit
            km_Tf.setItemCommandListener(this);//GEN-END:|69-getter|1|69-postInit
            // write post-init user code here
        }//GEN-BEGIN:|69-getter|2|
        return km_Tf;
    }
    //
//GEN-END:|69-getter|2|
    ////GEN-BEGIN:|70-getter|0|70-preInit
    /**
     * Returns an initiliazed instance of Weight component.
     * @return the initialized component instance
     */
    public Command getWeight() {
        if (Weight == null) {//GEN-END:|70-getter|0|70-preInit
            // write pre-init user code here
            Weight = new Command("Weight", Command.ITEM, 0);//GEN-LINE:|70-getter|1|70-postInit
            // write post-init user code here
        }//GEN-BEGIN:|70-getter|2|
        return Weight;
    }
    //
//GEN-END:|70-getter|2|
    ////GEN-BEGIN:|72-getter|0|72-preInit
    /**
     * Returns an initiliazed instance of Weights component.
     * @return the initialized component instance
     */
    public Form getWeights() {
        if (Weights == null) {//GEN-END:|72-getter|0|72-preInit
            // write pre-init user code here
            Weights = new Form("Weights", new Item[] { getMg_Tf(), getGm_Tf(), getKg_Tf(), getTn_Tf() });//GEN-BEGIN:|72-getter|1|72-postInit
            Weights.setTicker(getO2Sol());
            Weights.addCommand(getBackCommand());
            Weights.addCommand(getOkCommand());
            Weights.addCommand(getCancelCommand());
            Weights.setCommandListener(this);//GEN-END:|72-getter|1|72-postInit
            // write post-init user code here
        }//GEN-BEGIN:|72-getter|2|
        return Weights;
    }
    //
//GEN-END:|72-getter|2|
    ////GEN-BEGIN:|78-getter|0|78-preInit
    /**
     * Returns an initiliazed instance of gm_Tf component.
     * @return the initialized component instance
     */
    public TextField getGm_Tf() {
        if (gm_Tf == null) {//GEN-END:|78-getter|0|78-preInit
            // write pre-init user code here
            gm_Tf = new TextField("Gram", null, 32, TextField.ANY);//GEN-LINE:|78-getter|1|78-postInit
            // write post-init user code here
        }//GEN-BEGIN:|78-getter|2|
        return gm_Tf;
    }
    //
//GEN-END:|78-getter|2|
    ////GEN-BEGIN:|79-getter|0|79-preInit
    /**
     * Returns an initiliazed instance of mg_Tf component.
     * @return the initialized component instance
     */
    public TextField getMg_Tf() {
        if (mg_Tf == null) {//GEN-END:|79-getter|0|79-preInit
            // write pre-init user code here
            mg_Tf = new TextField("Mili Gram", null, 32, TextField.ANY);//GEN-LINE:|79-getter|1|79-postInit
            // write post-init user code here
        }//GEN-BEGIN:|79-getter|2|
        return mg_Tf;
    }
    //
//GEN-END:|79-getter|2|
    ////GEN-BEGIN:|80-getter|0|80-preInit
    /**
     * Returns an initiliazed instance of kg_Tf component.
     * @return the initialized component instance
     */
    public TextField getKg_Tf() {
        if (kg_Tf == null) {//GEN-END:|80-getter|0|80-preInit
            // write pre-init user code here
            kg_Tf = new TextField("Kilo Gram", null, 32, TextField.ANY);//GEN-LINE:|80-getter|1|80-postInit
            // write post-init user code here
        }//GEN-BEGIN:|80-getter|2|
        return kg_Tf;
    }
    //
//GEN-END:|80-getter|2|
    ////GEN-BEGIN:|81-getter|0|81-preInit
    /**
     * Returns an initiliazed instance of tn_Tf component.
     * @return the initialized component instance
     */
    public TextField getTn_Tf() {
        if (tn_Tf == null) {//GEN-END:|81-getter|0|81-preInit
            // write pre-init user code here
            tn_Tf = new TextField("Tone", null, 32, TextField.ANY);//GEN-LINE:|81-getter|1|81-postInit
            // write post-init user code here
        }//GEN-BEGIN:|81-getter|2|
        return tn_Tf;
    }
    //
//GEN-END:|81-getter|2|
    ////GEN-BEGIN:|97-getter|0|97-preInit
    /**
     * Returns an initiliazed instance of Time component.
     * @return the initialized component instance
     */
    public Command getTime() {
        if (Time == null) {//GEN-END:|97-getter|0|97-preInit
            // write pre-init user code here
            Time = new Command("Time", Command.ITEM, 0);//GEN-LINE:|97-getter|1|97-postInit
            // write post-init user code here
        }//GEN-BEGIN:|97-getter|2|
        return Time;
    }
    //
//GEN-END:|97-getter|2|    //

    ////GEN-BEGIN:|99-getter|0|99-preInit
    /**
     * Returns an initiliazed instance of Times component.
     * @return the initialized component instance
     */
    public Form getTimes() {
        if (Times == null) {//GEN-END:|99-getter|0|99-preInit
            // write pre-init user code here
            Times = new Form("Times", new Item[] { getMili_Tf(), getSeconds_Tf(), getMinutes_Tf(), getHours_Tf() });//GEN-BEGIN:|99-getter|1|99-postInit
            Times.setTicker(getO2Sol());
            Times.addCommand(getBackCommand());
            Times.addCommand(getOkCommand());
            Times.addCommand(getCancelCommand());
            Times.setCommandListener(this);//GEN-END:|99-getter|1|99-postInit
            // write post-init user code here
        }//GEN-BEGIN:|99-getter|2|
        return Times;
    }
    //
//GEN-END:|99-getter|2|    //

    ////GEN-BEGIN:|102-getter|0|102-preInit
    /**
     * Returns an initiliazed instance of minutes_Tf component.
     * @return the initialized component instance
     */
    public TextField getMinutes_Tf() {
        if (minutes_Tf == null) {//GEN-END:|102-getter|0|102-preInit
            // write pre-init user code here
            minutes_Tf = new TextField("Minutes", null, 32, TextField.ANY);//GEN-LINE:|102-getter|1|102-postInit
            // write post-init user code here
        }//GEN-BEGIN:|102-getter|2|
        return minutes_Tf;
    }
    //
//GEN-END:|102-getter|2|    //

    ////GEN-BEGIN:|103-getter|0|103-preInit
    /**
     * Returns an initiliazed instance of mili_Tf component.
     * @return the initialized component instance
     */
    public TextField getMili_Tf() {
        if (mili_Tf == null) {//GEN-END:|103-getter|0|103-preInit
            // write pre-init user code here
            mili_Tf = new TextField("Mili Seconds", null, 32, TextField.ANY);//GEN-LINE:|103-getter|1|103-postInit
            // write post-init user code here
        }//GEN-BEGIN:|103-getter|2|
        return mili_Tf;
    }
    //
//GEN-END:|103-getter|2|    //

    ////GEN-BEGIN:|104-getter|0|104-preInit
    /**
     * Returns an initiliazed instance of seconds_Tf component.
     * @return the initialized component instance
     */
    public TextField getSeconds_Tf() {
        if (seconds_Tf == null) {//GEN-END:|104-getter|0|104-preInit
            // write pre-init user code here
            seconds_Tf = new TextField("Seconds", null, 32, TextField.ANY);//GEN-LINE:|104-getter|1|104-postInit
            // write post-init user code here
        }//GEN-BEGIN:|104-getter|2|
        return seconds_Tf;
    }
    //
//GEN-END:|104-getter|2|    //

    ////GEN-BEGIN:|105-getter|0|105-preInit
    /**
     * Returns an initiliazed instance of hours_Tf component.
     * @return the initialized component instance
     */
    public TextField getHours_Tf() {
        if (hours_Tf == null) {//GEN-END:|105-getter|0|105-preInit
            // write pre-init user code here
            hours_Tf = new TextField("Hours", null, 32, TextField.ANY);//GEN-LINE:|105-getter|1|105-postInit
            // write post-init user code here
        }//GEN-BEGIN:|105-getter|2|
        return hours_Tf;
    }
    //
//GEN-END:|105-getter|2|
    ////GEN-BEGIN:|107-getter|0|107-preInit
    /**
     * Returns an initiliazed instance of Day component.
     * @return the initialized component instance
     */
    public Command getDay() {
        if (Day == null) {//GEN-END:|107-getter|0|107-preInit
            // write pre-init user code here
            Day = new Command("Day", Command.ITEM, 0);//GEN-LINE:|107-getter|1|107-postInit
            // write post-init user code here
        }//GEN-BEGIN:|107-getter|2|
        return Day;
    }
    //
//GEN-END:|107-getter|2|
    ////GEN-BEGIN:|109-getter|0|109-preInit
    /**
     * Returns an initiliazed instance of Days component.
     * @return the initialized component instance
     */
    public Form getDays() {
        if (Days == null) {//GEN-END:|109-getter|0|109-preInit
            // write pre-init user code here
            Days = new Form("Days", new Item[] { getDays_Tf(), getWeeks_Tf(), getMonths_Tf(), getYears_Tf() });//GEN-BEGIN:|109-getter|1|109-postInit
            Days.setTicker(getO2Sol());
            Days.addCommand(getBackCommand());
            Days.addCommand(getOkCommand());
            Days.addCommand(getCancelCommand());
            Days.setCommandListener(this);//GEN-END:|109-getter|1|109-postInit
            // write post-init user code here
        }//GEN-BEGIN:|109-getter|2|
        return Days;
    }
    //
//GEN-END:|109-getter|2|
    ////GEN-BEGIN:|110-getter|0|110-preInit
    /**
     * Returns an initiliazed instance of days_Tf component.
     * @return the initialized component instance
     */
    public TextField getDays_Tf() {
        if (days_Tf == null) {//GEN-END:|110-getter|0|110-preInit
            // write pre-init user code here
            days_Tf = new TextField("Days", null, 32, TextField.ANY);//GEN-BEGIN:|110-getter|1|110-postInit
            days_Tf.setLayout(ImageItem.LAYOUT_DEFAULT);//GEN-END:|110-getter|1|110-postInit
            // write post-init user code here
        }//GEN-BEGIN:|110-getter|2|
        return days_Tf;
    }
    //
//GEN-END:|110-getter|2|
    ////GEN-BEGIN:|111-getter|0|111-preInit
    /**
     * Returns an initiliazed instance of weeks_Tf component.
     * @return the initialized component instance
     */
    public TextField getWeeks_Tf() {
        if (weeks_Tf == null) {//GEN-END:|111-getter|0|111-preInit
            // write pre-init user code here
            weeks_Tf = new TextField("Weeks", null, 32, TextField.ANY);//GEN-LINE:|111-getter|1|111-postInit
            // write post-init user code here
        }//GEN-BEGIN:|111-getter|2|
        return weeks_Tf;
    }
    //
//GEN-END:|111-getter|2|    //

    ////GEN-BEGIN:|112-getter|0|112-preInit
    /**
     * Returns an initiliazed instance of months_Tf component.
     * @return the initialized component instance
     */
    public TextField getMonths_Tf() {
        if (months_Tf == null) {//GEN-END:|112-getter|0|112-preInit
            // write pre-init user code here
            months_Tf = new TextField("Months", null, 32, TextField.ANY);//GEN-LINE:|112-getter|1|112-postInit
            // write post-init user code here
        }//GEN-BEGIN:|112-getter|2|
        return months_Tf;
    }
    //
//GEN-END:|112-getter|2|    //

    ////GEN-BEGIN:|113-getter|0|113-preInit
    /**
     * Returns an initiliazed instance of years_Tf component.
     * @return the initialized component instance
     */
    public TextField getYears_Tf() {
        if (years_Tf == null) {//GEN-END:|113-getter|0|113-preInit
            // write pre-init user code here
            years_Tf = new TextField("Years", null, 32, TextField.ANY);//GEN-LINE:|113-getter|1|113-postInit
            // write post-init user code here
        }//GEN-BEGIN:|113-getter|2|
        return years_Tf;
    }
    //
//GEN-END:|113-getter|2|
    ////GEN-BEGIN:|114-getter|0|114-preInit
    /**
     * Returns an initiliazed instance of o2Sol component.
     * @return the initialized component instance
     */
    public Ticker getO2Sol() {
        if (o2Sol == null) {//GEN-END:|114-getter|0|114-preInit
            // write pre-init user code here
            o2Sol = new Ticker("O2 Solutions [RK].");//GEN-LINE:|114-getter|1|114-postInit
            // write post-init user code here
        }//GEN-BEGIN:|114-getter|2|
        return o2Sol;
    }
    //
//GEN-END:|114-getter|2|
    ////GEN-BEGIN:|122-getter|0|122-preInit
    /**
     * Returns an initiliazed instance of cancelCommand component.
     * @return the initialized component instance
     */
    public Command getCancelCommand() {
        if (cancelCommand == null) {//GEN-END:|122-getter|0|122-preInit
            // write pre-init user code here
            cancelCommand = new Command("Clear", Command.CANCEL, 0);//GEN-LINE:|122-getter|1|122-postInit
            // write post-init user code here
        }//GEN-BEGIN:|122-getter|2|
        return cancelCommand;
    }
    //
//GEN-END:|122-getter|2|
    ////GEN-BEGIN:|125-getter|0|125-preInit
    /**
     * Returns an initiliazed instance of cancelCommand1 component.
     * @return the initialized component instance
     */
    public Command getCancelCommand1() {
        if (cancelCommand1 == null) {//GEN-END:|125-getter|0|125-preInit
            // write pre-init user code here
            cancelCommand1 = new Command("Cancel", Command.CANCEL, 0);//GEN-LINE:|125-getter|1|125-postInit
            // write post-init user code here
        }//GEN-BEGIN:|125-getter|2|
        return cancelCommand1;
    }
    //
//GEN-END:|125-getter|2|
    ////GEN-BEGIN:|134-getter|0|134-preInit
    /**
     * Returns an initiliazed instance of screenCommand component.
     * @return the initialized component instance
     */
    public Command getScreenCommand() {
        if (screenCommand == null) {//GEN-END:|134-getter|0|134-preInit
            // write pre-init user code here
            screenCommand = new Command("Screen", Command.SCREEN, 0);//GEN-LINE:|134-getter|1|134-postInit
            // write post-init user code here
        }//GEN-BEGIN:|134-getter|2|
        return screenCommand;
    }
    //
//GEN-END:|134-getter|2|
    ////GEN-BEGIN:|136-getter|0|136-preInit
    /**
     * Returns an initiliazed instance of itemCommand1 component.
     * @return the initialized component instance
     */
    public Command getItemCommand1() {
        if (itemCommand1 == null) {//GEN-END:|136-getter|0|136-preInit
            // write pre-init user code here
            itemCommand1 = new Command("Item", Command.ITEM, 0);//GEN-LINE:|136-getter|1|136-postInit
            // write post-init user code here
        }//GEN-BEGIN:|136-getter|2|
        return itemCommand1;
    }
    //
//GEN-END:|136-getter|2|
    ////GEN-BEGIN:|143-getter|0|143-preInit
    /**
     * Returns an initiliazed instance of okCommand1 component.
     * @return the initialized component instance
     */
    public Command getOkCommand1() {
        if (okCommand1 == null) {//GEN-END:|143-getter|0|143-preInit
            // write pre-init user code here
            okCommand1 = new Command("Ok", Command.OK, 0);//GEN-LINE:|143-getter|1|143-postInit
            // write post-init user code here
        }//GEN-BEGIN:|143-getter|2|
        return okCommand1;
    }
    //
//GEN-END:|143-getter|2|
    ////GEN-BEGIN:|145-getter|0|145-preInit
    /**
     * Returns an initiliazed instance of Distance component.
     * @return the initialized component instance
     */
    public Command getDistance() {
        if (Distance == null) {//GEN-END:|145-getter|0|145-preInit
            // write pre-init user code here
            Distance = new Command("Distance", Command.ITEM, 0);//GEN-LINE:|145-getter|1|145-postInit
            // write post-init user code here
        }//GEN-BEGIN:|145-getter|2|
        return Distance;
    }
    //
//GEN-END:|145-getter|2|
    ////GEN-BEGIN:|17-itemCommandAction|0|17-preItemCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular item.
     * @param command the Command that was invoked
     * @param displayable the Item where the command was invoked
     */
    public void commandAction(Command command, Item item) {//GEN-END:|17-itemCommandAction|0|17-preItemCommandAction
        // write pre-action user code here
        if (item == imageItem) {//GEN-BEGIN:|17-itemCommandAction|1|28-preAction
            if (command == ConverterImage) {//GEN-END:|17-itemCommandAction|1|28-preAction
                // write pre-action user code here
//GEN-LINE:|17-itemCommandAction|2|28-postAction
                // write post-action user code here
            }//GEN-BEGIN:|17-itemCommandAction|3|17-postItemCommandAction
        }//GEN-END:|17-itemCommandAction|3|17-postItemCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|17-itemCommandAction|4|
    //
//GEN-END:|17-itemCommandAction|4|




    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay() {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable(null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet();
        } else {
            initialize();
            startMIDlet();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }
}