• Post Reply Bookmark Topic Watch Topic
  • New Topic

insert document content into Text Area  RSS feed

 
ola farouk gharably
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
in my program i'm adding a text field and next to it a button called "browse" well, i want this button to let me chose the path of a document so that it'll appear in the text field, and under the text field and the button I want to browse the content of the file in a text Area..

So this is my problem. What should I write in the code ??

Gr8 Thx
Ola
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got several different aspects to tackle here. So let's list them.

  • JFileChooser - in your buttons action method you will need to create a new JFileChooser to allow you to pic the document you want to open. It will return a file. See this for a tutorial on JFileChooser
  • When you have the File object returned from JFileChooser, you can get the filename from the File object and use setText(String) on your JTextField.
  • Displaying the document in the text area is a bit more involved. It will depend on what type of documents you are trying to read. So if you could tell us a bit more about that we can point you in the right direction.

  •  
    ola farouk gharably
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you Gregg very much..

    According to the type of my document, I'm supposed to get html or xml files, well if that may make things easier I only need the text in such documents without images..

    Gr8 thx
    Ola
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!