just want to know how to create a vector to store more then one username and
password, which i can call up each time when my program is executed.
username1:admin
password: 111
username2: user
password: 222
Thanks
This is my code:
-------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class login extends JFrame
{public static void main(String[] args)
{login login=new login();
login.show();
}
TextField text1,text2,text3,text4;
JButton b1,b2;
boolean confirm=false;
public login()
{setSize(300,100);
Container windowPane=getContentPane();
windowPane.setLayout(new GridLayout(3,2));
text1=new TextField("username:");
text1.setEditable(false);
text2=new TextField(6);
text3=new TextField("password:");
text3.setEditable(false);
text4=new TextField(6);
text4.setEchoChar('*');
b1=new JButton("OK");
b2=new JButton("Quit");
windowPane.add(text1);
windowPane.add(text2);
windowPane.add(text3);
windowPane.add(text4);
windowPane.add(b1);
windowPane.add(b2);
b1.addActionListener(new ConfirmListener());
b2.addActionListener(new QuitListener());
}
private class ConfirmListener implements ActionListener
{public void actionPerformed(ActionEvent e)
{confirm=true;
}
}
private class QuitListener implements ActionListener
{public void actionPerformed(ActionEvent e)
{System.exit(0);
}
}
}
password, which i can call up each time when my program is executed.
username1:admin
password: 111
username2: user
password: 222
Thanks
This is my code:
-------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class login extends JFrame
{public static void main(String[] args)
{login login=new login();
login.show();
}
TextField text1,text2,text3,text4;
JButton b1,b2;
boolean confirm=false;
public login()
{setSize(300,100);
Container windowPane=getContentPane();
windowPane.setLayout(new GridLayout(3,2));
text1=new TextField("username:");
text1.setEditable(false);
text2=new TextField(6);
text3=new TextField("password:");
text3.setEditable(false);
text4=new TextField(6);
text4.setEchoChar('*');
b1=new JButton("OK");
b2=new JButton("Quit");
windowPane.add(text1);
windowPane.add(text2);
windowPane.add(text3);
windowPane.add(text4);
windowPane.add(b1);
windowPane.add(b2);
b1.addActionListener(new ConfirmListener());
b2.addActionListener(new QuitListener());
}
private class ConfirmListener implements ActionListener
{public void actionPerformed(ActionEvent e)
{confirm=true;
}
}
private class QuitListener implements ActionListener
{public void actionPerformed(ActionEvent e)
{System.exit(0);
}
}
}