Here you can find the source of browseFileForField(JTextField textField, JFileChooser fileChooser, Component parent)
Parameter | Description |
---|---|
textField | a parameter |
public static void browseFileForField(JTextField textField, JFileChooser fileChooser, Component parent)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.io.File; import javax.swing.JFileChooser; import javax.swing.JTextField; public class Main { /**//from ww w . j a v a 2 s .co m * Uses the fileChooser to browse a (not further filtered) file and put the * path to the file in the given {@link JTextField}. * * @param textField */ public static void browseFileForField(JTextField textField, JFileChooser fileChooser, Component parent) { fileChooser.setMultiSelectionEnabled(false); int returnVal = fileChooser.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); textField.setText(file.getAbsolutePath()); } } }