Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes swing basics.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "swing basics.." Watch "swing basics.." New topic

swing basics..

Huang Crystal

Joined: Jul 17, 2001
Posts: 20
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..

Rashid Ali
Ranch Hand

Joined: Jan 16, 2001
Posts: 349
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...
Rashid Ali
Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
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("")

- Vinod<br />-------<br />SCJP2
I agree. Here's the link:
subject: swing basics..
It's not a secret anymore!