I am developing an application where, when I select a value(file) from list it should be opened in jTextPane of a different form. I am using two panels one is mainpanel where my list is shown and one is ExcelSheet, when i click on a list value then mainpanel is closed and new form ExcelSheet is displayed but not the content of doc file in jTextPane.
XWPFWordExtractor extractor=null;
File file=null;
String str=(String) list.getSelectedValue();
mainPanel.setVisible(false);
new ExcelSheet().setVisible(true);
ExcelSheet obj=new ExcelSheet();
try {
file=new File("C:\\Users\\Siddique Ansari\\Documents\\CV Parser\\"+str);
FileInputStream fis=new FileInputStream(file.getAbsolutePath());
XWPFDocument document=new XWPFDocument(fis);
extractor = new XWPFWordExtractor(document);
String fileData = extractor.getText();
Document doc = obj.jTextPane1.getDocument();
System.out.println(fileData);
doc.insertString(doc.getLength(), fileData, null);
}
catch(Exception exep){exep.printStackTrace();}