Java me 为特定记录存储添加记录时,它将';也将添加到另一个记录存储!?

Java me 为特定记录存储添加记录时,它将';也将添加到另一个记录存储!?,java-me,lwuit,rms,Java Me,Lwuit,Rms,我有一个LWUIT应用程序,它涉及两个RecordStores播放器1_recordStore和 players2_唱片店。检索的所有记录的两种方法SearchCard_team1 players1_recordStore和方法SearchCard_team2,用于检索 players2_唱片店。4个按钮b1用于向播放器添加新记录1_recordStore,b2用于添加新记录 录制到播放器2_recordStore,b3检索播放器1_recordStore的所有记录,b4检索到 检索player

我有一个LWUIT应用程序,它涉及两个RecordStores播放器1_recordStore和

players2_唱片店。检索的所有记录的两种方法SearchCard_team1

players1_recordStore和方法SearchCard_team2,用于检索

players2_唱片店。4个按钮b1用于向播放器添加新记录1_recordStore,b2用于添加新记录

录制到播放器2_recordStore,b3检索播放器1_recordStore的所有记录,b4检索到

检索players2_recordStore的所有记录

我的申请有几个问题

1-按下b3按钮或b4时,不显示第一条记录

2-为什么players2\u recordStore的记录显示在players1\u recordStore记录旁边

当按下b3按钮时,则相反

import javax.microedition.rms .*;

 import com.sun.lwuit.plaf.*;
import javax.microedition.midlet.*;

import com.sun.lwuit.*;
import com.sun.lwuit.events.*;

public class HelloLWUITMidlet extends MIDlet    {

     private RecordStore players1_recordStore;
     private RecordStore players2_recordStore;



