B Mail: Project Synopsis File On
B Mail: Project Synopsis File On
B MAIL
//initializing textfields
tf1 = new JTextField(12);
tf2 = new JTextField(12);
//initializing labels
//initializing panels
p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
psouth = new JPanel();
p2.setBorder(BorderFactory.createTitledBorder("
Enter Your
Details"));
p2.add(lblname);
p2.add(tf1);
p2.add(lbladd);
p2.add(tf2);
this.setSize(300,300);
this.setLocation(100,200);
this.show();
}
public static void main(String args[])
{
AddNewStudent ad = new AddNewStudent();
}
//event handling
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btnok)
{
PreparedStatement pstm;
ResultSet rs;
String sql;
//if no entries has been made and hit ok
button throw an error
//you can do this step using try clause as well
if((tf1.getText().equals("")&&(tf2.getText().equals(
""))))
{
lblmsg.setText("Enter your details ");
lblmsg.setForeground(Color.magenta);
}
else
{
try
{
//loading the driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
if(e.getSource()==btnexit)
{
System.exit(1);
}
}
}