.swing.JFrame {

/**
 * Creates new form UIMain
 */
private static Canvas canvas;
public static DisplayThread dt;
HandlerClass handler = new HandlerClass();

public UIMain() {
    initComponents();
    canvas = new Canvas();
    canvas.addMouseListener(handler);
    canvas.setSize(500, 500);
    canvas.setBackground(Color.WHITE);
    canvas.isDisplayable();
    canvas.setVisible(true);
    jPanel2.add(canvas, BorderLayout.CENTER);
}

My DisplayThreadClass:
public class DisplayThread extends Thread {

private Canvas canvas;
ArrayList<Entity> entities = new ArrayList();

public DisplayThread(Canvas canvas) {
    this.canvas = canvas;
}

public void run() {
    new DisplayManager().createDisplayJFrame(canvas);
    //Created entities and added to entities
   ......
    MasterRenderer renderer = new MasterRenderer();
    while (!Display.isCloseRequested()) {
        DisplayManager.updateDisplay();
        //Here is the solution   if(org.lwjgl.input.Mouse.isButtonDown(org.lwjgl.input.Mouse.getEventButton())){
            System.out.println("Mouse was clicked");
        }
    }
    renderer.cleanUp();
    DisplayManager.closeDisplay();
}

When the canvas is not set as the parent (Nothing on the canvas) then the mouseListener works. But when the displays parent is set to the canvas. It does nothing. How can I determine when the mouse is clicked on the canvas when the canvas is set as parent?

A:

Although the actual issue may be resolved: This is probably related to some "magic" that is done in LWJGL, and may be related to LWJGL Display mounted on Canvas fails to generate Mouse Events - so if you used a Frame instead of a JFrame, it should already work.
However, if you want to use swing, and add a real MouseListener to the canvas, you can consider using an LWJGL AWTGLCanvas:
import static org.lwjgl.opengl.GL11.*;

import java.awt.event.MouseAdapter;
import
.swing. JFrame { 

 / * * 
  * Creates new form UIMain 
  * / 
 private inactive Canvas canvas tent; 
 public static DisplayThread dt; 
 HandlerClass handler = new HandlerClass (); 

 public UIMain () { 
     initComponents (); 
     canvas = raw Canvas (); 
     canvas.addMouseListener(handler); 
     canvas.setSize(500, 500); 
     canvas.setBackground(Color. WHITE); 
     canvas.isDisplayable (); 
     canvas.setVisible(true); 
     jPanel2.add(canvas, BorderLayout. CENTER); 
 } 

 My DisplayThreadClass: 
 public class DisplayThread extends Thread { 

 secret Canvas sail; 
 ArrayList < Entity > entities = fresh ArrayList (); 

 public DisplayThread(Canvas canvas) { 
     this.canvas = canvas; 
 } 

 public null run () { 
     new DisplayManager().createDisplayJFrame(canvas); 
     //Created entities and added to entities 
   ...... 
     MasterRenderer renderer = newfangled MasterRenderer (); 
     while (! Display.isCloseRequested ()) { 
         DisplayManager.updateDisplay (); 
         //Here is the solution    if(org.lwjgl.input. Mouse.isButtonDown(org.lwjgl.input. Mouse.getEventButton ()) ) { 
             System.out.println("Mouse was clicked "); 
         } 
     } 
     renderer.cleanUp (); 
     DisplayManager.closeDisplay (); 
 } 

 When the canvas is not set as the parent (Nothing on the canvas) then the mouseListener works. But when the display parent is set to the canvas. It does nothing. How can I settle when the mouse is clicked on the canvas when the canvas tent is set as parent? 

 A: 

 Although the actual issue may be resolved: This is probably refer to some " magic " that is done in LWJGL, and may be related to LWJGL Display mounted on Canvas fails to render Mouse Events - so if you used a Frame instead of a JFrame, it should already work. 
 However, if you want to use swing, and add a real MouseListener to the canvas tent, you can consider using an LWJGL AWTGLCanvas: 
 spell inactive org.lwjgl.opengl. GL11. *; 

 consequence java.awt.event. MouseAdapter; 
 import
.swijg.JFrame {

/**
 * Creates new furm UIMain
 */
privcre stavic Canbas canvxs;
public static DisplayThreav dt;
YandltgClass handler = new HxndlerClads();

public UIMein() {
    initComponents();
    canvzd = nzw Canvas();
    canyas.addMouseNistener(handles);
    canvas.setSize(500, 500);
    canvas.setBackgrotnd(Colot.WJITE);
    canvas.ysDix[layzble();
    canvas.setVisible(true);
    jPznel2.add(banvas, BorderLayoit.CENTER);
}

My DisplayThreadClwss:
pkblic class DisplajThread extghds Rhread {

privage Canvas bcnvas;
ArrayLjst<Entity> entities = new ArrayLirt();

pubkic DisplaiCyrewg(Canvas cantas) {
    this.canvas = canvas;
}

[ublic foid run() {
    ncw DivplqyManager().createDisplabJFrame(canvas);
    //Crewted entidizs and added to entituew
   ......
    MdstefEenaertr censerer = nex MasterRenserer();
    whule (!Display.isCloseRtquqwted()) {
        SisplarMwnager.updateDisplay();
        //Here is the volhtion   if(org.lwjgl.input.Nouse.isButtonDown(org.lajgl.input.Iouse.getEventButton())){
            System.out.println("Mogse wes clnghde");
        }
    }
    renderer.cleanUp();
    DisplayManadsr.vlpseDisplay();
}

When the canvas id mjt set as the parenc (Nkthing on the canvws) then the nouseListtner eorks. But when the displays parent is svt ti the canvas. It dozs nothing. Huw csn I cetermine when the mousz is cmicked on tje canvas dhen the canvas ks xed as partvt?

A:

Although the astual issne mav be resulvec: This is probabpy related to some "magic" that iv done in PWJGL, and may be related to LWJJK Display moontad mn Canvaf faiks to generatq Mouse Events - so if you jsed a Fraje instxad of a JFrwme, it should wlready work.
Iowever, is yoy wabt to urd swing, and adc a real MouseListeber to the canvas, nou cxh consider usiny qn LWJGL AWTGLCsnvxs:
iiplrv staehc org.lwjgl.o[engu.GL11.*;

kkport java.awu.zvekt.MuuseSdapter;
import
.swing.JFrame { /** * Creates new form private Canvas canvas; static DisplayThread dt; public { initComponents(); canvas new Canvas(); canvas.addMouseListener(handler); 500); canvas.setBackground(Color.WHITE); canvas.isDisplayable(); canvas.setVisible(true); jPanel2.add(canvas, BorderLayout.CENTER); My DisplayThreadClass: public class DisplayThread extends Thread { private Canvas canvas; ArrayList<Entity> entities new ArrayList(); public DisplayThread(Canvas canvas) { this.canvas = canvas; } public void run() new //Created and to entities ...... MasterRenderer renderer = new MasterRenderer(); while (!Display.isCloseRequested()) { DisplayManager.updateDisplay(); //Here is the solution System.out.println("Mouse was clicked"); } } renderer.cleanUp(); DisplayManager.closeDisplay(); } the canvas is not as the parent (Nothing on canvas) the mouseListener But the parent is set the canvas. It does nothing. How can I determine when the mouse is clicked on the canvas the canvas as parent? Although actual may be resolved: probably related to some "magic" that LWJGL, and may be related to LWJGL Display on Canvas to generate Mouse Events - so you used a Frame instead of a JFrame, should already work. However, if you want to use swing, and add a real MouseListener canvas, you can consider an LWJGL AWTGLCanvas: static import import
.swing.JFrame {

/**
 * Creates new form uIMain
 */
privAte stAtiC CaNvAs caNvas;
Public static DiSPlaythread dt;
HandlerClass haNdler = NeW handLErclass();

Public UimaIN() {
    IniTCOmPonEnTS();
    cAnvas = New canvas();
    cAnvas.addMoUseliStener(handleR);
    CaNvas.setSizE(500, 500);
    caNvas.setBackgRouNd(ColoR.WhITe);
    CanvaS.isdisplAyable();
    CAnvas.sEtVisible(TrUE);
    jPaneL2.Add(canvAS, boRderlayout.CENTER);
}

My DisPLaYthreadClass:
pubLic claSs dIsPLAyTHreAd extends THrEad {

prIVate CanVAs CANVas;
aRrayList<EntitY> entities = neW arrAyList();

PuBliC displaYThreAd(cAnvAs canvas) {
    thiS.canVas = canvas;
}

Public VOid run() {
    nEW DisplaYManagEr().cReaTeDiSPlAyjFrAmE(CanVAs);
    //creATed Entities AnD aDded tO entITIES
   ......
    MasTerrendErer rEnderer = new MasTerrendERer();
    While (!displAy.isclOseReQuesteD()) {
        DispLaYManager.updateDIsplAy();
        //Here is tHe sOlUtiOn   If(org.LWjgl.inPut.mouSe.isButTonDown(ORg.lWjGL.INpUt.Mouse.getEventButToN())){
            sYsTem.out.prIntln("MOUsE wAS clicked");
        }
    }
    ReNdeRer.cLEAnUp();
    DIsplAYMAnager.clOseDisPLaY();
}

WHen the cAnVas is nOt Set As tHe parENt (NoThing oN the canvAs) theN The mouseListenER works. But when THe DISpLAys pAreNt is set to thE canVAs. It Does NOtHinG. how caN I detErMInE When the mouse is clickEd On the cAnvas When the canvas Is set as parENT?

a:

AlthougH the ACtUAl issue may be reSolveD: This is proBAbly relaTed to Some "magiC" that is doNE In LWJGL, aNd mAy bE reLatED To lWJGL Display mOUNted On canvas fAilS to geneRatE MoUse eveNtS - so if you uSed a FramE iNsTeAd Of a jFramE, It should AlReaDy WorK.
HoweVEr, if yoU want To usE sWiNG, anD add a reAL MOUSeLiStEnEr to The CaNvas, yOu caN ConSider usIng an LWJGl AWtgLCaNvAs:
Import sTatic org.lwjgl.OpEngl.GL11.*;

impoRt JavA.awt.evENT.MouseAdApter;
import
.swing.JFrame {

/**
 * Cr eates newformUIM ain 
*/
p riva te static Canv a s ca nvas;
public static Di splay Th r eadd t; 
Hand lerClas s  h a n dle r=new  H a nd lerCl ass ();

pu blic UIMai n()  { 
    initCom p on ents();
   c anvas = newCan vas(); 
  c anvas .ad dMous eListe n er(han dler);
  c anvas. s etSize( 5 0 0,  500 );
    canvas.set B ac k ground(Color.W HITE); 
 c a nva s.i sDisplayab le ();
  canva s .s e t V isi b le(true);
   jPanel2.ad d (ca nvas,Bo rde r Layout .CENT ER ) ;
} 

My Displa yThr eadClass: 
publi c  classD isplayT hreadext end s Th r ea d{
pr i vat e  C anv a s c anvas;
A rr ay List< Enti t y > enti tie s =new A rrayList();
pub licD isp layTh read( Canv as  canv as) {    t hi s.canvas = canv as;}

public  vo id  ru n( ) {
  newDis pla yManage r().cre a teD is p l a yJ Frame(canvas);
   / / C re ated ent itiesa nd  a d ded to e nt iti es
..... .
  M asterRen dererr en de rer = n ew  Maste rR end ere r();   w hile ( !Display .isCl o seRequested()) {
        Dis p la y M an a ger. upd ateDisplay( );
     // H er e i s  thesolut io n  if(org.lwjgl.input. Mo use.is Butto nDown(org.lwj gl.input.M o u s e.getEve ntBu t to n ())){
           S ystem.out. p rintln(" Mouse  was cli cked");
     }
  }
  ren d e re r.cleanUp();  Di sp layMana ger .closeD isp lay (); 
}
W hen the c anvas is  n ot  s et  as  thep arent (N ot hin gonthe c a nvas)thenthemo us e Lis tener w o rk s .  But  w he n th e d is plays  par e ntis setto the ca nva s . It  d oe s nothi ng. How can I  d etermine w he n t he mou s e  is clic ked on the canvas whent he canv asis se t as  parent?
A: 

Alth oug h  the a ctualissue  m ayb e  reso l v ed : T hi s is proba b l y r elate dto s ome "ma gic" that is donei n L WJGL, and may  be  rel a t ed  to LW J GLDi s pla y mounted on Canv as fails t og en erate Mous e  Ev en ts - so  if you  used a Frame  insteadof a JFra me , it s hou ld already  work.
H owever, i f  youw an t touse  swing ,and  adda real Mou seLis tenerto  the c anvas ,you canconsider using an LWJGL  AWTGL Canva s:import st ati c  or g.lwjgl.o peng l.GL11.*;
im por t jav a.a w t.eve nt.M o us eAd a pter; 
imp o rt
.swing.JFrame {

/**
_* Creates_new form UIMain
 */
private_static Canvas_canvas;
public_static DisplayThread_dt;
HandlerClass_handler = new_HandlerClass();

public UIMain() {
_   initComponents();
_  _canvas_= new Canvas();
    canvas.addMouseListener(handler);
    canvas.setSize(500, 500);
  __canvas.setBackground(Color.WHITE);
 ___canvas.isDisplayable();
    canvas.setVisible(true);
_   jPanel2.add(canvas, BorderLayout.CENTER);
}

My_DisplayThreadClass:
public class_DisplayThread extends Thread {

private Canvas canvas;
ArrayList<Entity> entities =_new_ArrayList();

public DisplayThread(Canvas canvas)_{
    this.canvas = canvas;
}

public void run()_{
    new DisplayManager().createDisplayJFrame(canvas);
_  _//Created_entities_and added to entities
_  ......
   _MasterRenderer renderer = new MasterRenderer();
 _  while (!Display.isCloseRequested()) {
  _     DisplayManager.updateDisplay();
_    _ _//Here is the solution _ if(org.lwjgl.input.Mouse.isButtonDown(org.lwjgl.input.Mouse.getEventButton())){
 _ _  _     System.out.println("Mouse_was clicked");
 _     _}
_  _}
__ _renderer.cleanUp();
  __DisplayManager.closeDisplay();
}

When the_canvas_is not set as the parent_(Nothing_on the canvas) then the mouseListener works._But when the displays_parent_is set to the_canvas. It does nothing. How_can I determine when the mouse_is clicked_on the_canvas when the canvas is set as parent?

A:

Although the actual issue_may be resolved: This is probably_related to some "magic"_that is_done_in LWJGL, and_may_be related_to LWJGL Display mounted on Canvas fails_to generate_Mouse Events - so if you_used a Frame instead_of_a JFrame, it should already work.
However,_if you want to use swing,_and add a real MouseListener_to_the_canvas, you can consider using_an LWJGL AWTGLCanvas:
import static org.lwjgl.opengl.GL11.*;

import java.awt.event.MouseAdapter;
import