2 Replies Latest reply: Oct 14, 2011 9:14 AM by shakir.gusaroff RSS

    Displaying Open Office word doc in browser using JavaFX

    894508
      My requirement is to display open office doc in my application for modification
        • 1. Re: Displaying Open Office word doc in browser using JavaFX
          aidreamer
          A Google search reveals this library for writing the files: http://odftoolkit.org/projects/odfdom/pages/Home

          But I very much doubt there is anything out there to render it in JavaFX, so you will have to write the UI on your own.
          • 2. Re: Displaying Open Office word doc in browser using JavaFX
            shakir.gusaroff
            Hi. The following works for Microsoft Word docs and Notepad.
            import javafx.application.Application;
            import javafx.event.ActionEvent;
            import javafx.event.EventHandler;
            import javafx.scene.Group;
            import javafx.scene.Scene;
            import javafx.scene.control.Button;
            import javafx.stage.Stage;
            
            /**
             *
             * @author gusaros
             */
            public class OpenOffice extends Application {
            
                /**
                 * @param args the command line arguments
                 */
                public static void main(String[] args) {
                    Application.launch(args);
                }
            
                @Override
                public void start(Stage primaryStage) {
                    primaryStage.setTitle("Hello World");
                    Group root = new Group();
                    Scene scene = new Scene(root, 300, 250);
                    Button btn = new Button();
                    btn.setLayoutX(100);
                    btn.setLayoutY(80);
                    btn.setText("Hello World");
                    btn.setOnAction(new EventHandler<ActionEvent>() {
            
                        public void handle(ActionEvent event) {
                            String[] cmdArray = {"cmd", "/c", "start", "c:\\fdres.doc"};
            
                            try {
                                java.lang.Runtime.getRuntime().exec(cmdArray);
                            } catch (Exception s) {
                            }
            
            
                        }
                    });
                    root.getChildren().add(btn);
                    primaryStage.setScene(scene);
                    primaryStage.show();
                }
            }