현재 아래 코드에 따라 JTextField를 사용하여 파일 위치를 입력하는 JFrame 응용 프로그램이 있습니다. 내가하고 싶은 무엇자바 스윙 - 파인더 텍스트 상자
txtSource = new JTextField();
txtSource.setToolTipText("/location/of/file/test.txt");
txtSource.setText("/location/of/file/test.txt");
txtSource.setBounds(16, 122, 412, 29);
contentPane.add(txtSource);
txtSource.setColumns(10);
는 사용자에 대한 디렉토리 검색은 로컬 컴퓨터에있는 파일의 위치를 선택하고 해당 위치가 텍스트 상자에 채우는 것입니다 수 있습니다.
아래 정보가 JCHooser에서 발견되었지만 구현 방법에 대한 도움이 필요하시면 잘 모르겠습니다. 사전에
String filename = File.separator+"tmp";
JFileChooser fc = new JFileChooser(new File(filename));
// Show open dialog; this method does not return until the dialog is closed
fc.showOpenDialog(frame);
File selFile = fc.getSelectedFile();
// Show save dialog; this method does not return until the dialog is closed
fc.showSaveDialog(frame);
selFile = fc.getSelectedFile();
덕분에
http://jsfiddle.net/arunpjohny/k24471o6/1/ –