I am opening a file in a frame and I wish to highlight few of the words.As I understand,I need to traverse the content of the file. How do I traverse through the contents and what is the related property that I may use for the purpose of highlighting?
UPDATE : MY CODE GOES SOMETHING LIKE THIS
private JEditorPane editorpane;
JScrollPane editorScrollPane;
public TextEditor()
{
editorpane = new JEditorPane();
editorpane.setEditable(false);
if (filename != null)
{
try
{
File file = new File(filename);
editorpane.setPage(file.toURI().toURL());
}
catch (IOException e)
{
e.printStackTrace();
System.err.println("Attempted to read a bad file ...");
}
}
else
{
System.err.println("File name is wrong");
}
add(editorpane);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…