i am making a wordprocessor that can open .RTF files. is their any way i
can make it open .txt files also this is the code for opening RTF files
Action actionOpen = new AbstractAction("Open",iconOpen){
public void actionPerformed (ActionEvent e)
{
WordPad.this.setCursor(
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Thread runner = new Thread()
{
public void run()
{
if (myChooser.showOpenDialog(WordPad.this)!=
JFileChooser.APPROVE_OPTION)
return;
WordPad.this.repaint();
File fileChoosen = myChooser.getSelectedFile();
try{
InputStream in = new FileInputStream (fileChoosen);
myDoc = new DefaultStyledDocument(myStyleContext);
myKit.read(in,myDoc,0);
myOutput.setDocument(myDoc);
in.close();
}
catch (Exception ex){
ex.printStackTrace();
}
WordPad.this.setCursor(Cursor.getPredefinedCursor
(Cursor.DEFAULT_CURSOR ) );
}
};
runner.start();
myDoc.addUndoableEditListener(new Undoer());
}
};
Henrik Skovgaard - 31 Mar 2005 13:16 GMT
I found this example, maybe you can use it..
http://lumumba.luc.ac.be/~emile/project%203.1/SimpleTextEditor.java
/Henrik
>i am making a wordprocessor that can open .RTF files. is their any way i
> can make it open .txt files also this is the code for opening RTF files