Thursday, May 30, 2013

Java JList scroll to selected item

Very funny, just one line of code make it fine.


String[] data = {"one", "two", "three", "four", /* AND A LOT MORE */};
JList dataList = new JList(data);
JScrollPane scrollPane = new JScrollPane(dataList);

/* And scroll to selected index */
dataList.ensureIndexIsVisible(dataList.getSelectedIndex());

JTable Scrolling to a specified row index java


public static void scrollToVisible(JTable table, int rowIndex, int vColIndex) {
        if (!(table.getParent() instanceof JViewport)) {
            return;
        }
        JViewport viewport = (JViewport)table.getParent();

        // This rectangle is relative to the table where the
        // northwest corner of cell (0,0) is always (0,0).
        Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);

        // The location of the viewport relative to the table
        Point pt = viewport.getViewPosition();

        // Translate the cell location so that it is relative
        // to the view, assuming the northwest corner of the
        // view is (0,0)
        rect.setLocation(rect.x-pt.x, rect.y-pt.y);

        table.scrollRectToVisible(rect);       
}

A Simple JTable Example Java Code Program


import java.awt.Color;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JComboBox;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import javax.swing.DefaultCellEditor;

public class TableExample {

    //Note: Typically the main method will be in a
    //separate class. As this is a simple one class
    //example it's all in the one class.
    public static void main(String[] args) {

        //Use the event dispatch thread for Swing components
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {

                new TableExample();
            }
        });

    }

    public TableExample() {
        JFrame guiFrame = new JFrame();

        //make sure the program exits when the frame closes
        guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        guiFrame.setTitle("Creating a Table Example");
        guiFrame.setSize(700, 200);

        //This will center the JFrame in the middle of the screen
        guiFrame.setLocationRelativeTo(null);

        //Create the JTable using the ExampleTableModel implementing 
        //the AbstractTableModel abstract class
        JTable table = new JTable(new ExampleTableModel());

        //Set the column sorting functionality on
        table.setAutoCreateRowSorter(true);

        //Uncomment the next line if you want to turn the grid lines off
        //  table.setShowGrid(false);

        //Change the colour of the table - yellow for gridlines 
        //blue for background
        table.setGridColor(Color.YELLOW);
        table.setBackground(Color.CYAN);

        //String array to populate the combobox options
        String[] countries = {"Australia", "Brazil", "Canada", "China"
                , "France", "Japan", "Norway", "Russia", "South Korea"
                , "Tunisia", "USA"};
        JComboBox countryCombo = new JComboBox(countries);

        //Set the default editor for the Country column to be the combobox
        TableColumn countryColumn = table.getColumnModel().getColumn(2);
        countryColumn.setCellEditor(new DefaultCellEditor(countryCombo));

        //set the Event column to be larger than the rest and the Place column 
        //to be smaller
        TableColumn eventColumn = table.getColumnModel().getColumn(3);
        eventColumn.setPreferredWidth(150);

        TableColumn placeColumn = table.getColumnModel().getColumn(4);
        placeColumn.setPreferredWidth(5);

        //Place the JTable object in a JScrollPane for a scrolling table
        JScrollPane tableScrollPane = new JScrollPane(table);

        guiFrame.add(tableScrollPane);
        guiFrame.setVisible(true);
    }

    //implement a table model by extending a class to use
    //the AbstractTableModel
    class ExampleTableModel extends AbstractTableModel {

        //Two arrays used for the table data
        String[] columnNames = {"First Name", "Surname", "Country"
                , "Event", "Place", "Time", "World Record"};

        Object[][] data = {
                {"Pritom Kumar Mondal", "pritom", "Bangladesh", "50m freestyle", 1, "21.30", false},
                {"Pallob", "pallob", "Bangladesh", "50m freestyle", 2, "21.45", false}
        };

        @Override
        public int getRowCount() {
            return data.length;
        }

        @Override
        public int getColumnCount() {
            return columnNames.length;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return data[row][column];
        }

        //Used by the JTable object to set the column names
        @Override
        public String getColumnName(int column) {
            return columnNames[column];
        }

        //Used by the JTable object to render different
        //functionality based on the data type
        @Override
        public Class getColumnClass(int c) {
            return getValueAt(0, c).getClass();
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            if (column == 0 || column == 1) {
                return false;
            } else {
                return true;
            }
        }
    }
}
http://java.about.com/od/Creating-Tables/ss/A-Simple-Table-Example-Java-Code-Program.htm

