Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2005

Tip: Looking for answers? Try searching our database.

opening  RTF and TXT files

Thread view: 
yorkmac - 30 Mar 2005 01:14 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.