0
안녕하세요, 나는 자바 프로그래밍에 익숙하지 않고 몇 가지 옵션과 파일 선택기로 자바 메뉴를 만들었습니다. 따라서 내 IDE에서 파일 이름과 사용자가 선택한 파일의 경로를 출력합니다. 사용자가 실제 출력을 볼 수 있도록 프레임에 텍스트 영역을 만들 수있는 방법이 있습니까? 이것은 내 파일 선택기가 어떻게 보이며 콘솔에서 결과를 출력하는 방법입니다. 여기 자바 스윙은 출력을위한 텍스트 영역을 만듭니다
JFileChooser chooser = new JFileChooser();
File F = new File("C:/");
File namedir;
File namepath;
chooser.setCurrentDirectory(F);
chooser.showOpenDialog(null);
chooser.setDialogTitle("Choose file to play");
chooser.setApproveButtonText("Play");
namedir = chooser.getCurrentDirectory();
namepath = chooser.getSelectedFile();
System.out.print("the name of the the directory is "+namedir.getName());
System.out.print("the name of the the path is "+namepath.getAbsolutePath());
그리고
는 내가 필요로하는 것은 내가 출력 파일 이름과 내 프레임의 경로를 할 수 있도록 텍스트 영역 내 메뉴JFrame frame = new JFrame("Menu");
frame.setVisible(true);
frame.setSize(600,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//add the menu bar with the item browse
JMenuBar bar = new JMenuBar();
frame.setJMenuBar(bar);
JMenu search = new JMenu("Browse");
bar.add(search);
코드입니다.
원하는대로 JTextArea ... setText를 사용하고 해당 영역을 프레임에 간단하게 추가하십시오. – TeamIncredibles