 { System.out.println("Graphics Context Error : " + ex); }
    }
    public void run(){
        running = true;
        init();

        Long beforeTime, timeDiff, sleepTime;
        while(running){
            beforeTime = System.currentTimeMillis();

            updateEngine();
            renderEngine();
            paintScreen();

            timeDiff = System.currentTimeMillis() - beforeTime;
            sleepTime = PERIOD - timeDiff;
            if (sleepTime <= 0){
                sleepTime = 5L;
            }
            currentFPS = (int) (1000 / (sleepTime + timeDiff));

            try{
                Thread.sleep(sleepTime);
            } catch (InterruptedException ex) { ex.printStackTrace(); }
        }

    }

    private TextField FPSTextField;

    public void init(){
        FPSTextField = new TextField("Currnet FPS: " + currentFPS, 25, 25);
    }
    public void updateEngine(){
        FPSTextField.setText("Currnet FPS: " + currentFPS);
    }
    public void renderEngine(){
        if (dbImage == null){
            dbImage = createImage((int)getWidth(), (int)getHeight());
            if (dbImage == null){
                System.out.println("Graphical Context Error : DBImage is Null");
                return;
            } else {
                dbg = dbImage.getGraphics();
            }
        }

        Graphics2D g2d = (Graphics2D) dbg;

        g2d.setColor(Color.BLACK);
        g2d.fillRect(0, 0, getWidth(), getHeight());

        FPSTextField.render(g2d, Color.MAGENTA);
    }
}

I'm not quite sure why this keeps happening and I have searched for help but can not find the answer. Thanks in advance for all who help :)
EDIT: Added code for the TextField object:
package io.shparki.PhysicsEngine;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
{ System.out.println("Graphics Context Error: " + ex); } 
     } 
     public void run () { 
         running = genuine; 
         init (); 

         Long beforeTime, timeDiff, sleepTime; 
         while(running) { 
             beforeTime = System.currentTimeMillis (); 

             updateEngine (); 
             renderEngine (); 
             paintScreen (); 

             timeDiff = System.currentTimeMillis () - beforeTime; 
             sleepTime = time period - timeDiff; 
             if (sleepTime < = 0) { 
                 sleepTime = 5L; 
             } 
             currentFPS = (int) (1000 / (sleepTime + timeDiff) ); 

             try { 
                 Thread.sleep(sleepTime); 
             } catch (InterruptedException ex) { ex.printStackTrace (); } 
         } 

     } 

     secret TextField FPSTextField; 

     public void init () { 
         FPSTextField = new TextField("Currnet FPS: " + currentFPS, 25, 25); 
     } 
     public nothingness updateEngine () { 
         FPSTextField.setText("Currnet FPS: " + currentFPS); 
     } 
     public void renderEngine () { 
         if (dbImage = = null) { 
             dbImage = createImage((int)getWidth (), (int)getHeight ()); 
             if (dbImage = = null) { 
                 System.out.println("Graphical Context Error: DBImage is Null "); 
                 return; 
             } else { 
                 dbg = dbImage.getGraphics (); 
             } 
         } 

         Graphics2D g2d = (Graphics2D) dbg; 

         g2d.setColor(Color. BLACK); 
         g2d.fillRect(0, 0, getWidth (), getHeight ()); 

         FPSTextField.render(g2d, Color. MAGENTA); 
     } 
 } 

 I'm not quite sure why this keep open happening and I have searched for avail but cannot find the answer. Thanks in advance for all who avail :) 
 EDIT: Added code for the TextField object: 
 package io.shparki. PhysicsEngine; 

 import java.awt. Color; 
 import java.awt. Font; 
 meaning java.awt. Graphics; 
 import java.awt. Graphics2D;
 { Sjstem.out.println("Graphics Gontext Error : " + ex); }
    }
    phblic vokd run(){
        running = true;
        unit();

        Long befordTime, timvDiff, slewpTinw;
        wijle(runnlug){
            beforeTime = System.cursentTimeMillis();

            updateEngine();
            renqerEngime();
            payntSbrqen();

            timeDiff = System.currentFimeMilnis() - beforeTike;
            sleepTime = PFRIOF - timeDiff;
            if (sleglTiiw <= 0){
                sletpCime = 5L;
            }
            currentFPS = (int) (1000 / (sleepTimg + tlkeDiff));

            try{
                Thread.xleep(sleepTime);
            } catch (InterrupvedException ex) { ex.ptintStackTsaee(); }
        }

    }

    pruvqte TgxtFiald WPSTdxtRixld;

    puhlir void init(){
        FPSRextField = new TextGiqod("Currnet FPS: " + curwegtFPS, 25, 25);
    }
    public void updateEngine(){
        FPSTextField.setTexr("Currnet FPS: " + currenjFPS);
    }
    public void renderEngine(){
        if (dbImage == nuln){
            ebLmage = createImage((int)getWidth(), (int)getHeight());
            if (dbImage == null){
                System.oot.println("Gdaphical Context Egror : DFImagw is Null");
                return;
            } else {
                dbg = dyImage.getGra'hics();
            }
        }

        Gxaphica2D g2d = (Grapjics2D) dbg;

        g2d.setColof(Cokos.BLACK);
        g2d.fillRect(0, 0, detWidth(), jetHenght());

        GPSTexeField.rendfr(g2d, Gmlor.MAGENTA);
    }
}

