Hi,

I have been trying to look for some code to add a comment box where people can add or delete comments in my program when viewing items any ideas pls?

you may want to be a bit more specific

I assume using a textArea to write one, a Button to add it to your savedComments, and a small 'X' button in a subpanel that contains a comment linked to a deleteThisComment function would do the trick.

that is, if you are working in a Swing application, if you are in a webapp, it's another story

yes i am using a swing application. i am require to store comments with the ability to add / delete comments with a timestamp on each comment which are stored on a text file. Please check your pm with further information regarding the matter.

thanks in advance

yes i am using a swing application. i am require to store comments with the ability to add / delete comments with a timestamp on each comment which are stored on a text file. Please check your pm with further information regarding the matter.

thanks in advance

post your code that you have and what you are having problems doing and we can help.

i havent began the coding yet. i am new at this so i am seeking for good reference sites where i can get a good idea what to do

adding to what stultuske said, assuming you have a text area added to your gui, and its name is jTextArea1, and a button to add the comment say jButton1. you would add an ActionPreformed event to the button and in this method the button will use:

String comment=jTextArea1.getText();

That will now save what the user typed in the textarea, now you would save it to a file:http://www.daniweb.com/software-development/java/threads/94567 that may help you accomplish that. as for viewing the comment next time, your textfile should contain some structure to allow you to see if it has a comment and then print it to the textarea using:

String comment="";//this will be the comment found in the text file
jTextArea1.setText(comment);

To find the comments you'll have to read in the text file with the saved comments...take a look at:http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml

hope that helps to get you going, oh and if you dont know how to write action listeners for jbuttons here:http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html

wow thank you :))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.