I am making the Summarizer project in NetBeans 6.9.1 so that I have a Browse button that should open an open dialog on JFileChooser. I looked here: stack overflow
My problem is the same, I tried to install the current directory, which was tried on another similar question in stackoverflow, but even this does not work on my PC.
I still can't figure out what the heck is my mistake. I think the same error is that things do not start on EDT. I use netbeans, the code is huge. I cannot find where to make edt changes. Therefore, I will publish only the relevant part. Please take a look and tell me what I need to do to solve my problem?
private void cmdBrowseActionPerformed(java.awt.event.ActionEvent evt) {
jFileChooser1.setCurrentDirectory(new File("F:/BE-Project/Summarizer"));
jFileChooser1.setDialogTitle("Open File");
jFileChooser1.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = jFileChooser1.showOpenDialog(Summarizer.this);
if (returnVal== JFileChooser.APPROVE_OPTION) {
try {
fin = jFileChooser1.getSelectedFile();
fileContents = Files.readFromFile(fin,"ISO-8859-1");
tAreafileContents.setText( fileContents );
txtInputFile.setText( fin.getAbsolutePath() + " -- " + fin.getName());
tAreafileContents.setCaretPosition(tAreafileContents.getDocument().getLength());
}
catch (Exception e) {
System.out.println(e);
}
}
else System.out.println("there is some error");
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Summarizer().setVisible(true);
}
});
}
Please tell me if any other part of the code is needed and please help. I'm scratching my head right now.
source
share