Hey, I'm having problems with JTextPane, I have class which has gui and other class for the software logic (in this case text editor), so when I try to save a file using filechooser it works fine to the point where it needs to save the information from the JTextPane, it saves the file with the correct file name, but it's always empty.
I'm going to demonstrate it with some piece of code (nothing too fancy, just so you get the idea).

public class Gui extends javax.swing.JFrame {
public Gui() {
textarea = new JTextPane();
dialog = new JDialog();

public JDialog dialog;
public JTextPane textarea;
}
}

Then I have the other class:

public class texteditor() extends Gui{
public void test(){
textarea.setText(""); //Calling this in the gui doesn't work
dialog.setVisible(true);//This on the other hand works

}
}

Hope I demonstrated the problem clearly enough.

Do you take the text from the JTextPane, and do you write it to the file?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.