Getting text from inside a jeditorpane inside a jtabbedpane
I have a small program that contains a jTabbedPane. Then, when the user does an action (like click a button) a new jScrollPane is created, and a new jEditorPane is placed inside it. The jScrollPane is then added to the jTabbedPane.
The jEditorPane then fills itself with information from a different file, depending on which button was clicked.
All that works fine, but the problem arrises when I want to save the information to the file later. I can't get the text from inside the jEditorPane.
Here is the method which adds a new tab:
I can't show you the save code because I really haven't got any. I know I can get the current selected component/tab from the jTabbedPane:
public void addTab()
currentFile = "The File";
//create new editor pane
DefaultSyntaxKit.initKit(); //I'm using a custom kit
JEditorPane editPane = new JEditorPane();
JScrollPane editScroll = new JScrollPane(editPane);
FileReader input = new FileReader(new File("The directory" + currentFile));
catch (IOException e)
But that has two problems:
1) It actually returns the scrollPane, not the editor
2) It returns a component , component has no getText() method
Any one got any ideas? I'm all out