Turning off the program with the run button?

This is where you talk about the RCX software itself, installation issues, and programming talk.

Moderator: roger

Turning off the program with the run button?

Postby pedor » Sat Jun 09, 2007 9:39 pm

How do I do so i always can turn off the program with the run button?
pedor
New User
 
Posts: 3
Joined: Sat Jun 09, 2007 9:25 pm

Postby pedor » Fri Jul 27, 2007 4:41 pm

Somebody write a example please :?: :?:
pedor
New User
 
Posts: 3
Joined: Sat Jun 09, 2007 9:25 pm

Postby 99jonathan » Sat Jul 28, 2007 12:47 am

One way to do that would be to create a subclass of ButtonListener such as:

Code: Select all
class ButtonExit extends ButtonListener{

public boolean isrunpressed=false;

void buttonPressed(Button b) {
    if(b.equals(Button.RUN))
        isrunpressed=true;
}

void buttonReleased(Button b){}

}

Then just make ur main method do the following:

Code: Select all
//code here
ButtonExit be=new ButtonExit();
Button.RUN.addButtonListener( be );

while(!be.isrunpressed){}
//end of main method
}


Probably not all that efficient but hey... it'll do!!
99jonathan
Moderator
 
Posts: 122
Joined: Thu Mar 01, 2007 5:30 am


Return to RCX Software

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests

more stuff