  public String [] SearchCarded_team1()
{

    String[] str = null;
    int counter = 0;
    try
    {
   RecordEnumeration enumeration = players1_recordStore.enumerateRecords(null, null, false);
        str = new String[players1_recordStore.getNumRecords()];

        while(enumeration.hasNextElement())
        {
            try
            {
                str[counter] = (new String(enumeration.nextRecord()));
                counter ++;
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }


    return str;
}

 public String [] SearchCarded_team2()
{

    String[] str = null;
    int counter = 0;
    try
    {


        RecordEnumeration enumeration = players2_recordStore.enumerateRecords(null, null, false);
        str = new String[players2_recordStore.getNumRecords()];

        while(enumeration.hasNextElement())
        {
            try
            {
                str[counter] = (new String(enumeration.nextRecord()));
                counter ++;
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }


    return str;
}




    public void startApp()

    {

      com.sun.lwuit.Display.init(this);

int bgColor =0x0066CC;
try
{
players1_recordStore.openRecordStore("My Record Store", true);

}
catch(Exception e){}

try
{
players2_recordStore.openRecordStore("My Record Store", true);

}

catch(Exception e){}

final form5 gggg =new form5();
gggg.setTitle("Cards ' Record");

 final com.sun.lwuit.List mylist =  new com.sun.lwuit.List();


 final  com.sun.lwuit.Form f = new com.sun.lwuit.Form("Soccer Software");
   f.getStyle().setBgColor(0X99CCFF);

  final    com.sun.lwuit.TextField tf =new com.sun.lwuit.TextField();
  final   com.sun.lwuit.TextField  txtfield3 =new  com.sun.lwuit.TextField();

 final    com.sun.lwuit.TextField     tf3 =new com.sun.lwuit.TextField();
  final    com.sun.lwuit.TextField  txtfield4 =new com.sun.lwuit.TextField();

  final    com.sun.lwuit.TextField  tf4 =new com.sun.lwuit.TextField();
  final    com.sun.lwuit.TextField  txtfield6 =new com.sun.lwuit.TextField();


  final Button cards = new Button(""+"Cards Status");
  cards.getStyle().setBgColor(0X0066CC);

 final Button b1 = new Button("Yellow Cards ");
 final Button b2 = new Button("Red Cards");
 final Button b3 = new Button("All yellow carded players");
 final Button b4 = new Button("All red carded players");

b2.getStyle().setBgColor(0X0066CC);

  b1.getStyle().setBgColor(0X0066CC); ;
  b2.getStyle().setBgColor(0X0066CC);
  b3.getStyle().setBgColor(0X0066CC); ;
 b4.getStyle().setBgColor(0X0066CC);


   com.sun.lwuit.Command back = new com.sun.lwuit.Command("Main Screen");



final com.sun.lwuit.TextArea text = new com.sun.lwuit.TextArea();

final Label lll = new Label("");


 f.addComponent(cards);

 txtfield3.setLabelForComponent(lll);


gggg.getStyle().setBgColor(0X99CCFF);
gggg.addComponent(b1);
gggg.addComponent(b2);
gggg.addComponent(b3);
gggg.addComponent(b4);
gggg.addComponent(txtfield6);


gggg.addCommand(back);


cards.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent ae) {


gggg.show();
     }

  }
);


 gggg.addCommandListener(new ActionListener()

 {


  public void actionPerformed(ActionEvent ae) {



f.show();
     }



 }
          );



b1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {

String player1 =txtfield6.getText();

     { }

if(player1!=null && player1.length() > 0)

{


try
{
players1_recordStore.openRecordStore("My Record Store", true);
        }

 catch(Exception e){}


 try{
   byte bytestream[] = player1.getBytes()  ;

             int i = players1_recordStore.addRecord(bytestream, 0, bytestream.length);

     }

 catch(Exception ex) { }


   Dialog validDialog = new Dialog(" ");
   Style Dialogstyle = validDialog.getSelectedStyle() ;

        validDialog.setScrollable(false);
 validDialog.getDialogStyle().setBgColor(0x0066CC);
        validDialog.setTimeout(1000);
        TextArea textArea = new TextArea("....");
        textArea.setFocusable(false);

       textArea.setText(player1+"-"+"has been carded");
        validDialog.addComponent(textArea);

        validDialog.show(0, 10, 10, 10, true);

txtfield6.clear();


}


else

{

    Dialog validDialo = new Dialog(" ");
        validDialo.setScrollable(false);
validDialo.getDialogStyle().setBgColor(0x0066CC);
        validDialo.setTimeout(5000);
        TextArea textArea = new TextArea("....");

        textArea.setFocusable(false);
       textArea.setText("please Enter the record ");
        validDialo.addComponent(textArea);


        validDialo.show(50, 50, 50, 50, true);
        txtfield6.clear();
 }




   }
  }
);

b2.addActionListener(new ActionListener() {


public void actionPerformed(ActionEvent ae) {

String player2 =txtfield6.getText();


     { }

if(player2!=null && player2.length() > 0)

{

 try{
   byte bytestream[] = player2.getBytes()  ;

             int i = players2_recordStore.addRecord(bytestream, 0, bytestream.length);

     }

 catch(Exception ex) { }


   Dialog validDialog = new Dialog(" ");
   Style Dialogstyle = validDialog.getSelectedStyle() ;

        validDialog.setScrollable(false);
 validDialog.getDialogStyle().setBgColor(0x0066CC);
        validDialog.setTimeout(1000);
        TextArea textArea = new TextArea("....");
        textArea.setFocusable(false);

       textArea.setText(player2+"-"+"has been expluded");
        validDialog.addComponent(textArea);

        validDialog.show(0, 10, 10, 10, true);

txtfield6.clear();


}


else

{

    Dialog validDialo = new Dialog(" ");
        validDialo.setScrollable(false);
validDialo.getDialogStyle().setBgColor(0x0066CC);
        validDialo.setTimeout(5000);
        TextArea textArea = new TextArea("....");

        textArea.setFocusable(false);
       textArea.setText("please Enter Record");
        validDialo.addComponent(textArea);


        validDialo.show(10, 10, 10, 10, true);
        txtfield6.clear();
 }




   }
  }
);


