/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.netbeans.lab.ui;

import java.util.Vector;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.m2g.SVGImage;
import org.netbeans.lab.data.Employee;
import org.netbeans.lab.data.EmployeeData;
import org.netbeans.microedition.svg.DataListener;
import org.netbeans.microedition.svg.SVGActionListener;
import org.netbeans.microedition.svg.SVGButton;
import org.netbeans.microedition.svg.SVGButtonGroup;
import org.netbeans.microedition.svg.SVGComponent;
import org.netbeans.microedition.svg.SVGForm;
import org.netbeans.microedition.svg.SVGLabel;
import org.netbeans.microedition.svg.SVGList;
import org.netbeans.microedition.svg.SVGRadioButton;
import org.netbeans.microedition.svg.SVGSpinner;
import org.netbeans.microedition.svg.SVGTextField;

public class VisualMidlet extends MIDlet {

    private boolean midletPaused = false;
    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private SVGForm employeeList;
    private SVGButton back;
    private SVGButton select;
    private SVGList svgList;
    private SVGForm employeeForm;
    private SVGTextField svgTextFieldLastName;
    private SVGLabel svgLabel2;
    private SVGButtonGroup svgButtonGroup;
    private SVGRadioButton svgRadioButton;
    private SVGButton back1;
    private SVGLabel svgLabel;
    private SVGTextField svgTextFieldFirstName;
    private SVGLabel svgLabel1;
    private SVGButton next;
    private SVGLabel svgLabel3;
    private SVGRadioButton svgRadioButton1;
    private SVGButton previous;
    private SVGSpinner svgSpinner;
    private SVGImage svgImage;
    private SVGImage svgImage1;
    private SVGImage svgImage2;
    private SVGImage svgImage4;
    //</editor-fold>//GEN-END:|fields|0|
    private int index = 0;

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

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|
    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//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 <code>startMIDlet</code> 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|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//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, getEmployeeList().getSvgCanvas());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//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|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> 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 <code>null</code>, then <code>nextDisplayable</code> 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|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: employeeList ">//GEN-BEGIN:|14-getter|0|14-preInit
    /**
     * Returns an initiliazed instance of employeeList component.
     * @return the initialized component instance
     */
    public SVGForm getEmployeeList() {
        if (employeeList == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
            employeeList = new SVGForm(getSvgImage(), getDisplay());//GEN-BEGIN:|14-getter|1|14-postInit
            employeeList.setTitle("svgForm");
            employeeList.add(getBack());
            employeeList.add(getSelect());
            employeeList.add(getSvgList());//GEN-END:|14-getter|1|14-postInit

        }//GEN-BEGIN:|14-getter|2|
        return employeeList;
    }
    //</editor-fold>//GEN-END:|14-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgImage2 ">//GEN-BEGIN:|53-getter|0|53-preInit
    /**
     * Returns an initiliazed instance of svgImage2 component.
     * @return the initialized component instance
     */
    public SVGImage getSvgImage2() {
        if (svgImage2 == null) {//GEN-END:|53-getter|0|53-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|53-getter|1|53-@java.io.IOException
                svgImage2 = (SVGImage) SVGImage.createImage(getClass().getResourceAsStream("/org/netbeans/lab/ui/newImage.svg"), null);
            } catch (java.io.IOException e) {//GEN-END:|53-getter|1|53-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|53-getter|2|53-postInit
            // write post-init user code here
        }//GEN-BEGIN:|53-getter|3|
        return svgImage2;
    }
    //</editor-fold>//GEN-END:|53-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: employeeForm ">//GEN-BEGIN:|86-getter|0|86-preInit
    /**
     * Returns an initiliazed instance of employeeForm component.
     * @return the initialized component instance
     */
    public SVGForm getEmployeeForm() {
        if (employeeForm == null) {//GEN-END:|86-getter|0|86-preInit
            // write pre-init user code here
            employeeForm = new SVGForm(getSvgImage1(), getDisplay());//GEN-BEGIN:|86-getter|1|86-postInit
            employeeForm.setTitle("svgForm");
            employeeForm.add(getBack1());
            employeeForm.add(getSvgLabel());
            employeeForm.add(getSvgTextFieldFirstName());
            employeeForm.add(getSvgLabel1());
            employeeForm.add(getSvgTextFieldLastName());
            employeeForm.add(getSvgLabel2());
            employeeForm.add(getSvgRadioButton());
            getSvgButtonGroup().add(getSvgRadioButton());
            employeeForm.add(getSvgRadioButton1());
            getSvgButtonGroup().add(getSvgRadioButton1());
            employeeForm.add(getSvgLabel3());
            employeeForm.add(getSvgSpinner());
            employeeForm.add(getPrevious());
            employeeForm.add(getNext());//GEN-END:|86-getter|1|86-postInit
            // write post-init user code here
        }//GEN-BEGIN:|86-getter|2|
        return employeeForm;
    }
    //</editor-fold>//GEN-END:|86-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgImage4 ">//GEN-BEGIN:|87-getter|0|87-preInit
    /**
     * Returns an initiliazed instance of svgImage4 component.
     * @return the initialized component instance
     */
    public SVGImage getSvgImage4() {
        if (svgImage4 == null) {//GEN-END:|87-getter|0|87-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|87-getter|1|87-@java.io.IOException
                svgImage4 = (SVGImage) SVGImage.createImage(getClass().getResourceAsStream("/org/netbeans/lab/ui/newImage1.svg"), null);
            } catch (java.io.IOException e) {//GEN-END:|87-getter|1|87-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|87-getter|2|87-postInit
            // write post-init user code here
        }//GEN-BEGIN:|87-getter|3|
        return svgImage4;
    }
    //</editor-fold>//GEN-END:|87-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: nextMethod ">//GEN-BEGIN:|128-entry|0|129-preAction
    /**
     * Performs an action assigned to the nextMethod entry-point.
     */
    public void nextMethod() {//GEN-END:|128-entry|0|129-preAction
        //Move to the next Employee record
        if (index < EmployeeData.getData().size() - 1) {
            //Update index.
            index++;
        }
        //Update UI - empolyee form
        updateEmpoyeeFormUI();
        //Go back to employeeForm
        switchDisplayable(null, getEmployeeForm().getSvgCanvas());//GEN-LINE:|128-entry|1|129-postAction

    }//GEN-BEGIN:|128-entry|2|
    //</editor-fold>//GEN-END:|128-entry|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: previousMethod ">//GEN-BEGIN:|132-entry|0|133-preAction
    /**
     * Performs an action assigned to the previousMethod entry-point.
     */
    public void previousMethod() {//GEN-END:|132-entry|0|133-preAction
        //Move to the previous Employee record
        if (index > 0) {
            //Update index
            index--;
        }
        //Update UI
        updateEmpoyeeFormUI();
        //Go back to employeeForm
        switchDisplayable(null, getEmployeeForm().getSvgCanvas());//GEN-LINE:|132-entry|1|133-postAction
        // write post-action user code here
    }//GEN-BEGIN:|132-entry|2|
    //</editor-fold>//GEN-END:|132-entry|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: back ">//GEN-BEGIN:|137-getter|0|137-preInit
    /**
     * Returns an initiliazed instance of back component.
     * @return the initialized component instance
     */
    public SVGButton getBack() {
        if (back == null) {//GEN-END:|137-getter|0|137-preInit
            // write pre-init user code here
            back = new SVGButton(getEmployeeList(), "button_0");//GEN-BEGIN:|137-getter|1|137beforeSwitch
            back.addActionListener(new SVGActionListener() {
                public void actionPerformed(SVGComponent svgComponent) {//GEN-END:|137-getter|1|137beforeSwitch
                    //Some action before exit Midlet
                    exitMIDlet();//GEN-BEGIN:|137-getter|2|137-postInit
                }
            });//GEN-END:|137-getter|2|137-postInit
            // write post-init user code here
        }//GEN-BEGIN:|137-getter|3|
        return back;
    }
    //</editor-fold>//GEN-END:|137-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: select ">//GEN-BEGIN:|139-getter|0|139-preInit
    /**
     * Returns an initiliazed instance of select component.
     * @return the initialized component instance
     */
    public SVGButton getSelect() {
        if (select == null) {//GEN-END:|139-getter|0|139-preInit
            // write pre-init user code here
            select = new SVGButton(getEmployeeList(), "button_1");//GEN-BEGIN:|139-getter|1|139beforeSwitch
            select.addActionListener(new SVGActionListener() {
                public void actionPerformed(SVGComponent svgComponent) {//GEN-END:|139-getter|1|139beforeSwitch
                    //Updating global index
                    index = getSvgList().getSelectionModel().getSelectedIndex();
                    //Updating UI after selection has been made
                    updateEmpoyeeFormUI();
                    //Switching to the employeeForm
                    switchDisplayable(null, getEmployeeForm().getSvgCanvas());//GEN-LINE:|139-getter|2|139afterSwitch
                    //Some action after switch
                }//GEN-BEGIN:|139-getter|3|139-postInit
            });//GEN-END:|139-getter|3|139-postInit
            // write post-init user code here
        }//GEN-BEGIN:|139-getter|4|
        return select;
    }
    //</editor-fold>//GEN-END:|139-getter|4|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgList ">//GEN-BEGIN:|141-getter|0|141-preInit
    /**
     * Returns an initiliazed instance of svgList component.
     * @return the initialized component instance
     */
    public SVGList getSvgList() {
        if (svgList == null) {//GEN-END:|141-getter|0|141-preInit
            // write pre-init user code here
            //Creating new SVGList
            svgList = new SVGList(getEmployeeList(), "list_0");//GEN-LINE:|141-getter|1|141-postInit
            //Creating and adding new SVGListModel as anonymous class. Implementation of ListModel
            svgList.setModel(new SVGList.ListModel() {
                //Getting contact data as Vector from class EmployeeData
                Vector data = EmployeeData.getData();

                /**
                 * Method returns returns combination of strings: First Name + Last Name
                 * @return Employee name as String
                 */
                public Object getElementAt(int index) {
                    //Getting First Name String
                    String firstName = ((Employee) data.elementAt(index)).getFirstName();
                    //Getting Last Name String
                    String lastName = ((Employee) data.elementAt(index)).getLastName();

                    return firstName + " " + lastName;
                }

                /**
                 * Number of employees
                 * @return number of employees
                 */
                public int getSize() {
                    return data.size();
                }

                // Not used
                public void addDataListener(DataListener listener) {}
                // Not used
                public void removeDataListener(DataListener listener) {}
            });
        }//GEN-BEGIN:|141-getter|2|
        return svgList;
    }
    //</editor-fold>//GEN-END:|141-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgImage ">//GEN-BEGIN:|136-getter|0|136-preInit
    /**
     * Returns an initiliazed instance of svgImage component.
     * @return the initialized component instance
     */
    public SVGImage getSvgImage() {
        if (svgImage == null) {//GEN-END:|136-getter|0|136-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|136-getter|1|136-@java.io.IOException
                svgImage = (SVGImage) SVGImage.createImage(getClass().getResourceAsStream("/org/netbeans/lab/ui/employeeList.svg"), null);
            } catch (java.io.IOException e) {//GEN-END:|136-getter|1|136-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|136-getter|2|136-postInit
            // write post-init user code here
        }//GEN-BEGIN:|136-getter|3|
        return svgImage;
    }
    //</editor-fold>//GEN-END:|136-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: back1 ">//GEN-BEGIN:|145-getter|0|145-preInit
    /**
     * Returns an initiliazed instance of back1 component.
     * @return the initialized component instance
     */
    public SVGButton getBack1() {
        if (back1 == null) {//GEN-END:|145-getter|0|145-preInit
            // write pre-init user code here
            back1 = new SVGButton(getEmployeeForm(), "button_0");//GEN-BEGIN:|145-getter|1|145beforeSwitch
            back1.addActionListener(new SVGActionListener() {
                public void actionPerformed(SVGComponent svgComponent) {//GEN-END:|145-getter|1|145beforeSwitch
                    //Some action before switch
                    switchDisplayable(null, getEmployeeList().getSvgCanvas());//GEN-LINE:|145-getter|2|145afterSwitch
                    //Some action after switch
                }//GEN-BEGIN:|145-getter|3|145-postInit
            });//GEN-END:|145-getter|3|145-postInit
            // write post-init user code here
        }//GEN-BEGIN:|145-getter|4|
        return back1;
    }
    //</editor-fold>//GEN-END:|145-getter|4|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgLabel ">//GEN-BEGIN:|147-getter|0|147-preInit
    /**
     * Returns an initiliazed instance of svgLabel component.
     * @return the initialized component instance
     */
    public SVGLabel getSvgLabel() {
        if (svgLabel == null) {//GEN-END:|147-getter|0|147-preInit
            // write pre-init user code here
            svgLabel = new SVGLabel(getEmployeeForm(), "label_0");//GEN-BEGIN:|147-getter|1|147-postInit
            svgLabel.setText("First Name");//GEN-END:|147-getter|1|147-postInit
            // write post-init user code here
        }//GEN-BEGIN:|147-getter|2|
        return svgLabel;
    }
    //</editor-fold>//GEN-END:|147-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgTextFieldFirstName ">//GEN-BEGIN:|149-getter|0|149-preInit
    /**
     * Returns an initiliazed instance of svgTextFieldFirstName component.
     * @return the initialized component instance
     */
    public SVGTextField getSvgTextFieldFirstName() {
        if (svgTextFieldFirstName == null) {//GEN-END:|149-getter|0|149-preInit
            // write pre-init user code here
            svgTextFieldFirstName = new SVGTextField(getEmployeeForm(), "textfield_0");//GEN-LINE:|149-getter|1|149-postInit
            // write post-init user code here
        }//GEN-BEGIN:|149-getter|2|
        return svgTextFieldFirstName;
    }
    //</editor-fold>//GEN-END:|149-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgLabel1 ">//GEN-BEGIN:|151-getter|0|151-preInit
    /**
     * Returns an initiliazed instance of svgLabel1 component.
     * @return the initialized component instance
     */
    public SVGLabel getSvgLabel1() {
        if (svgLabel1 == null) {//GEN-END:|151-getter|0|151-preInit
            // write pre-init user code here
            svgLabel1 = new SVGLabel(getEmployeeForm(), "label_1");//GEN-BEGIN:|151-getter|1|151-postInit
            svgLabel1.setText("Last Name");//GEN-END:|151-getter|1|151-postInit
            // write post-init user code here
        }//GEN-BEGIN:|151-getter|2|
        return svgLabel1;
    }
    //</editor-fold>//GEN-END:|151-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgTextFieldLastName ">//GEN-BEGIN:|153-getter|0|153-preInit
    /**
     * Returns an initiliazed instance of svgTextFieldLastName component.
     * @return the initialized component instance
     */
    public SVGTextField getSvgTextFieldLastName() {
        if (svgTextFieldLastName == null) {//GEN-END:|153-getter|0|153-preInit
            // write pre-init user code here
            svgTextFieldLastName = new SVGTextField(getEmployeeForm(), "textfield_1");//GEN-LINE:|153-getter|1|153-postInit
            // write post-init user code here
        }//GEN-BEGIN:|153-getter|2|
        return svgTextFieldLastName;
    }
    //</editor-fold>//GEN-END:|153-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgLabel2 ">//GEN-BEGIN:|155-getter|0|155-preInit
    /**
     * Returns an initiliazed instance of svgLabel2 component.
     * @return the initialized component instance
     */
    public SVGLabel getSvgLabel2() {
        if (svgLabel2 == null) {//GEN-END:|155-getter|0|155-preInit
            // write pre-init user code here
            svgLabel2 = new SVGLabel(getEmployeeForm(), "label_2");//GEN-BEGIN:|155-getter|1|155-postInit
            svgLabel2.setText("Gender");//GEN-END:|155-getter|1|155-postInit
            // write post-init user code here
        }//GEN-BEGIN:|155-getter|2|
        return svgLabel2;
    }
    //</editor-fold>//GEN-END:|155-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgButtonGroup ">//GEN-BEGIN:|157-getter|0|157-preInit
    /**
     * Returns an initiliazed instance of svgButtonGroup component.
     * @return the initialized component instance
     */
    public SVGButtonGroup getSvgButtonGroup() {
        if (svgButtonGroup == null) {//GEN-END:|157-getter|0|157-preInit
            // write pre-init user code here
            svgButtonGroup = new SVGButtonGroup();//GEN-LINE:|157-getter|1|157-postInit
            // write post-init user code here
        }//GEN-BEGIN:|157-getter|2|
        return svgButtonGroup;
    }
    //</editor-fold>//GEN-END:|157-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgRadioButton ">//GEN-BEGIN:|158-getter|0|158-preInit
    /**
     * Returns an initiliazed instance of svgRadioButton component.
     * @return the initialized component instance
     */
    public SVGRadioButton getSvgRadioButton() {
        if (svgRadioButton == null) {//GEN-END:|158-getter|0|158-preInit
            // write pre-init user code here
            svgRadioButton = new SVGRadioButton(getEmployeeForm(), "radiobutton_0");//GEN-BEGIN:|158-getter|1|158-postInit
            svgRadioButton.setText("Male");//GEN-END:|158-getter|1|158-postInit
            // write post-init user code here
        }//GEN-BEGIN:|158-getter|2|
        return svgRadioButton;
    }
    //</editor-fold>//GEN-END:|158-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgRadioButton1 ">//GEN-BEGIN:|160-getter|0|160-preInit
    /**
     * Returns an initiliazed instance of svgRadioButton1 component.
     * @return the initialized component instance
     */
    public SVGRadioButton getSvgRadioButton1() {
        if (svgRadioButton1 == null) {//GEN-END:|160-getter|0|160-preInit
            // write pre-init user code here
            svgRadioButton1 = new SVGRadioButton(getEmployeeForm(), "radiobutton_1");//GEN-BEGIN:|160-getter|1|160-postInit
            svgRadioButton1.setText("Female");//GEN-END:|160-getter|1|160-postInit
            // write post-init user code here
        }//GEN-BEGIN:|160-getter|2|
        return svgRadioButton1;
    }
    //</editor-fold>//GEN-END:|160-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgLabel3 ">//GEN-BEGIN:|162-getter|0|162-preInit
    /**
     * Returns an initiliazed instance of svgLabel3 component.
     * @return the initialized component instance
     */
    public SVGLabel getSvgLabel3() {
        if (svgLabel3 == null) {//GEN-END:|162-getter|0|162-preInit
            // write pre-init user code here
            svgLabel3 = new SVGLabel(getEmployeeForm(), "label_3");//GEN-BEGIN:|162-getter|1|162-postInit
            svgLabel3.setText("Age");//GEN-END:|162-getter|1|162-postInit
            // write post-init user code here
        }//GEN-BEGIN:|162-getter|2|
        return svgLabel3;
    }
    //</editor-fold>//GEN-END:|162-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgSpinner ">//GEN-BEGIN:|164-getter|0|164-preInit
    /**
     * Returns an initiliazed instance of svgSpinner component.
     * @return the initialized component instance
     */
    public SVGSpinner getSvgSpinner() {
        if (svgSpinner == null) {//GEN-END:|164-getter|0|164-preInit
            // write pre-init user code here
            svgSpinner = new SVGSpinner(getEmployeeForm(), "spinner_0");//GEN-LINE:|164-getter|1|164-postInit
            // write post-init user code here
        }//GEN-BEGIN:|164-getter|2|
        return svgSpinner;
    }
    //</editor-fold>//GEN-END:|164-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: previous ">//GEN-BEGIN:|166-getter|0|166-preInit
    /**
     * Returns an initiliazed instance of previous component.
     * @return the initialized component instance
     */
    public SVGButton getPrevious() {
        if (previous == null) {//GEN-END:|166-getter|0|166-preInit
            // write pre-init user code here
            previous = new SVGButton(getEmployeeForm(), "button_3");//GEN-BEGIN:|166-getter|1|166beforeSwitch
            previous.addActionListener(new SVGActionListener() {
                public void actionPerformed(SVGComponent svgComponent) {//GEN-END:|166-getter|1|166beforeSwitch
                    //Some action before switch
                    previousMethod();//GEN-LINE:|166-getter|2|166afterSwitch
                    //Some action after switch
                }//GEN-BEGIN:|166-getter|3|166-postInit
            });//GEN-END:|166-getter|3|166-postInit
            // write post-init user code here
        }//GEN-BEGIN:|166-getter|4|
        return previous;
    }
    //</editor-fold>//GEN-END:|166-getter|4|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: next ">//GEN-BEGIN:|168-getter|0|168-preInit
    /**
     * Returns an initiliazed instance of next component.
     * @return the initialized component instance
     */
    public SVGButton getNext() {
        if (next == null) {//GEN-END:|168-getter|0|168-preInit
            // write pre-init user code here
            next = new SVGButton(getEmployeeForm(), "button_2");//GEN-BEGIN:|168-getter|1|168beforeSwitch
            next.addActionListener(new SVGActionListener() {
                public void actionPerformed(SVGComponent svgComponent) {//GEN-END:|168-getter|1|168beforeSwitch
                    //Some action before switch
                    nextMethod();//GEN-LINE:|168-getter|2|168afterSwitch
                    //Some action after switch
                }//GEN-BEGIN:|168-getter|3|168-postInit
            });//GEN-END:|168-getter|3|168-postInit
            // write post-init user code here
        }//GEN-BEGIN:|168-getter|4|
        return next;
    }
    //</editor-fold>//GEN-END:|168-getter|4|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgImage1 ">//GEN-BEGIN:|144-getter|0|144-preInit
    /**
     * Returns an initiliazed instance of svgImage1 component.
     * @return the initialized component instance
     */
    public SVGImage getSvgImage1() {
        if (svgImage1 == null) {//GEN-END:|144-getter|0|144-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|144-getter|1|144-@java.io.IOException
                svgImage1 = (SVGImage) SVGImage.createImage(getClass().getResourceAsStream("/org/netbeans/lab/ui/employeeForm.svg"), null);
            } catch (java.io.IOException e) {//GEN-END:|144-getter|1|144-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|144-getter|2|144-postInit
            // write post-init user code here
        }//GEN-BEGIN:|144-getter|3|
        return svgImage1;
    }
    //</editor-fold>//GEN-END:|144-getter|3|

    /**
     * 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) {
    }

    /**
     * Method resposible for populating employee UI form with information about
     * employees.
     */
    private void updateEmpoyeeFormUI() {
        //Getting currently selected employee
        final Employee employee = (Employee) EmployeeData.getData().elementAt(index);
        //Setting First Name
        getSvgTextFieldFirstName().setText(employee.getFirstName());
        //Setting Last Name
        getSvgTextFieldLastName().setText(employee.getLastName());
         //Setting Gender
        if (employee.getGender()) {
            getSvgRadioButton().setSelected(false);
            getSvgRadioButton1().setSelected(true);
        } else {
            getSvgRadioButton().setSelected(true);
            getSvgRadioButton1().setSelected(false);
        }
        //Setting age
        getSvgSpinner().getModel().setValue(new Integer(employee.getAge()));
    }
}
