Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in writing to file. Contents not refreshed automatically  RSS feed

 
kavya bharadwaj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I am using the following code to write into a java properties file through the swings UI.
I am trying to re open the UI after making write changes, and the contents written are not to be seen on the UI. I am using eclipse IDE and i need to manually open the file on which is asks me save changes. If i run the UI again, I m able to see the changes. What should i do to refresh the file contents and not save changes manually.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In future, while posting code please use code tags.
You can add code tags to your existing post by clicking on the button.

The code you have shown is for writing to the file.
Where is the code for swing? By the way it is Swing and not swings
Usually you will have a text area, open a stream to the file, read the contents and then display them in the text area.
Once you have displayed the contents, it does not automatically refresh if the underlying file is changed. You will have to code it explicitly.

You mention that you reopen the UI after you write to a file. Can you show us the relevant code?

We have a forum dedicated to Swing and other UI stuff.
I will move this thread there for you.
 
kavya bharadwaj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for the trouble.
I am reading file contents and displaying in a JTable. This is what i am using using to raed the properties file.

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how do you set the map in the table?
Also are you reloading the table model after the file has been changed?
 
kavya bharadwaj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using the data from hash map and updating the row data for the JTable.
Everytime i add or delete the rows from the JTable, i use the current table model and update the contents of the table by setting the new default table model.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You suppose we can figure out the error without seeing the relevant code?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!