Witam
za pomocą buttona z JfileChooser wybieram plik txt którego ścieżkę wyswietlam w textFieldzie:
public void chooseFile() {
final JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int returnVal = fc.showOpenDialog(fc);
if (returnVal == JFileChooser.APPROVE_OPTION) {
f = fc.getSelectedFile();
jTextField1.setText(f.getAbsolutePath());}}
Potrzebuje wyswietlic zawartosc tego pliku w textArea. Znalazłem taką metodę ale jednak coś nie działa.
public void wyswietl() {
jTextArea1.setText("");
Grep g = new Grep(jTextField2.getText());
try {
if(f != null)
g.searchInFiles(f);
} catch (FileNotFoundException ex) {
Logger.getLogger(AplikacjaView.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(AplikacjaView.class.getName()).log(Level.SEVERE, null, ex);
}
getJTextArea1().setText(g.getFormatedSearchResults());
}
Może ktoś pomóc?