I am sorry if i was not too clear the first time.I hope my problem is clearer now. I have written a program that executes certain instructions.It reads these instruction from an array of Textfield.I have a for loop to go through the Textfield.I am unable to implement a JUMP instruction that will jump to a specified Textfield as well as the SKIP instruction that will skip the next Textfield based on some condition. I tried the code below but it does not work private class Executionionhandler implements ActionListener { public void actionPerformed(ActionEvent event) { int StartLocation=(int)(Integer.parseInt(start2.getText())); //start1.setVisible(fa lse); //start2.setVisible(false); //r, StartLocation, End, Stop are global for(int r=StartLocation;r<End && Stop==false;r++) {//content[r] is a Textfield String read=Content[r].getText(); String com1=read.substring(0,2); int com11=(int)(Integer.parseInt(com1)); String com2=read.substring(2,4); instruction(com11,com2); } } }
public void instruction(int IN1,String IN2) { switch(IN1) { case 1: //do something break; case 3: //do something break; case 7://the JUMP INSTRUCTION int JmpLoc7=(int)(Integer.parseInt(IN2)); r=JmpLoc7; //StartLocation=JmpLoc7; break ; case 8://the SKIP INSTRUCTION int copy81=(int)(Integer.parseInt(BUTTON.getText())); if(((copy81<0) && (IN2.equals("00"))) || ((copy81==0) && (IN2.equals("01"))) || ((copy81>0) && IN2.equals("02"))) ) r++; case 11: error1.setText("End of command"); Stop=true; break; default: error1.setText("BAD COMMAND"); Stop=true; } } Any idea why or how can I achieve this?