Here you can find the source of browseFileForList(DefaultListModel listModel, JFileChooser fileChooser, Component parent)
Parameter | Description |
---|---|
textField | a parameter |
public static void browseFileForList(DefaultListModel listModel, JFileChooser fileChooser, Component parent)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.io.File; import javax.swing.DefaultListModel; import javax.swing.JFileChooser; public class Main { /**//from w ww . ja v a 2 s . c o m * Uses the fileChooser to browse a (not further filtered) file and put the * path into the list(-model) * * @param textField */ public static void browseFileForList(DefaultListModel listModel, JFileChooser fileChooser, Component parent) { fileChooser.setMultiSelectionEnabled(true); int returnVal = fileChooser.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { for (File file : fileChooser.getSelectedFiles()) { listModel.addElement(file.getAbsolutePath()); } } } }