 b3.addActionListener(new ActionListener() {


  public void actionPerformed(ActionEvent ae) {

  try{
        players1_recordStore = RecordStore.openRecordStore("My Record Store", true);

        }


     catch(Exception ex)
     {
         ex.printStackTrace();
     }

String [] carded =  SearchCarded_team1();
int j;
String valueToBeInserted="";

for( j=0;j< SearchCarded_team1().length;j++)
  {


valueToBeInserted=valueToBeInserted + " " + carded[j];







      }
 Dialog  hilal = new Dialog(" ");
   Style Dialogstyle = hilal.getSelectedStyle() ;
hilal.setTitle("All Yellow Carded Players");
        hilal.setScrollable(false);
 hilal.getDialogStyle().setBgColor(0x0066CC);
        hilal.setTimeout(10000);
        TextArea textArea = new TextArea( );
        textArea.setFocusable(false);

       textArea.setText(valueToBeInserted+"                   "+"\t");
       hilal.addComponent(textArea);

        hilal.show(0, 10, 10, 10, true);

  }

  }
);


 b4.addActionListener(new ActionListener() {


  public void actionPerformed(ActionEvent ae) {

  try{
       players2_recordStore = RecordStore.openRecordStore("My Record Store", true);

        }


     catch(Exception ex)
     {
         ex.printStackTrace();
     }

String [] carded2 =   SearchCarded_team2();
int j;
String valueToBeInserted2="";

for( j=0;j< SearchCarded_team2().length;j++)
  {


valueToBeInserted2=valueToBeInserted2 + " " + carded2[j];


      }
 Dialog  hilal2 = new Dialog(" ");
   Style Dialogstyle = hilal2.getSelectedStyle() ;
hilal2.setTitle("All red carded players");
        hilal2.setScrollable(false);
 hilal2.getDialogStyle().setBgColor(0x0066CC);
        hilal2.setTimeout(5000);
        TextArea textArea = new TextArea( );
        textArea.setFocusable(false);

       textArea.setText(valueToBeInserted2+"                   "+"\t");
       hilal2.addComponent(textArea);

        hilal2.show(0, 10, 10, 10, true);
txtfield6.clear();
  }

  }
);

      f.show();

    }

    public void pauseApp() {}

    public void destroyApp(boolean unconditional) {}

    public void actionPerformed(ActionEvent ae) {
      notifyDestroyed();
    }

