I recently ported my measly game to LWJGL for performance reasons and discovered that (on windows at least) the JFileChooser I was using in the built in map editor didn’t like to grab focus from the main LWJGL window. After some googling and I couldn’t find a solution and decided to just mess with it a little. The solution I found to work for me is to simply create an invisible frame to steal focus from the LWJGL window and then display the file chooser. I thought I’d share my solution as I had trouble finding one on my own. If anyone else has a more elegant solution please let me know
The code is fairly simple but here it is for the noobs.
Frame frame = new Frame();
frame.setUndecorated(true);
frame.setOpacity(0);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.toFront();
frame.setVisible(false);
frame.dispose();
// File chooser stuff here