Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with actionEvent command

 
Arun kumar Maalik
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Respected sir in following code what is the problem with code it is compiling fine but when i m pressing on submit button it is throwing lot of exception although i think that exception is throwing at the time when i m creating file with command RandomAccessFile. pls solve the problem




import javax.swing.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import java.util.*;

/*<applet code="first1.class" height=400 width=400> </applet> */

public class first1 extends JApplet implements ActionListener{
Container con;

JLabel lbl1=new JLabel("Student name");
JLabel lbl2=new JLabel("Password");
JLabel lbl3=new JLabel("Course");
JLabel lbl4=new JLabel("Subject");

JTextField txt1=new JTextField();
JTextField txt2=new JTextField();
JTextField txt3=new JTextField();
JTextField txt4=new JTextField();

JButton btn=new JButton("Submit");

public void init(){
con=getContentPane();
con.setLayout(null);

lbl1.setBounds(30,30,90,40);
txt1.setBounds(120,40,90,20);
lbl2.setBounds(230,30,90,40);
txt2.setBounds(320,40,90,20);
lbl3.setBounds(30,60,90,40);
txt3.setBounds(120,70,90,20);
lbl4.setBounds(230,60,90,40);
txt4.setBounds(320,70,90,20);
btn.setBounds(200,100,90,30);

con.add(txt1);
con.add(txt2);
con.add(txt3);
con.add(txt4);

con.add(lbl1);
con.add(lbl2);
con.add(lbl3);
con.add(lbl4);

con.add(btn);

btn.addActionListener(this);


}

public void actionPerformed(ActionEvent ae){
String st1=txt1.getText();
String st2=txt2.getText();
String st3=txt3.getText();
String st4=txt4.getText();
String st=ae.getActionCommand();

try{



if("Submit".equals(st))
{
RandomAccessFile raf1=new RandomAccessFile("work.txt","rw");

}
}
catch(IOException ie){}
}


}
 
Sunil Kumar Gupta
Ranch Hand
Posts: 824
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you put here the list of exceptions you are getting when run this applet.

So that we can give a better answer to your question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic