JFileField Swing component

May 4th, 2008

While programming simple Java swing applications, I often found myself writing a combination of a JTextField and a JButton (”Browse…”) when prompting the user to select a file. The JButton would then bring up a JFileChooser and the path to the selected file would show up in the text field. To make this easier, I have written a simple JFileField class that encapsulates the browse functionality. Its source (JFileField.java) and Javadoc (JFileField.html) are available.

Note that the component was originally created in the NetBeans IDE 6.0, so some remnants of the NetBeans form editor are still present in the Java source. This does not matter, however, since NetBeans generates highly portable code.

Leave a Reply