i hava a code called home.java
import javax.swing.*;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Random;
import java.util.*;
import java.text.*;
class home extends JFrame implements ActionListener, Runnable
{
JButton btndetect,btntest,btnstart,btnexit,btntransfer;
ImageIcon ic,ic1,bc;
JLabel lbltitle;
JTextArea textArea ;
JScrollPane scrollPane;
JPanel panel;
Thread t;
public home()
{
setSize(800,570);
setTitle(" CAMERA SETUP ");
/*ic1=new ImageIcon("ready3.jpg");*/
JTextArea textArea = new JTextArea( 5, 10);
textArea.setPreferredSize(new Dimension(100, 100));
JScrollPane scrollPane = new JScrollPane(textArea);
textArea.setEditable(false);
JPanel panel = new JPanel();
lbltitle= new JLabel(ic1);
btndetect=new JButton(" Detect web cam ",ic);
btntest=new JButton(" Test cam ");
btnstart=new JButton("Start Survellance");
btntransfer=new JButton("File Transfer");
btnexit=new JButton("Exit");
Container cp=getContentPane();
cp.setLayout(null);
//cp.setBackground(Color.white);
Insets ins=getInsets();
textArea.setBounds(400,100,200,400);
btntest.setBounds(40,200,150,50);
btntransfer.setBounds(230,200,150,50);
btnstart.setBounds(40,300,150,50);
btndetect.setBounds(230,300,150,50);
btnexit.setBounds(120,400,170,50);
lbltitle.setBounds(0,0,850,570);
//lbltitle.setBounds(220,20,130,104);
btndetect.addActionListener(this);
btntest.addActionListener(this);
btntransfer.addActionListener(this);
btnstart.addActionListener(this);
btnexit.addActionListener(this);
cp.add(panel, "north");
cp.add(scrollPane);
cp.add(textArea);
cp.add(btndetect);
cp.add(btntest);
cp.add(btntransfer);
cp.add(btnstart);
cp.add(btnexit);
cp.add(lbltitle);
cp.setBackground(Color.black);
}
public void run()
{
try
{
while(t.isAlive())
{
Thread.sleep(1000);
File f = new File("check/test.jpg");
if(f.exists())
{
String fname = f.getAbsolutePath();
FileInputStream instream = new FileInputStream(fname);
int insize = instream.available();
byte inBuf[] = new byte[insize];
int bytesread = instream.read(inBuf,0,insize);
instream.close();
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource() == btndetect)
{
textArea.setText("initialized");
detect sc=new detect();
sc.show();
setVisible(false);
}
else
if(ae.getSource() == btntest)
{
try
{
JWebCam myWebCam = new JWebCam ( "Web Cam Capture" );
myWebCam.setVisible ( true );
if ( !myWebCam.initialise() )
{
System.out.println ("Web Cam not detected / initialised");
}
}
catch ( Exception ex )
{
ex.printStackTrace();
}
}
else if(ae.getSource() == btnstart)
{
WebCam sc=new WebCam("vfw:Microsoft WDM Image Capture (Win32)");
sc.show();
setVisible(false);
}
else
if (ae.getSource() == btntransfer)
{
transfer t=new transfer();
t.show();
}
else
{
System.exit(0);
}
}
public static void main(String args[])
{
home h=new home();
h.show();
}
}
now i need to add text in textArea whenver a button is clicked..
i.e sppose i click button "start surveillance" ..i want "surveillance started" to appear in JtextArea of the same Jframe...
czm sm1 peez assist me..
any kind of help wil b appreciated..thnx