> 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);
}
}