nordfalk/jsyntaxpane

JSyntaxPane hangs on loading text file

Closed this issue · 4 comments


public void loadProgramFile(String filename) throws IOException{

        StringBuffer file_contents = new StringBuffer(256);
        String file_path = Settings.SETTINGS_DIR + "/" 
                + Settings.FILES_DIR + "/" + filename;
        File program_file = new File(file_path);

        epane_codeeditor.setContentType("text/cpp");

        BufferedReader input =  
                new BufferedReader(new FileReader(program_file));
        try {
            String line = null;
            while (( line = input.readLine()) != null){
                file_contents.append(line);
file_contents.append(System.getProperty("line.separator"));
            }
        }
        finally {
            input.close();
        }
        epane_codeeditor.setText(file_contents.toString());
}

the program hangs when executing the last statement
"epane_codeeditor.setText(file_contents.toString());"

private JEditorPane epane_codeeditor; // class member

in constructor
...................................................
DefaultSyntaxKit.initKit();
epane_codeeditor = new JEditorPane();
pan_top_right.add(epane_codeeditor);
JScrollPane spane_epane_codeeditor = new JScrollPane(epane_codeeditor);
pan_top_right.add(spane_epane_codeeditor,"span 3,growx,gaptop 2");
epane_codeeditor.setContentType("text/c");
.....................................................

uses miglayout as layout manager
and jSyntaxPane jsyntaxpane-0.9.5-b29.jar

................................................

How can i solve this issue....??





Original issue reported on code.google.com by suhaib...@gmail.com on 13 Oct 2010 at 2:29

Why dont you use the read method of the JeditorPane?  it will save you a lot of 
code.  Just supply a FileReader and you are done.
How big is the file?

Original comment by ayman.al...@gmail.com on 30 Oct 2010 at 4:17

Original comment by ayman.al...@gmail.com on 30 Oct 2010 at 4:17

Even small files (of 2kb) are also not loading.

Original comment by suhaib...@gmail.com on 30 Oct 2010 at 9:06

Why not the read method above?

Original comment by ayman.al...@gmail.com on 30 Oct 2010 at 12:37