create a login frame

login page in java

Page 1 of 1

4 Replies - 27799 Views - Last Post: 07 December 2006 - 11:27 PM Rate Topic: -----

#1 janakiraman  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 3
  • Joined: 05-December 06

create a login frame

Posted 05 December 2006 - 03:17 AM

Dear Friends,

Any body can help me how to create a login frame in java.Afer loged in that page has got to another frame.

Regards[/b]
Janakiraman
Is This A Good Question/Topic? 1
  • +

Replies To: create a login frame

#2 ReggaetonKing  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 73
  • Joined: 16-November 06

Re: create a login frame

Posted 05 December 2006 - 08:47 PM

You want us to actually make the login frame for you? If you can't make a login frame, which only concise of a couple of text fields, labels, and two buttons, how are you going to implement that into your existing code?
Was This Post Helpful? 0
  • +
  • -

#3 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1255
  • View blog
  • Posts: 4,618
  • Joined: 02-May 04

Re: create a login frame

Posted 05 December 2006 - 10:52 PM

Quote

If you can't make a login frame, which only concise of a couple of text fields, labels, and two buttons, how are you going to implement that into your existing code?


that's why he's asking on a programming help site.
Was This Post Helpful? 0
  • +
  • -

#4 ReggaetonKing  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 73
  • Joined: 16-November 06

Re: create a login frame

Posted 06 December 2006 - 12:54 PM

Well maybe the user should try it himself first, show us the code, and then we can help the user based on what they already have. Users that just ask "help me make a bank system!!!!" don't even attempt to try the problem out themselves. They are just taking advantages of other programmer who already know this.

You can't learn to cook if you have a your own chef to do it for you all the time. They had to learn about Java somewhere and there are unlimited number of tutorials and free stuff out there where one can get started and become more advanced.
Was This Post Helpful? 0
  • +
  • -

#5 janakiraman  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 3
  • Joined: 05-December 06

Re: create a login frame

Posted 07 December 2006 - 11:27 PM

View PostReggaetonKing, on 5 Dec, 2006 - 08:47 PM, said:

You want us to actually make the login frame for you? If you can't make a login frame, which only concise of a couple of text fields, labels, and two buttons, how are you going to implement that into your existing code?



I don't want you to make the login page for me.I have the code attached below please go through this and reply,whether the code is correct.What i want is once i login to login frame it should go to the examOP Frame.examOp is new Frame.
Regards
Janakiraman



package Test;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.sql.*;
import java.io.*;
public class login extends JFrame implements ActionListener
{
JLabel lbl[]=new JLabel[3];
JLabel head;
String name[]={"User Name","Password","Domain"};
String btnCap[]={" ok","exit"};
TextField tf[]=new TextField[3];
JButton btn[]=new JButton[2];
Container con;
JPanel p1,p2,p3,p4;
Font f;
JComboBox cmb;
JApplet Test;




int OK=0,exp=0;

public login()
{
con=getContentPane();
con.setLayout(null);
con.addKeyListener(new key());
con.setBackground(Color.black);

p1=new JPanel();
TitledBorder br=new TitledBorder(new LineBorder(Color.black),"");
p1.setBorder(br);
p1.setBackground(new Color(102,153,102));
p1.addKeyListener(new key());
p1.setBounds(5,5,300,160);
p1.setLayout(null);
con.add(p1);

f=new Font("Monotype Corsiva",1,30);

p3=new JPanel();
p3.setBorder(br);
p3.setBackground(new Color(204,255,204));
p3.addKeyListener(new key());
p3.setBounds(5,5,289,105);
p3.setLayout(null);
p1.add(p3);

int x=5,y=10;
for(int i=0;i<3;i++)
{
lbl[i]=new JLabel(name[i]);
lbl[i].setBounds(20,y,115,25);
p3.add(lbl[i]);

if(i<2){
tf[i]=new TextField();
if(i==1)
{tf[i].setEchoChar('*');}
tf[i].setBounds(140,y,135,25);
tf[i].addKeyListener(new key());
p3.add(tf[i]);
}
if(i==2)
{
cmb=new JComboBox();
cmb.setBackground(Color.white);
cmb.addItem("Administrator");
cmb.addKeyListener(new key());
cmb.addItem("Local User");
cmb.setBounds(140,y,135,25);
p3.add(cmb);
}



y+=30;
}



p4=new JPanel();
p4.setBorder(br);
p4.setBackground(new Color(102,153,102));
p4.setLayout(null);
p4.addKeyListener(new key());
p4.setBounds(5,115,289,40);
p1.add(p4);

x=18;
for(int i=0;i<2;i++)
{
btn[i]=new JButton();
btn[i].addActionListener(this);
btn[i].addKeyListener(new key());
btn[i].setBorder(null);
btn[i].setBounds(x,5,100,30);
x+=150;
if(i==1)
x=170;


btn[i].setBackground(new Color(153,204,255));
p4.add(btn[i]);
}
ImageIcon i1=new ImageIcon("ok.jpg");
ImageIcon i2=new ImageIcon("exit.jpg");

btn[0].setIcon(i1);
btn[1].setIcon(i2);


}

class key extends KeyAdapter
{
public void keyReleased(KeyEvent ke)
{
if(ke.getKeyCode()==10)
{
if(tf[1].getText().equals(" "))
{}
else
{
check();
}
}
}
}


public void actionPerformed(ActionEvent ae)

{
if(ae.getSource()==btn[1])
{

dispose();
}

if(ae.getSource()==btn[0])
{
check();
}
}


public void check()
{
try{
String uname=tf[0].getText();
String pwd=tf[1].getText();
String domain=String.valueOf(cmb.getSelectedItem());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:MyData");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from login");
int find=0;

while(rs.next())
{
if(uname.equals(rs.getString(1)) && pwd.equals(rs.getString(2)) && domain.equals(rs.getString(3)))




find=1;
}
if(find==1)


{

examOP o=new examOP(uname,domain);


dispose();
}
else
{
JOptionPane.showMessageDialog(this,"Invalid UserName or Password","Netizen-Alert",0);
tf[1].setText(" ");
}


}
catch(Exception aes)
{
System.out.println(aes);}
}

public static void main(String s[])
{
login usr=new login();
usr.setSize(315,198);
usr.setTitle("Login");
usr.setLocation(240,140);
usr.setResizable(false);
usr.setVisible(true);
}
}
Was This Post Helpful? 1

Page 1 of 1