Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Pedro Silva   on Jan 23 In Java Category.

  
Question Answered By: Fred Hicks   on Jan 23

i got ur mail here and posting my idea to read  the RTF file in SWINGS. u can
use the
same logic in ur invisible application  too.

u can read and write any type of file in java using java.io.Reader


The code listing is for RTFView.java is as follows:

import java.awt.*;import java.io.*;import javax.swing.*;import
javax.swing.text.*;import javax.swing.text.rtf.*;class RTFView extends JFrame{
public RTFView() { setTitle( "RTF text  Application" ); setSize( 400, 240 );
setBackground( Color.gray ); getContentPane().setLayout( new BorderLayout() );
JPanel topPanel = new JPanel(); topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel, BorderLayout.CENTER ); // Create an RTF editor
window RTFEditorKit rtf = new RTFEditorKit(); JEditorPane editor = new
JEditorPane(); editor.setEditorKit( rtf ); editor.setBackground( Color.white
); // This text could be big so add a scroll pane JScrollPane scroller = new
JScrollPane(); scroller.getViewport().add( editor ); topPanel.add( scroller,
BorderLayout.CENTER ); // Load an RTF file into the editor try {
FileInputStream fi = new FileInputStream( "test.rtf" ); rtf.read( fi,
editor.getDocument(), 0 ); } catch( FileNotFoundException e ) {
System.out.println( "File not found" ); } catch( IOException e ) {
System.out.println( "I/O error" ); } catch( BadLocationException e ) { } }
public static void main( String args[] ) { // Create an instance of the test
application RTFView mainFrame = new RTFView(); mainFrame.setVisible( true );
}}


i want to handle doc  files into my application, i want to read rich text format
and save  the work  into my application as doc files  that is redable by MS Word
and in the same time  the word  must keeps all formating done into my application

can any1 give  me some help  or giude me to a place  i may find  the info  i need,

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on dealing with doc files Or get search suggestion and latest updates.


Tagged: