How can I use abstract method in J2ME?
<p>I implemented some code that has an alert class which is type of Canvas, and it has a keyPress method which must work different for each class that using alert class. For example the keyPress method has 2 buttons that the function of each button is different for each class!  Could anyone tell me  How can I implement that ?</p>

<p>public class myAlert extends Canvas implements CommandListener{</p>

<p>public myAlert(Midlet midlet,int width,int height,String str,String left_str,String right_str){
}
  protected void paint(Graphics g) {
     g.setColor(0, 0,0);
        g.drawRoundRect(5, 180, width-10, height, 8, 8);
        g.drawRoundRect(15, 185, width-15, height-5, 7, 7);
        g.setColor(0xbfd4f6);
        g.fillRoundRect(0, 180, width, height, 8, 8);
        ///////////////
    }
    protected void keyPressed(int keyCode)
    {
       switch(keyCode){
           case -6: // select button<br>
//
break;
        case -7: //close button</p>

<pre><code>        break;
}
</code></pre>

<p>}
}
Public class M(){<br>
protected  void keyPressed(int keyCode) {</p>

<pre><code>    switch (state) {
 case STATE_INPUT_LEFT:
      // do work for focus on the left
      if (keyCode &gt;= KEY_NUM0 &amp;&amp; keyCode &lt;= KEY_NUM9 &amp;&amp; digitsEntered &lt; 10) {
        digits_left[digitsEntered] = (char) ('0' + (keyCode - KEY_NUM0));
        digitsEntered++;
        repaint();
        if(digitsEntered&gt;=8){
         state=STATE_INPUT_RIGHT;
            m= new myAlert(midlet,w, 150,"Ok " ,"exit",”system”);
</code></pre>

<p>//I want that if user click on Ok button the main page must be shown to user
                Display.getDisplay(midlet).setCurrent( m);
         break;
            }
      }
}
Public class N(){
  public void commandAction(Command c, Displayable d) {
     String label = c.getLabel();
     if(label.equals("Exit")){
         midlet.exit();
      }
     else if(label.equals("Enter")){
      m= new myAlert(midlet,w, 150,”yes”,”No”,”Print” );
// I want here that if user clicks on ok another message be shown to user 
      Display.getDisplay(midlet).setCurrent( m);</p>

<pre><code>}
}
</code></pre>

<p>here is part of my code! as you see in M class and N class function of left button of Alert class is diffrent from each other! Now Could you help me?</p>
