I am trying to make a Text Editor in Java , but I have a few problems.
I can add an image to the with JTextPane with insertIcon(), but when I save it the file is empty ,I am trying to save it as a .doc . Its the same when I try to change the font , it works in JTextPane but when I save its a default font , not the font/size I had.
This is my saveFile method:
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(filename));
writer.write(text.getText());
writer.close();
saved = true;
} catch (IOException err) {
err.printStackTrace();
}
}
Thanks in advance :P
EDIT:
I am inserting an image in my JTextPane like this :
JFileChooser open = new JFileChooser();
open.showOpenDialog(null);
File file = open.getSelectedFile();
Icon image = new ImageIcon(String.valueOf(file));
text.insertIcon(image);
I am saving the JTextPane to a file using the saveFile method from above. The image is being added to the JTextPane , everything is fine .But when I open the file the image isnt there.