opening RTF and TXT files

From: yorkmac (yorkmac_at_hotmail.com)
Date: 03/30/05

  • Next message: John McGrath: "Re: Look And Feel - ButtonUI"
    Date: Tue, 29 Mar 2005 19:14:06 -0500
    
    

    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());
        }

      };


  • Next message: John McGrath: "Re: Look And Feel - ButtonUI"