Wednesday, May 29, 2013

Which function in php validate if the string is valid html?

Html validation function in php:
function isValidHtml($string)
{
    $string = "<div>".$string."</div>";
    $start = strpos($string, '<');
    $end = strrpos($string, '>', $start);
    if($start === false && $end === false) {
        return true;
    }
    if ($end !== false) {
        $string = substr($string, $start);
    } else {
        $string = substr($string, $start, $end - $start);
    }
    libxml_use_internal_errors(true);
    libxml_clear_errors();
    $xml = simplexml_load_string($string);
    return count(libxml_get_errors()) == 0;
}
And best way to use this:

if(isValidHtml($strHtml) {
    echo "Valid html";
}

$strHtml = "<table><tr><td>Hi pritom</td></tr><table>"; is FALSE

Thursday, May 23, 2013

YII TbButtonColumn Urlencode() Expects Parameter 1 To Be String, Array Given

I can not understand anything the global did not, I put to show the button in CGridView when table has multiple primary key.

array(
                'class'=>'bootstrap.widgets.TbButtonColumn',
                'htmlOptions'=>array('style'=>'width: 50px'),
            ),
it gives me:
urlencode() expects parameter 1 to be string, array given
C:\xampp\htdocs\contactwebspace\framework\web\CUrlManager.php(758)
746 
747         if($manager->matchValue && $this->matchValue===null || $this->matchValue)
748         {
749             foreach($this->params as $key=>$value)
750             {
751                 if(!preg_match('/\A'.$value.'\z/u'.$case,$params[$key]))
752                     return false;
753             }
754         }
755 
756         foreach($this->params as $key=>$value)
757         {
758             $tr["<$key>"]=urlencode($params[$key]);
759             unset($params[$key]);
760         }
761 
762         $suffix=$this->urlSuffix===null ? $manager->urlSuffix : $this->urlSuffix;
763 
764         $url=strtr($this->template,$tr);
765 
766         if($this->hasHostInfo)
767         {
768             $hostInfo=Yii::app()->getRequest()->getHostInfo();
769             if(stripos($url,$hostInfo)===0)
770                 $url=substr($url,strlen($hostInfo));
It seems that my yii does not like composite primary keys in models.
I use it with GridView, CButtonColumn and an url issue update like :

array('class'=>'CButtonColumn', 
'viewButtonUrl'=>'Yii::app()->controller->createUrl("view",$data->primaryKey)', 
'updateButtonUrl'=>'Yii::app()->controller->createUrl("update",$data->primaryKey)', 
'deleteButtonUrl'=>'Yii::app()->controller->createUrl("delete",$data->primaryKey)',
)

Or you can use as following:
array('class'=>'CButtonColumn', 
'viewButtonUrl'=>'Yii::app()->request->getBaseUrl(true)."/contact/view/".$data["id"]', 
'updateButtonUrl'=>'Yii::app()->request->getBaseUrl(true)."/contact/update/".$data["id"]', 
'deleteButtonUrl'=>'Yii::app()->request->getBaseUrl(true)."/contact/delete/".$data["id"]',
)

Deploying a PHP Application on a Remote Web Server Using the NetBeans IDE

If you have a hosting account on a remote Web server and an FTP account to transfer your source files to the remote server, you can create and debug your PHP project locally and then deploy it on the remote server. With the concept of Run Configurations, you can switch between these workflows within the same NetBeans PHP project by changing the Run Configuration type from Local Web Site to Remote Web Site.
To enable running a PHP application on a remote web server, you need to set up a run configuration that contains an FTP connection profile.
If you already have a project with a default run configuration and you want to add a new remote run configuration, customize your project:
  1. Click the right mouse button on the project node and choose Properties from the popup menu. The Project Properties panel opens.
  2. From the Categories list, choose Run Configuration. The Run Configurations panel opens.
  3. Choose the run configuration type and specify the (S)FTP connection settings as described in the sections below.
To create a NetBeans project for a PHP application on a remote server, or to create a new project that uses a remote run configuration as default:
  1. Start the IDE, choose File -> New Project. The New Project panel opens.
  2. Choose PHP from the Categories and choose the PHP Application from Remote Server. Then click Next. The Name and Location panel opens.
  3. Specify the project name, the location of the application source files, and the location of the project internal files (optional). Click Next. The Run Configuration panel opens.
  4. Specify the FTP connection settings as described in the section below. 

Choosing the Run Configuration Type

On the Run Configurations panel, choose Remote Web Site (FTP, SFTP) from the Run As dropdown list. The hidden area for setting up the configuration displays.
If you are creating a new project with the PHP Application from Remote Server wizard, you do not need to choose from the Run As dropdown list. The wizard automatically takes you to the Remote Connection panel. This panel has only Project URL, Remote Connections and Upload Directory fields.

Specifying the (S)FTP Connection Settings

To create an FTP connection:

  1. Click Manage next to the FTP Connection dropdown list. The Manage Remote Connections dialog box displays.
  2. Click Add. The Create New Connection dialog box opens. (It may open automatically if you are defining your first connection.)
  3. In the Connection Name field, enter the name of the new connection. In this example the connection name is x10hosting. From the Type dropdown list, choose FTP or SFTP. Click OK. The Manage Remote Connections dialog box displays with the name of the new connection in the Connection Name display field.
  4. In the Host Name field, enter the FTP Server name as it is written in the FTP account creation confirmation message. In this example, the FTP server is nbuser.x10.mx.
  5. In the Port field, specify 21.
  6. In the User Name field, enter your FTP Username as it is written in the FTP account creation confirmation message. In this example, the FTP username is nbuser.
  7. Fill in the Password field. In this example the password is qwerty1234.
  8. In the Initial Directory field, enter the name of your account directory on the FTP server. In this example, no account directory is specified, enter a slash in the field. 
  9. Click OK. You return to the Run Configuration panel.
  10. In the Upload Directory field, enter the name of the subfolder in the initial directory where the source files will be uploaded. The prompt below the field shows the FTP host URL.
  11. To complete setting up a new project, click Finish. 

Uploading the Source Files to a Remote Server

After you choose the remote connection for your project, select whether to upload your source files on run, on save, or manually.
  • On Run: Source files are uploaded to the server when you run the project.
  • On Save: Every change (create, edit, rename, delete) is immediately propagated to your remote server. If the operation takes more than 1 second, a progress bar is shown.
  • Manually: Files are never uploaded automatically. You must use the IDE's manual upload function, described in this section.
To manually upload files from your project to your FTP server, right-click the Source Files node of your project and select Upload. Note that you can also download files from your FTP server in the same menu.
When you start to upload files, a dialog opens with a tree view of the source files. In this dialog, you can select individual files to upload or not upload. For more information, see the NetBeans PHP blog entry on the File Upload dialog.
While you upload files, the results of your upload appear in an output tab.

Remote Synchronization

For developers who must work over (S)FTP in multiple developer environments without proper version control, NetBeans IDE provides remote synchronization. Remote synchronization allows you to compare your local copy of project files with the copies on the (S)FTP server. You can upload your local copy to the server or download the server's copy to your local machine. When the copy on the server was updated after you began work on your local copy, NetBeans IDE warns you of a file conflict. When there is a file conflict, NetBeans IDE lets you diff your local version with the version on the server and decide which version to accept on a line-by-line basis.
Warning: Remote synchronization is never 100% reliable because the timestamps on FTP servers are not 100% reliable. Version control is a safer solution.
Caution: Remote synchronization works more reliably when you perform it on an entire project. You can perform remote synchronization on individual files but this has higher risk.
To perform remote synchronization:
  • In the Projects window (Ctrl-1), expand the node for the PHP project that you want to synchronize. Right-click the Source Files node. The context menu appears, including the Synchronize option.
  •  
  • Select Synchronize. The IDE retrieves the file names and paths from the remote server and opens the Remote Synchronization dialog. The Remote Synchronization dialog shows a table of project files. The remote versions on the file are on the left and the local versions are on the right. In the center column is an icon showing the operation that the IDE will perform on synchronization. Warning icons are on the far left. A summary of operations and problems appears at the bottom of the table. A verbose description of any errors appears below the table. Above the table are sets of checkboxes for filtering which problems and operations the dialog shows. For detailed information about this dialog, click Help.  
  •  
  • Select multiple items in the table. At the bottom of the table the summary now only includes those items.
  •  
  • Right-click the selected items. A context menu of possible operations appears.  
  •  
  • If an item has a Resolve Conflicts error icon, select that item. A description of the error appears at the bottom of the table.
  •  
  • Select the item with an error. Select Diff... diff icon from either the row of buttons or from the context menu. The Diff dialog opens. In this dialog, scroll down to each difference between the remote and local versions of the file. In the graphics view, you can apply or refuse to apply the remote change to your local file. If you want to edit the file manually, switch to the Textual tab. When you are finished with the diff, click OK. You return to the Remote Synchronization dialog. The operation for the file changes to Upload and the file is marked with an asterisk, because you changed it.
  •  
  • If you have no conflict, click Synchronize. If you selected Show Summary Before Start, the Synchronize summary appears so you can review the operations one more time before performing the synchronization. If you approve of the operations, click OK.
  •  
  • The IDE performs the synchronization. You can follow the progress of the synchronization in a window that the IDE opens.

Running a PHP Application


To run a PHP application on a remote server:
  1. On the Properties panel, make sure that the Remote Web Site is chosen from the Run As dropdown list.
  2. Check the Run Configuration settings.
  3. If the project is set as main, click run main project button on the toolbar.
  4. If the project is not set as main, position the cursor on the project node and choose Run from the popup menu.

Using a Remote MySQL Database

Remote hosting services such as x10Hosting.com usually allow you to set up a MySQL database on their servers. You can create databases, manage users, and copy, read, update, or delete (CRUD) data with the tools provided by the remote hosting service.
For example, if you are using x10Hosting.com, you create a MySQL database by logging onto the x10Hosting cPanel and then opening the MySQL Databases panel. You can also create users, assign users to databases, and grant privileges to users in the MySQL Databases panel. You then can use the CRUD tools in the phpMyAdmin panel.
An alternative to working with remote database CRUD tools is to use NetBeans IDE's CRUD features to work with a local database. Then you can copy or dump the local database to the remote database. On x10Hosting.com, you can use their phpMyAdmin panel to upload the local database.

https://netbeans.org/kb/docs/php/remote-hosting-and-ftp-account.html 

Yii - How to print SQL used by the application

You can log the executed queries in the application log and review that. Something like this in the config file, and the file named "db.log" most probably created in "protected/runtime" folder.
'components' => array(
  'db'=>array(
    'enableParamLogging' => true,
  ),
  'log'=>array(
    'class'=>'CLogRouter',
    'routes'=>array( 
      array(
        'class'=>'CFileLogRoute',
        'levels'=>'trace,log',
        'categories' => 'system.db.CDbCommand',
        'logFile' => 'db.log',
      ), 
    ),
  ),
);
In some cases (e.g. when running tests), you will also need to call Yii::app()->log->processLogs(null); at the end of the process for this to work.
Of course, once you're there nothing's stopping you from writing your own log route that does something different with the logged messages, but mind that the logs are processed at the end of the request (or when you call processLogs), not every time you log something.

By the way, the proper way to create dynamic query with parameters:
$criteria = new CDbCriteria();
$criteria->condition = 't.date BETWEEN :from_date AND :to_date';
$criteria->params = array(
  ':from_date' => $from_date,
  ':to_date' => $to_date,
);
$criteria->with = array('order');

$orders = ProductOrder::model()->findAll($criteria);

Wednesday, May 22, 2013

Check if a port is being used on a Windows machine and if Kill

See all port used:
netstat -aon

Find a port:
netstat -aon | findstr 8082

TCP    0.0.0.0:8082           0.0.0.0:0              LISTENING       5312

Kill a process:
taskkill /F /PID 5312

Addition or Substraction of Double Values in Java


In subtracting one double from another, namely 45.32 - 45.31, I get a
result of 0.00999999999999801. According to all the math I've ever 
learned, the answer should be .01. Now the answer is:

double x = 45.32;
double y = 45.31;
double answer = (x - y);
answer = Math.round(answer*100)/100.0d; 

Monday, May 20, 2013

Groovy Grails Domain GORM and enum types


Create an enum class in src/groovy or src/java.

/**
 * User: pritom
 */
public enum UserStatus {
    active('active'),
    on_hold('on_hold')

    String name

    UserStatus(String name) {
        this.name = name
    }

    public String getName() {
        name
    }

    public String toString() {
        return this.getName()
    }
}

Specify a property in your domain class with the enum type.

class User {
 String userName,
 UserStatus type = UserStatus.active
}

Wednesday, May 8, 2013

Building a J2ME sliding menu with text and images

This example will show, how to create an image icon to perform the next action or next image from the list every time it's been clicked. So if you want to go from one icon to another icon by the nice sliding effect, you have to run the given example. For developing this application we have inherit canvass class and implement Runnable Interface. The Runnable interface is called from java.lang package and this interface has only one methods which is called: run() method. The function to run the application is as follows which is used in this application:

 

Use SlideMenuRunnable as following code:

display.setCurrent(new SlideMenuRunnable(Main Midlet Class Reference));

 

SlideMenuRunnable Class


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package the.contact.space;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 *
 * @author User
 */
public class SlideMenuRunnable extends Canvas implements Runnable,CommandListener {
    SlideMenu menu = null;
    private Command cmdBack;
    private Home midlet;
    
    public SlideMenuRunnable(Home midlet){
        this.midlet = midlet;
        cmdBack = new Command("Back", Command.BACK, 1);
        addCommand(cmdBack);
        setCommandListener(this);
        Image[] image = new Image[3]; 
        try{
            image[0] = Image.createImage("/hk1.jpg");
            image[1] = Image.createImage("/hk2.jpg");
            image[2] = Image.createImage("/hk3.jpg");

            menu = new SlideMenu(new String[]{"1", "2", "3"},  
                image,  getWidth(),  getHeight());
            new Thread(this).start();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
    protected void paint(Graphics g) {
        menu.paint(g);
    }
    
    public void keyPressed(int key){
        int gameKey = getGameAction(key);
        if(gameKey == Canvas.RIGHT){
            menu.slideItem(1);
        }else if(gameKey == Canvas.LEFT){
            menu.slideItem(- 1);
        }
    }

    public void run() {
        try{
            while(true){
                repaint();
                synchronized(this){
                    wait(100L);
                }
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }    

    public void commandAction(Command c, Displayable d) {
        if (c == cmdBack) {
            /* back code here */
        }
    }
}

SlideMenu Class

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package the.contact.space;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 *
 * @author User
 */
public class SlideMenu {
    public int select_index, back_index, width, height;
    public Image r_arrow, l_arrow;
    String[] labels = null;
    Image[] icons = null;
    public int duration = 500;
    long time = 0;
    
    public SlideMenu(String[] labels, Image[] icons, int width, int height) throws Exception{
        try{
            r_arrow = Image.createImage("/right_arrow.png");
            l_arrow = Image.createImage("/left_arrow.png");
        }catch(Exception e){
            e.printStackTrace();
        }
        this.width = width;
        this.height = height;  
        this.labels = labels;
        this.icons = icons;  
    }
    
    public void slideItem(int next){
        if(!isImage() && select_index + next >= 0 && select_index + next < labels.length){
            back_index = select_index;  
            select_index += next;  
            time = System.currentTimeMillis();
        }
    }

    public boolean isImage(){
      return back_index != select_index;
    }

    public void paint(Graphics g){  
        g.setColor(255, 0, 0);
        g.fillRect(0, 0, width, height);  
        g.setColor(0, 0, 255);
  
        if(select_index > 0){
            g.drawImage(l_arrow, 2, height / 2, 
            Graphics.LEFT | Graphics.VCENTER);
        }

        if(select_index < icons.length - 1){
            g.drawImage(r_arrow, width - 2, height / 2, 
            Graphics.RIGHT | Graphics.VCENTER);
        }

        g.drawString(labels[select_index], width / 2, 
        height - 2, Graphics.BOTTOM | Graphics.HCENTER);  

        g.setClip(l_arrow.getWidth(), 0, width - 2 * 
        l_arrow.getWidth(), height);

        if(select_index != back_index) {
            int difference = (int)(System.currentTimeMillis() - time);  
            if(difference > duration){
                difference = duration;
            }

            int image_present = select_index > back_index ? 1 : - 1;
            int current_image = width / 2 - image_present * 
            difference * width / duration;

            int next_image = current_image + width * image_present;

            g.drawImage(icons[back_index], current_image, height / 2, 
            Graphics.VCENTER | Graphics.HCENTER);  

            g.drawImage(icons[select_index], next_image, height / 2, 
            Graphics.VCENTER | Graphics.HCENTER);

            if(difference >= duration){
                back_index = select_index;
            }
        } else {
            g.drawImage(icons[select_index], width / 2, height / 2, 
            Graphics.VCENTER | Graphics.HCENTER);
        }
    }
} 
http://www.roseindia.net/j2me/slide-image.shtml 

Where do I put images in J2me application

create a folder ( res) in your main project . 
put all images in this folder. 

add this folder in resource ..  by right clicking on resource folder from project browser and click add folder.

you can create images .. like 

Image image = createImage("/image.png")

Monday, May 6, 2013

View contact list using j2me


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package the.contact.space;

import java.util.Enumeration;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.pim.Contact;
import javax.microedition.pim.ContactList;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMList;

/**
 * @author User
 */
public class ViewContactList extends Form implements CommandListener {
    private final Home midlet;
    private Command cmdBack;
    private Enumeration contacts;
    private List contactList;
    private ContactList contList;

    /**
     *
     */
    public ViewContactList(String title, Home midlet) {
        super(title);
        this.midlet = midlet;
        cmdBack = new Command("Back", Command.BACK, 1);
        addCommand(cmdBack);
        setCommandListener(this);
        contactList = new List("Contact List", List.IMPLICIT);
        viewContactList2();
    }
    
    private void viewContactList2() {
        try {
            PIM pimInst = PIM.getInstance();
            contList = (ContactList) pimInst.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
            contacts = contList.items();
            while (contacts.hasMoreElements()) {
                Contact tCont = (Contact) contacts.nextElement();
                String[] nameValues = tCont.getStringArray(Contact.NAME, 0);
                String firstName = nameValues[Contact.NAME_GIVEN];
                String lastName = nameValues[Contact.NAME_FAMILY];
                String phone = tCont.getString(Contact.TEL, 0);
                String email = null;
                try {
                    email = tCont.getString(Contact.EMAIL, 0);
                } catch (Exception ex) {}
                contactList.append(firstName + " " + lastName + "\n" + phone, null);
            }
            contactList.addCommand(cmdBack);
            contactList.setCommandListener(this);
            this.midlet.getDisplay().setCurrent(contactList);
        } catch (Exception ex) {
            ex.printStackTrace();
            Alert error = new Alert("Error", "No available contacts."+ex.getMessage(), null, AlertType.ERROR);
            error.setTimeout(Alert.FOREVER);
            this.midlet.getDisplay().setCurrent(error);
            return;
        }
    }
    
    public void commandAction(Command c, Displayable d) {
        if (c == cmdBack) {
            midlet.displayMainMIDlet();
        }
    }
}