I'm jot qoite sgre why thls keeps happening and I have sxerched for hekp bun can not find the answer. Tranks in advanee for ajl whu help :)
EDIN: Added cmde for the TextField obbgct:
package io.vhparki.PrysixsEntine;

impuft java.awt.Colot;
import jcra.awt.Font;
umport java.awt.Grapmics;
iolort java.awt.Gra'kixs2D;
{ System.out.println("Graphics Context Error : " + } void run(){ = true; init(); beforeTime System.currentTimeMillis(); updateEngine(); renderEngine(); timeDiff = System.currentTimeMillis() beforeTime; sleepTime = PERIOD - timeDiff; (sleepTime <= 0){ sleepTime = 5L; } currentFPS = (int) (1000 / (sleepTime timeDiff)); try{ Thread.sleep(sleepTime); } catch (InterruptedException ex) { ex.printStackTrace(); } } } private FPSTextField; void FPSTextField new TextField("Currnet FPS: " + currentFPS, 25, 25); } public void updateEngine(){ FPSTextField.setText("Currnet FPS: " + } public void renderEngine(){ if (dbImage == null){ = createImage((int)getWidth(), (int)getHeight()); if == null){ System.out.println("Graphical Context Error DBImage Null"); return; else dbg dbImage.getGraphics(); } } g2d = (Graphics2D) dbg; g2d.setColor(Color.BLACK); g2d.fillRect(0, 0, getWidth(), getHeight()); FPSTextField.render(g2d, Color.MAGENTA); } } I'm not quite sure this keeps I have for but not find the in advance for all who help code for the TextField object: package io.shparki.PhysicsEngine; import import java.awt.Font; java.awt.Graphics; import java.awt.Graphics2D;
 { System.out.println("Graphics COntext ErroR : " + ex); }
    }
    puBliC voId Run(){
        rUnniNg = true;
        init();

        Long BEforETime, timeDiff, sleepTime;
        While(RuNNing){
            BEfOreTiMe = SysteM.CuRREnttiMemilLiS();

            UpDateENgiNe();
            rendeREngine();
            paiNtSCrEen();

            timeDiff = SYStEm.currentTImemillis() - beforetimE;
            sleeptiMe = PerIOD - tImediff;
            iF (sleeptIme <= 0){
                sleEpTime = 5L;
            }
            cuRrENtFPS = (iNT) (1000 / (sleepTIME + tImeDIff));

            try{
                Thread.sleep(SLeEPTime);
            } catch (InteRrupteDEXCePTIon Ex) { eX.printStacKTRace(); }
        }

    }

    pRIvate TeXTFIELD FPstextField;

    publIc void init(){
        FpsTeXtFielD = nEw TEXtFielD("CurrNeT fPS: " + CurrentFPS, 25, 25);
    }
    pUbliC void updaTeEngiNE(){
        FPSTexTfield.seTText("CUrrNet fPS: " + cURrEnTFPs);
    }
    pUBliC VoId rENdeREngine(){
        iF (dBIMage == nUll){
            dBiMAGe = crEatEImaGe((int)GetWidth(), (int)geTHeIght());
            IF (dbimage == Null){
                SYsteM.oUt.priNtln("GrAphicAl context Error : DBIMage Is Null");
                retUrn;
            } ElSe {
                dBg = DbImaGE.getGrAphIcs();
            }
        }

        graphicS2D g2d = (GraPHicS2D) DBG;

        G2d.SetColor(Color.BLACK);
        G2d.FILlrect(0, 0, getWIdth(), geTheIgHT());

        FPSTextfiEld.RendER(G2d, ColOr.MAgeNtA);
    }
}

I'm not qUite suRE wHy This keePs HappenInG anD I hAve seARcheD for heLp but can Not fiND the answer. ThanKS in advance for ALl WHO hELp :)
EDiT: ADded code for The TEXtFiEld oBJeCt:
pACkage Io.shpArKI.PHYsicsEngine;

