Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting a Word doc into a Gui.

 
Scotty Steven
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a word document (a tutorial) that I want to open in a swing type window. It has both text and pictures. What I'm looking to accomplish is when the user selects the item from a menu in a larger program, this event will a new class and in that class, a "window" opens displaying the pics and text, pretty much as formatted. I want to use, but have no clue as to accomplish it. I'm new to programming, and have tried this on my own with no luck at all, so help will be appreciated.

If you tell me how to upload the file, I will, but I get a: Files with the extension (.rar)(docx)(rtf) are not allowed as attachment in the message. each time I try.
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to rephrase your requirement. Frankly speaking, I (at least) cannot figure out what you are trying to do here. Uploading a file typically indicates a server side component. What is it's relation to the Swing UI? Regarding richly formatted text component, you might want to check out http://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html
 
Scotty Steven
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to upload the word document that I'm working with to this board, but but the board doesn't allow .rar, .docx, or .rtf files to be attached, so if someone needs the file, I will need your emaill address.

I want to take the contents of a word document, that includes both pictures and text, and incorporate it into a larger program. That's all. Nothing nearly as fancy as your post indicated.

I hope that makes things a little clearer.
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what you're saying is that you'd like to display your Word document in a Java program, right?

Apache POI (<-link) might be of some use.
 
Scotty Steven
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Riaan Nel

I am trying to run Apache POI, but I get the following error:

Failed to load Main-Class manifest attribute from
C:\Users\Scotty\Desktop\poi-3.7\poi-3.7-20101029.jar

Any ideas why this might be?
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't run POI as a stand-alone program, but it offers an API you can call from within your own program if you put the JAR file on your application's classpath.
By the way, a simpler alternative might be using something like a JTextPane to display an HTML formatted document.
You wouldn't need to mess about with external libraries like Apache POI if you save the document as a web page (.html) in Word - usually yielding some of the most horrific HTML of all time.
Don't know if that's a usable alternative, but I figured it was worth mentioning.
 
Tim Moores
Bartender
Posts: 2842
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Writing a Word viewer component in Swing would be a major undertaking; you could probably make money selling that. If this viewer component isn't the main point of your app, I predict that you will end up not doing it.

What's the advantage of displaying such a document in a Swing component instead of using an existing desktop app (assuming that some office app is installed, obviously)?
 
Scotty Steven
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I am not explaining myself correctly. I have a tutorial. It happens to be saved as a word document. I want to take each part of the word document. cut them out of the document, and past them into a frame. Once built, I never want to use the word file again.

So really, what I'm asking is, how can I display text and pictures together, at the same time in a frame. There might be a paragraph of text, then a picture, then some more text, a table, more text, ect.
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:Writing a Word viewer component in Swing would be a major undertaking; you could probably make money selling that. If this viewer component isn't the main point of your app, I predict that you will end up not doing it.

What's the advantage of displaying such a document in a Swing component instead of using an existing desktop app (assuming that some office app is installed, obviously)?

@OP - I agree with Tim. When I need some or other external functionality (e.g. opening a Word document), I tend to try and pass it to an external application that knows how to handle it, rather than reinvent the wheel.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to take each part of the word document. cut them out of the document, and past them into a frame. Once built, I never want to use the word file again.


In that case I would certainly externalize the content you want to display in HTML form, rather than as a MS Office document.
 
Tim Moores
Bartender
Posts: 2842
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no principal difficulty walking through a document using the Apache POI library Riaan mentioned, and building a corresponding tree of Swing components. It's just a very involved process if you want to process all the options a typical word document can have. Maybe the documents you're working with do not use all those options, which would make the endeavour more feasible.
 
Scotty Steven
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the doc I has is some plain old text text with the following features: times new roman, size 11 and 18, bullets, some bold, some underline.

Several jpeg

a couple of tables.

That's it. Nothing that special.

I could turn it into a htlm in a couple of minutes, but I would then be asking the question, how do I display an html page inside a frame?


 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JEditorPane could be of some use, unless you really want separate components for everything.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that was the whole point of the suggestion for a move towards HTML: Swing offers out-of-the-box support for rendering HTML content in its components.
JEditorPane or its subclass JTextPane are good examples of this, and seem very usable in your case.
 
Scotty Steven
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's it! I'm looking for the example on the top right corner. OK. Time to go play. Thanks everyone.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic