File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How do i go about displaying text and graphic files in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do i go about displaying text and graphic files in java?" Watch "How do i go about displaying text and graphic files in java?" New topic
Author

How do i go about displaying text and graphic files in java?

m brown
Ranch Hand

Joined: Mar 01, 2005
Posts: 57
i want to be able to open a text file or a image file(gif, jpeg, etc) in a window. how would i go about doing that?
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Use a GUI API such as Swing, and use certain components to parse text or render images.

For images, see this.

For text, you could use the same component as in the above example (JEditorPane) and learn to read text from a file using BufferedReader. Something like this would be useful - you could append each line of text to a GUI component (in this case, JEditorPane).
m brown
Ranch Hand

Joined: Mar 01, 2005
Posts: 57
thanks for the help. JavaWorld seems pretty cool....the stupid examples in my book dont even compile correctly...i was becoming very frustrated!
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Which book are you using? The "head first" books are very popular.
m brown
Ranch Hand

Joined: Mar 01, 2005
Posts: 57
i am using the deitel and deitel "how to program" java book...the context is decent, but the examples presented in the text do not work! i always get errors when i try to run the examples.how can i learn from examples that dont work!

are these "head first" books something you reccomend? who makes them?
[ March 20, 2005: Message edited by: m brown ]
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Ah, I've also got a copy of that Deitel book (albeit an old 3rd edition), its got too much tedious content and I hate the way almost every example uses a GUI to explain something (it may have changed in the later editions).

Head First - I've heard lots of good things about them, read more about them here.
[ March 20, 2005: Message edited by: Kashif Riaz ]
m brown
Ranch Hand

Joined: Mar 01, 2005
Posts: 57
i read a sample chapter from the head first book and i actually went and bought a used one for $25..it looks like a pretty fun book
M Beck
Ranch Hand

Joined: Jan 14, 2005
Posts: 323
with no lack of respect for Kathy and Bert, i actually don't like Head First Java. that might be because i need a very structured text for my personal learning style, and HFJ is nothing if not chaotic. even its graphics-heavy presentation rubs me the wrong way. i have trouble focusing on its pages, because they're so burdened by glitzy pictures and a hyperactive, short-attention-span format of jumping from one topic to the next that keep distracting my attention from the task of learning Java.

HFJ is the textbook used in the 300-level Java programming class that brought me to the Java Ranch website, and i'm actually learning Java far more through this bulletin board and Sun's API documentation website than i am through the book. my copy will be in mint condition when i resell it to my academic bookstore.

that said, it might be a good choice for self-study learners with less need for structure and focus than my own brain demands. personally, i prefer a more stodgy approach to learning; perhaps i'm just growing old.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do i go about displaying text and graphic files in java?