intel1993 / jsyntaxpane

Automatically exported from code.google.com/p/jsyntaxpane
0 stars 0 forks source link

JSyntaxPane hangs on loading text file #163

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago

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

GoogleCodeExporter commented 8 years ago
Even small files (of 2kb) are also not loading.

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

GoogleCodeExporter commented 8 years ago
Why not the read method above?

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