LwjglCanvas Hangs When I Try to Quit Application

Anything libgdx related goes here!

LwjglCanvas Hangs When I Try to Quit Application

Postby tommiller » Sun Aug 11, 2019 9:06 pm

Hello,

I use LwjglCanvas to render my libgdx game in a Swing GUI. The thing is when I quit app using close icon on Desktop, app hangs forever.
As stated in LwjglCanvas documentation I used stop before closing my app.

Code: Select all
jFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

jFrame.addWindowListener(new WindowAdapter() {
   @Override
   public void windowClosing(WindowEvent e) {
      lwjglCanvas.stop();
      System.exit(0);
   }
});


The program doesn't respond at all and waits forever (or until I use Ctrl+Alt+Delete to close it forcefully!). Please help.
tommiller
 
Posts: 19
Joined: Sat Jan 20, 2018 6:54 pm

Re: LwjglCanvas Hangs When I Try to Quit Application

Postby shatterblast » Mon Aug 12, 2019 5:03 am

LibGDX really does not work well with Swing. Really old versions do, like maybe 1.0 and before, but those are not supported. You can search in this forum for other posts that mention "Swing" as to why.
shatterblast
 
Posts: 653
Joined: Sun Jul 06, 2014 1:14 pm

Re: LwjglCanvas Hangs When I Try to Quit Application

Postby tommiller » Mon Dec 09, 2019 9:21 pm

Any updates on this???
tommiller
 
Posts: 19
Joined: Sat Jan 20, 2018 6:54 pm

Re: LwjglCanvas Hangs When I Try to Quit Application

Postby shatterblast » Mon Dec 09, 2019 9:38 pm

From another post I made:
Swing derives from AWT, so I suggest looking at what LibGDX offers you in that area. I believe Swing and AWT components work together, so LibGDX should work with it from that perspective. You may also want to consider enabling VSync if you have a frame rate issue.


LibGDX provides AWT support, so you should begin with that.
shatterblast
 
Posts: 653
Joined: Sun Jul 06, 2014 1:14 pm

Re: LwjglCanvas Hangs When I Try to Quit Application

Postby tommiller » Tue Jan 07, 2020 1:00 pm

It works well with AWT? What else can I do to use Libgdx within a JFrame or something inside a desktop app?
tommiller
 
Posts: 19
Joined: Sat Jan 20, 2018 6:54 pm

Re: LwjglCanvas Hangs When I Try to Quit Application

Postby shatterblast » Tue Jan 07, 2020 2:41 pm

I don't have much experience with either AWT or Swing. I can tell you that the vast majority of UI stuff with Swing uses JFrame in some way.

So the answer is: You can probably do very much.

In most cases, you would just want to consume the contents of a JFrame and fit it into something else as a component. However, you can make the startup AWT be an entire JFrame, so your game could take up the whole window.

It is possible to mix Swing with AWT, since Swing derives from it. Good luck.
shatterblast
 
Posts: 653
Joined: Sun Jul 06, 2014 1:14 pm


Return to Libgdx

Who is online

Users browsing this forum: No registered users and 1 guest