brokenbone
Programmer
Hi!
I'm using JFileChooser to export some data from my web application to a file. Everything is working fine, the only problem I have is when I run the application and try to export data the choose file dialog opens behind the browser window. This is quite unpleasant since the user thinks the dialog is not opened at all. This only happens the first time when the button to export the data is clicked after the application is run. Every next time the dialog gets the focus and is visible in front of the browser.
How can I set the focus to dialog the first time it opens?
My code looks like this:
Thanks in advance.
BB
I'm using JFileChooser to export some data from my web application to a file. Everything is working fine, the only problem I have is when I run the application and try to export data the choose file dialog opens behind the browser window. This is quite unpleasant since the user thinks the dialog is not opened at all. This only happens the first time when the button to export the data is clicked after the application is run. Every next time the dialog gets the focus and is visible in front of the browser.
How can I set the focus to dialog the first time it opens?
My code looks like this:
Code:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
loJFC = new JFileChooser();
loJFC.setDialogTitle("Export data");
loJFC.setFileFilter(new TextFilter()); // my class that accepts only txt files
loJFC.setAcceptAllFileFilterUsed(false);
loJFC.setSelectedFile(new File("MyFileName.txt")); // set the default name
int liRetVal = loJFC.showSaveDialog(null);
if (liRetVal == JFileChooser.APPROVE_OPTION)
{
loFile = loJFC.getSelectedFile();
}
else
{
return;
}
// then I write to file etc...
Thanks in advance.
BB