public  class form5    extends   com.sun.lwuit.Form


  {



   public form5()

          {

  com.sun.lwuit.Form form5 = new com.sun.lwuit.Form("Cards' Records ");


          }


}





}
import javax.microedition.rms.*;
导入com.sun.lwuit.plaf.*;
导入javax.microedition.midlet.*;
导入com.sun.lwuit.*;
导入com.sun.lwuit.events.*;
公共类HelloLWUITMidlet扩展了MIDlet{
私人唱片店播放器1_唱片店;
私人唱片店播放器2_唱片店;
公共字符串[]SearchCard_team1()
{
字符串[]str=null;
int计数器=0;
尝试
{
RecordEnumeration enumeration=players1\u recordStore.enumerateRecords(null,null,false);
str=新字符串[players1_recordStore.getNumRecords()];
while(枚举.hasNextElement())
{
尝试
{
str[counter]=(新字符串(enumeration.nextRecord());
计数器++;
}
捕获(例外e)
{
e、 printStackTrace();
}
}
}捕获(例外e){
e、 printStackTrace();
}
返回str;
}
公共字符串[]SearchCard_team2()
{
字符串[]str=null;
int计数器=0;
尝试
{
RecordEnumeration enumeration=players2\u recordStore.enumerateRecords(null,null,false);
str=新字符串[players2_recordStore.getNumRecords()];
while(枚举.hasNextElement())
{
尝试
{
str[counter]=(新字符串(enumeration.nextRecord());
计数器++;
}
捕获(例外e)
{
e、 printStackTrace();
}
}
}捕获(例外e){
e、 printStackTrace();
}
返回str;
}
公开作废startApp()
{
com.sun.lwuit.Display.init(this);
int bgColor=0x0066CC;
尝试
{
播放器1_recordStore.openRecordStore(“我的唱片店”,true);
}
捕获(例外e){}
尝试
{
players2_recordStore.openRecordStore(“我的唱片店”,true);
}
捕获(例外e){}
最终表格5 gggg=新表格5();
gggg.setTitle(“卡片记录”);
final com.sun.lwuit.List mylist=new com.sun.lwuit.List();
final com.sun.lwuit.Form f=新的com.sun.lwuit.Form(“足球软件”);
f、 getStyle().setBgColor(0X99CCFF);
final com.sun.lwuit.TextField=new com.sun.lwuit.TextField();
final com.sun.lwuit.TextField txtfield3=new com.sun.lwuit.TextField();
final com.sun.lwuit.textf3=new com.sun.lwuit.TextField();
final com.sun.lwuit.TextField txtfield4=新com.sun.lwuit.TextField();
final com.sun.lwuit.textf4=new com.sun.lwuit.TextField();
final com.sun.lwuit.TextField txtfield6=新com.sun.lwuit.TextField();
最终按钮卡=新按钮(“+”卡状态”);
cards.getStyle().setBgColor(0X0066CC);
最终按钮b1=新按钮(“黄牌”);
最终按钮b2=新按钮(“红牌”);
最终按钮b3=新按钮(“所有黄牌球员”);
最终按钮b4=新按钮(“所有红牌球员”);
b2.getStyle().setBgColor(0X0066CC);
b1.getStyle().setBgColor(0X0066CC);
b2.getStyle().setBgColor(0X0066CC);
b3.getStyle().setBgColor(0X0066CC);
b4.getStyle().setBgColor(0X0066CC);
com.sun.lwuit.Command back=新建com.sun.lwuit.Command(“主屏幕”);
final com.sun.lwuit.TextArea text=new com.sun.lwuit.TextArea();
最终标签lll=新标签(“”);
f、 添加组件(卡片);
txtfield3.setLabelForComponent(lll);
getStyle().setBgColor(0X99CCFF);
gggg.addComponent(b1);
gggg.addComponent(b2);
gggg.addComponent(b3);
gggg.addComponent(b4);
gggg.addComponent(txtfield6);
gggg.addCommand(返回);
cards.addActionListener(新ActionListener(){
已执行的公共无效行动(行动事件ae){
gggg.show();
}
}
);
addCommandListener(新的ActionListener()
{
已执行的公共无效行动(行动事件ae){
f、 show();
}
}
);
b1.addActionListener(新ActionListener(){
已执行的公共无效行动(行动事件ae){
String player1=txtfield6.getText();
{ }
如果(player1!=null&&player1.length()>0)
{
尝试
{
播放器1_recordStore.openRecordStore(“我的唱片店”,true);
}
捕获(例外e){}
试一试{
byte ByTestStream[]=player1.getBytes();
int i=players1\u recordStore.addRecord(bytestream,0,bytestream.length);
}
捕获(例外情况除外){}
Dialog validDialog=新建对话框(“”);
Style Dialogstyle=validDialog.getSelectedStyle();
有效模拟设置可滚动(假);
validDialog.getDialogStyle().setBgColor(0x0066CC);
validDialog.setTimeout(1000);
TextArea TextArea=新TextArea(“..”);
textArea.setFocusable(false);
textArea.setText(player1+“-”+“已被刷卡”);
validDialog.addComponent(文本区域);
有效数字显示(0,10,10,10,真);
txtfield6.clear();
}
其他的
{
Dialog validDialo=新建对话框(“”);
有效的可设置滚动(假);
validDialo.getDialogStyle().setBgColor(0x0066CC);
有效设置超时(5000);
TextArea TextArea=新TextArea(“..”);
textArea.setFocusable(false);
textArea.setText(“请输入记录”);
validDialo.addComponent(文本区域);
有效的表演(50,50,50,50