0
JFileChooser
을 사용하여 데스크탑에서 이미지를 JTextArea
으로로드하지만 PC에서 이미지를로드하면 소프트웨어가 중지됩니다.스윙을 사용하여 JTextArea로 이미지를로드 할 수 없습니다.
다음은 파일 선택기의 OpenActionPerformed
메소드 코드입니다.
private void OpenActionPerformed(java.awt.event.ActionEvent evt) {
int returnVal = fileChooser.showOpenDialog(this);
if (returnVal == fileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
try {
// What to do with the file, e.g. display it in a TextArea
textarea.read(new FileReader(file.getAbsolutePath()), null);
} catch (IOException ex) {
System.out.println("problem accessing file"+file.getAbsolutePath());
}
} else {
System.out.println("File access cancelled by user.");
}
하지만 Netbeans를 사용하고 있습니다. 거기에 대한 옵션이 없습니다 –
@ Vipul.Johri 첫째, 나는 netbeans 양식 편집기를 사용하여 중지하고 귀하의 UI를 코딩 손 시작, 그것은 API에 대한 더 나은 감사를 줄거야 두 번째 예, 그렇지 않습니다 – MadProgrammer