India Forums .Info

Discuss Cars, Bikes, Jobs, Romance, Marriage, Jobs, Real Estate, Programming and more..
It is currently Wed Dec 03, 2008 4:10 am

All times are UTC + 5:30 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Help!!!!
PostPosted: Thu Jun 08, 2006 1:01 pm 
Offline
Newbie

Joined: Thu Jun 08, 2006 12:51 pm
Posts: 2
Hey!there pro, I need ur kind help to solve my problem.Here is my coding.Now the problem is there no error when I compile the coding but I find some task does'nt work but I have implement it in my coding(Example connection to database and the user name and password validation).What the problem actually.
Code:
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import java.net.*;
public class MyLogin extends Frame implements ActionListener
{
//Boolean id=false;
JButton ok,can,next;
JFrame jf;
TextField username;
TextField password;
static ResultSet result;
static Connection con;
static Statement stat;

public  MyLogin()
{
  super("Welcome");
   jf=new JFrame("Welcome");
  setLayout(new FlowLayout());
MyWinListener mywindow=new MyWinListener();
addWindowListener(mywindow);
  username = new TextField(15);
  password = new TextField(15);
  password.setEchoChar('*');
  add(new JLabel("User :"));
  add(username);
  add(new JLabel("Password :"));
  add(password);
  addOKCancelNextPanel();
  createFrame();
  pack();
  setVisible(true);
  blist obj=new blist();
  }

void addOKCancelNextPanel()
  {
  JPanel p = new JPanel();
  p.setLayout(new FlowLayout());
  createButtons( p );
  add( p );
  }

void createButtons(JPanel p)
{
 
  p.add(ok = new JButton("OK"));
  ok.addActionListener(this);
  p.add(can = new JButton("Cancel"));
  can.addActionListener(this);
  p.add(next = new JButton("Next"));
  next.addActionListener(this);
  }

    void createFrame()
   {
   Dimension d = getToolkit().getScreenSize();
   setLocation(d.width/4,d.height/3);
   }
 
class blist implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==ok)
{
String uid=new String(username.getText());
String pwd=new String(password.getText());
if(uid.equals("Ram")&& pwd.equals("kumar"))
JOptionPane.showMessageDialog(jf,new String("Your password is correct"));
else
JOptionPane.showMessageDialog(jf,new String("Your password is not correct"));
username.setText("");
password.setText("");
}//end of the command
else if(ae.getSource()==can)
{
username.setText("");
password.setText("");
JOptionPane.showMessageDialog(jf,new String("Thank you"));
}
}
}



  class MyWinListener implements WindowListener
  {
  public void windowClosing(WindowEvent w)
  {
    System.exit(0);
  }
public void windowClosed(WindowEvent w)
{
}
public void windowOpened(WindowEvent w) 
{
}
public void windowIconified(WindowEvent w)
{

public void windowDeiconified(WindowEvent w)
{
}
public void windowActivated(WindowEvent w)
{
}
public void windowDeactivated(WindowEvent w)
{
}
}
 
   


public static void main(String args[])
{
MyLogin obj=new MyLogin();
try
{
Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
Connection con;
con=DriverManager.getConnection("jdbc:odbc:kumar","","");
stat=con.createStatement();
result=stat.executeQuery("Select * from Javadetail");
result.next();
}
catch(Exception e)
{
System.out.println("Error.."+e);
}
  obj.showRecord(result);
}

public void actionPerformed(ActionEvent evt)
{
if(evt.getSource()==can)
{
setVisible(false);
}

else if(evt.getSource()==next)
{
try
{
result.next();
}

catch(Exception e)
{}
showRecord(result);

}
}

public void showRecord(ResultSet result)
{
try
{
password.setText(result.getString(2));
username.setText(result.getString(2));
}
catch(Exception e)
{}
}
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 5:30 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO