title: Java Swing load file into JEditorPane
body: <p>I'm trying to write text-editor type application in Java/Swing. I have the FileChooser working and I can print out the contents of the file to the console. I want to load the file into a JEditorPane</p>
  
  <p>When I call setText(), it updates the value of the text (I can print the result of getText, but the actual EditorPane is not refreshing). I've tried calling repaint/revalidate on the JEditorPane, the encapsulating JScrollPane but nothing will refresh the text to what I sent to setText.</p>
  
  <p>Am I missing something?</p>
  
  <p>P.S. The JEditorPane is wrapped inside a JScrollPane, and I have a method in my mainEditor that passes the string to the setText method of the JEditorPane.</p>
  
  <pre><code>      if (r == JFileChooser.APPROVE_OPTION) 
        {
            FileInputStream fis;
            BufferedReader br;
            try
              {
                  fis = new FileInputStream( 
                        chooser.getSelectedFile() ) ;
                  br  = new BufferedReader( 
                        new InputStreamReader( fis ) ) ;
                  String read ;
                  StringBuffer text = new StringBuffer() ;
                  while( ( read = br.readLine() ) != null ) 
                  {
                     text.append( read ).append( "\n" ) ;
                  }
                  Main.frame.mainEditor.setText( text.toString() ) ;
                  Main.frame.mainEditor.revalidate();
              }
              catch( IOException e1 ) 
              {
                  JOptionPane.showMessageDialog( this , 
                      "Error in File Operation" ,
                      "Error in File Operation" , 
                      JOptionPane.INFORMATION_MESSAGE) ;
              }             
        }
  </code></pre>