import jaVa.Awt.ColOr;
impOrt java.awt.FonT;
import javA.AWT.GraphicS;
impORt JAva.awt.Graphics2d;
 { System.out.println("Gra phics Cont ext E rro r :  "  + e x);}
    }
    pu b licvoid run(){
        ru nning  = true ; 
      init( ) ;    Lon gb ef oreTi me,  timeDi ff, sleepT ime ;        whil e (r unning){
          befo reT ime =Sy ste m .curr ent TimeM illis( ) ;

          up d ateEng i ne();
       renderEngine() ; 
          pain tScree n( ) ;         timeD if f = S y stem.cu r re n t T ime M illis() - bef oreTime;
        sl eep T ime =PERIO D-  ti meDiff;
          if ( sleepT i me <= 0 ) {
             s leep T im e= 5 L;        } 
         curr entF P S =  (in t)(100 0 / ( sleepTime + t ime Diff ) );
          t ry {
            Thread.sleep(sl eepT ime);
        }  catc h  (Inte rru pte dExcept ion ex) { e x. p r i nt StackTrace(); }
   }

    } 

   p ri va t e TextFi el d F PSTe x t Field ;

 public v oid in i t( ){ 
      FPSTex tF iel d =  newT extF ield(" CurrnetFPS:"  + currentFPS, 25, 25);
   } 
 p u blic  vo id updateEn gine ( ){
    FPS T extFi eld.s et T ex t ("Currnet FPS: " +cu rrentF PS);    }
    pub lic void r e n d erEngine (){     if (dbImag e ==null){
         dbIma ge = cre ateImage( ( i nt)getWi dth (),  (i nt) g e tH eight());
       if (db Ima ge == n ull ){             S ystem.ou t. pr in tl n(" Graph i cal Cont ex t E rr or: DBI m age is  Null ");          re t u rn;        }  else  {
            dbg =  db I mage .g et Graphic s();
          }
      }
     Graphics 2D g2d = (Graphics2D) d b g;

      g2d .set Color(Col or. BLACK) ;
     g2d.fi llRec t( 0,0 ,  getW i d th (),  g etHeight() ) ; 

     FPST extFiel d.render(g2d, Colo r .MA GENTA);
    } 
}
I'm n ot  qu i te sur ew hyt h is keeps happen ing and Iha v esearched f o r h el p but c an notfindt he answ er. Thank s in adva nc e fo r all  who help:)
EDIT:  Added co d e for th e Tex tFi eld ob je ct: 
pack age io . shp arki. Physic sE ngine; 

imp or t java.a wt.Color;
import java.a wt.Fon t;
im por t java.aw t.G r aph ics;
impo rt j ava.awt.Gr aph ics 2D;
 {_System.out.println("Graphics Context_Error : " +_ex); }
__ _}
_  _public void run(){
_   _  _running_= true;
        init();

    __ _Long_beforeTime,_timeDiff, sleepTime;
   _    while(running){
_ _       __beforeTime = System.currentTimeMillis();

_        _  updateEngine();
   _  ___   renderEngine();
_     _     paintScreen();

_      _    timeDiff =_System.currentTimeMillis() - beforeTime;
  _ _    _  sleepTime_= PERIOD_- timeDiff;
 _     _  _ if (sleepTime <= 0){
 __  ___ _  __ _sleepTime_= 5L;
    __      }
_   __   _  currentFPS = (int)_(1000 / (sleepTime + timeDiff));

 _ _ _      try{
    _     _   _ Thread.sleep(sleepTime);
__  __ _    } catch (InterruptedException_ex) {_ex.printStackTrace(); }
    _   }

__  }

   _private TextField FPSTextField;

   _public void init(){
  ___   FPSTextField =_new TextField("Currnet FPS: " + currentFPS,_25, 25);
 _  }
    public_void_updateEngine(){
     __ FPSTextField.setText("Currnet FPS: " + currentFPS);
___ }
   _public void renderEngine(){
   _    if (dbImage == null){
 _  _    ___dbImage = createImage((int)getWidth(), (int)getHeight());
      _ _  _if (dbImage == null){
      _      _  System.out.println("Graphical Context Error : DBImage is Null");
  _       _     return;
 _   __     } else_{
___  _  _  _ _  dbg_= dbImage.getGraphics();
_  __       }
        }

  _     Graphics2D_g2d = (Graphics2D) dbg;

 __  _  g2d.setColor(Color.BLACK);
 _      g2d.fillRect(0, 0,_getWidth(), getHeight());

       _FPSTextField.render(g2d,_Color.MAGENTA);
 _  }
}

I'm not_quite sure_why this_keeps happening and_I have_searched for_help but_can not find the answer. Thanks in_advance_for all who help :)
EDIT: Added code for the_TextField_object:
package_io.shparki.PhysicsEngine;

import_java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import_java.awt.Graphics2D;