button event

A textbox with a button, if i execute button to start the backend program and anything submitted from the textbox should be saved to a file by the console program. how can i do this..help me..thx..
[211 byte] By [potla123a] at [2007-11-26 20:13:14]
# 1

> A textbox with a button, if i execute button to

> start the backend program and anything submitted from

> the textbox should be saved to a file by the console

> program. how can i do this..help me..

>

> thx..

may be this code will help you. It is not a perfect code. You have to change some to make it more perfect. But it works and shows the basics.

mport java.awt.*;

import java.awt.event.*;

import java.io.*;

class Test extends Frame implements ActionListener{

Button b;

TextArea ta;

public Test() {

b=new Button("submit");

ta=new TextArea(200,50);

b.addActionListener(this);

this.add(b,BorderLayout.NORTH);

this.add(ta,BorderLayout.SOUTH);

this.pack();

}

public void actionPerformed(ActionEvent ae) {

String s=ta.getText();

save(s);

ta.setText("");

}

public void save(String s) {

try {

File file=new File("your file name");

FileWriter f=new FileWriter(file);

BufferedWriter bw=new BufferedWriter(f);

bw.write(s);

bw.flush();

}catch(IOException e) {/*IOException handeler*/}

}

public static void main(String [] args) {

new Test().setVisible(true);

}

}

tanmoy_rajgurua at 2007-7-9 23:19:14 > top of Java-index,Security,Event Handling...
# 2
thx for the reply..its good. but i want to do using sockets.i want send the signal to backend program to read the input..
jaggu321a at 2007-7-9 23:19:14 > top of Java-index,Security,Event Handling...