Hi all, I'm a greenhorn in Java so I need your advices on quite alot of swing basics. Firstly, I areadly have 3 JButtons onto the JFrame. The first button is "Add", it should have the functions of able to get the data from the JTextFields and save them to a file. The file will contain 1 line per product. Secondly, a "Clear" button to clear the text fields. Thirdly, a "Print" button to read all the data in the file and print to a standard output. Pls advise and if poss. , wif some egs too... thanx in advance..
It's not just a swing basics but like a small project involve in it Your code requires to know how of Input/Out as well and when the swing classes and the stream classes will combine to work it would be many lines of code to work with... Do you need this program completed by us or just wanna hint of the code... Would be better if you do it yourself so that you can dig into the i/o and swing operations. What would you like... Regards Rashid Ali
You can refer to Sun's Java tutorial for all your problems. 1) For Add: First do textfield.getText()& assign to some variable. Then create FileOutputStream & ObjectOutputStream objects & write the contents to the file. 2) Clear: do textfield.setText("")