1
我想說明,在JFrame
選擇了與JFileChooser
上JTextarea
選定的文件,如:顯示選定的文件
JTextArea textArea = new JTextArea(6, 12);
contentPane.add(textArea);
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setDialogTitle("XML Datei auswählen");
int ret = fileChooser.showDialog(fileChooser, "auswählen");
if (ret == JFileChooser.APPROVE_OPTION) {
file3 = fileChooser.getSelectedFile().getAbsoluteFile();
textArea.setText(file3.getName());
但它表明我的textarea的什麼都沒有,我究竟做錯了什麼?