ANT Java dialogs appearing behind oXygen fix
Posted by jtakeda on 08 May 2018 in Activity log
Pop up dialog boxes created from embedded Javascript in Ant were appearing behind oXygen, which wasn't very user friendly. I posted a ticket on the Oxygen forum (https://www.oxygenxml.com/forum/topic16346.html) and the solution suggested worked. Basically, I had to create an empty JFrame and then place the other dialog boxes on top of them. It slows down the process slightly, but I'd rather sacrifice speed for usability. Code below posted for future reference:
//Create a new Jframe
var frame = new javax.swing.JFrame();
//Set it on top
frame.setAlwaysOnTop( true );
//Set location
frame.setLocationByPlatform( true );
frame.setLocationRelativeTo(null);
//Close it when it closes
frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
//No decoration
frame.setUndecorated(true);
//Display it
frame.pack();
frame.setVisible(true);
//Now get the inputter for the message
var inputter = new javax.swing.JOptionPane();
//Put the dialog there and show the message with the frame as its parent.
var message = javax.swing.JOptionPane.showInputDialog(frame, "Please enter a short message summarizing what you did today.");
//If the message is empty, break.
if (message.isEmpty()){
javax.swing.JOptionPane.showMessageDialog(null, "No message entered. Aborting.");
throw "Process cancelled. Aborting!";
}
//Set the message property in ANT
project.setProperty("message", message);