TFT 3.2 inch mega relay control

Hi
I'm trying to program my arduino to control a relay with my tft screen
so there are 2 colors on my tft screen half red(relay off) and other half green(relay on) i want to press the green light to turn the relay and red light to turn off the relay.
I got to the controlling the relay but idk how to how to make it just to go on when i press the green light cause at the moment when i press the green light, i can turn the relay on and when i press it again it goes off. i tried to make the colors to do 1 thing only just to turn it ON when i press the green color or off when i press the red color but i can turn it on and off with both buttons on the tft.
If you guyz can help me i would really appreciate it.
thanks and im sorry for the English and I'm really new to arduino .
i got a Mega2560
3.2 Inch ILI9341 TFT LCD
and a tft lcd mega shield v2.2.

#include <TouchScreen.h>

//
#include <UTouch.h>
#include <UTFT.h>

#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF820
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
// Declare which fonts we will be using

int Relay = 8;

// Uncomment the next line for Arduino 2009/Uno
UTFT myGLCD(ILI9327,38,39,40,41); // Remember to change the model parameter to suit your display module!
UTouch myTouch( 6, 5, 4, 3, 2);

int x, y;

void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
myTouch.InitTouch();
myTouch.InitTouch(LANDSCAPE);
myTouch.setPrecision(PREC_MEDIUM);
OnOffButton();

Serial.begin(9600);
pinMode(Relay, OUTPUT);

}
void OnOffButton()
{
//on button

myGLCD.setColor(GREEN);
myGLCD.fillRect(0,0,240,240);
myGLCD.setColor(BLACK);
myGLCD.drawRoundRect(0,0,240,240);

//off button

myGLCD.setColor(RED);
myGLCD.fillRect(240,0,399,240);
myGLCD.setColor(BLACK);
myGLCD.drawRoundRect(240,0,399,240);

}
void loop()
{

if (myTouch.dataAvailable()){
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
if ((x>=0) && (x<=240) && (y>=0) && (y<=240));

digitalWrite(Relay,0);

}

// off button
if (myTouch.dataAvailable()){
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();

digitalWrite(Relay,1);

}

}

You are not testing the right conditions in this area.

  // off button
 if (myTouch.dataAvailable()){
  myTouch.read();
  x=myTouch.getX();
  y=myTouch.getY();


 digitalWrite(Relay,1);

You need to test for the region of screen touched for the OFF condition.

Add

if ((x>=240) && (x<=390) && (y>=0)&& (y<=240));

Before

 digitalWrite(Relay,1);

One of your bug is at the end of this line

 if ((x>=0) && (x<=240) && (y>=0) && (y<=240))[color=red][b];[/b][/color]

you really don't want a ;

But your logic is flawed because when you have a touch your read it and if it's green you (try to) do the right thing (if you did not have the ;) but if you touched the other side your detect a touch, you read the data, it's on the wrong side so you don't turn on the relay, and then.. you check again for touch and then read again the touch...

what you should do

if no touch then do nothing
else
myTouch.read();
you don't need to check the Y because you have the full height of the device so
if (myTouch.getX() < 240) then TURN ON (if not already, you might want to memorize status)
else TURN OFF (if not already OFF, you might want to memorize status)

also you might want to read this

thanks you that helped me a lot
so i changed the code abit and now it works great like how i wanted at the start.
really appreciate the help

// off button
if (myTouch.dataAvailable()){
delay(50);
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
if ((x>=120) && (x<=390))

digitalWrite(Relay,1);