Re: File browser
On Tue, 05 Feb 2008 18:35:05 -0800, Daniel Pitts =
<newsgroup.spamfilter@virtualinfinity.net> wrote:
The rule is that you "MUST" if you want to be able to easily prove the=
=
correctness of your program. If you don't, the program *may* function=
=
as expected, but may have subtle problems that arise in circumstances =
=
that you can't predict (multi-core CPUs for instance, or OS thread =
scheduling decisions.
Okay, well it's easy enough to change.
That said, I did write a sample program that all it does is initialize t=
he =
look-and-feel according to the method you suggested, and then shows the =
=
JFileChooser. All on the EDT thread. The dialog works (and doesn't wor=
k) =
exactly as it did before.
I can post the code here, though I'm not sure what the point of that wou=
ld =
be. It's reasonably short though, so I'll go ahead and attach it below.=
Pete
import java.io.File;
import javax.swing.*;
public class TestFileChooser
{
/**
* @param args
*/
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
init();
}
});
}
private static void init()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClas=
sName());
}
catch (Exception e)
{
throw new RuntimeException(e);
}
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
JFileChooser chooser = new JFileChooser();
chooser.setSelectedFile(new File("Test Filename.txt"));
chooser.showSaveDialog(null);
}
}