Rafael D.
Catain
Final Exam
BSIT III
04/02/16
Application Class
public class library {
public static void main(String[] args) {
log_Instance login = new log_Instance();
[Link](true);
}
}
INSTANCE CLASS
/**
* @(#)log_Instance.java
*
*
* @author
* @version 1.00 2016/3/31
*/
import
import
import
import
import
import
import
import
[Link];
[Link];
[Link].*;
[Link].*;
[Link].*;
[Link];
[Link];
[Link];
public class log_Instance extends JFrame implements ActionListener {
private JFrame frame;
private JLabel lblUsername, lblPassword, lblImage;
private JTextField txtUsername;
private JPasswordField txtPassword;
private JButton btnLogin, btnCancel;
private static JComboBox comboBox;
final int WIDTH = 450;
final int LENGHT = 100;
int ctr= 1;
Color blue = new Color(0x4a, 0x5d, 0x4a);
String uName = "juan";
String pWord = "tamad";
String msg = "";
Font myFont = new Font("Arial", [Link], 14);
public log_Instance() {
//Set frame layout manager
super("System's Security");
setSize(WIDTH, LENGHT);
setLocation(250,250);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel bg = new JPanel(new FlowLayout());
[Link](blue);
JPanel gui = new JPanel(new BorderLayout());
[Link](blue);
JPanel dummyPanel = new JPanel(new GridLayout(0,1,1,1));
[Link](blue);
JPanel dummyPanel2 = new JPanel(new GridLayout(0,1,1,1));
[Link](blue);
JPanel labelFields = new JPanel(new BorderLayout(3,2));
[Link](blue);
JPanel labelFieldImage = new JPanel(new BorderLayout(2,2));
[Link](blue);
JPanel labels=new JPanel(new GridLayout(0,1,1,1));
[Link](blue);
JPanel fields=new JPanel(new GridLayout(0,1,1,1));
[Link](blue);
JPanel button=new JPanel(new GridLayout(0,1,1,1));
[Link](blue);
lblUsername=new JLabel("Username:");
[Link]([Link]);
[Link](myFont);
[Link]([Link]);
lblPassword=new JLabel("Password:");
[Link]([Link]);
[Link](myFont);
[Link]([Link]);
txtUsername=new JTextField(20);
txtPassword=new JPasswordField(20);
String[] options = { "Admin", "Librarian", "Student Assistant"};
comboBox = new JComboBox(options);
[Link](new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Do something when you select a value
}
});
btnLogin=new JButton("login");
[Link](this);
btnCancel=new JButton("Cancel");
[Link](this);
[Link](lblUsername);
[Link](lblPassword);
[Link](txtUsername);
[Link](txtPassword);
//[Link](comboBox);
[Link](btnCancel);
[Link](btnLogin);
[Link](labels, [Link]);
[Link](fields, [Link]);
[Link](comboBox, [Link]);
[Link](button, [Link]);
[Link](labelFields, [Link]);
[Link](gui);
add(bg);
}
public void actionPerformed(ActionEvent event){
if([Link]()==btnLogin){
if([Link]([Link]())&&[Link]([Link]())){
[Link](null,"Access Granted");
Librarysystem main = new Librarysystem();
[Link](true);
dispose();
}
else{
if(ctr!=3){
[Link](null,"Access Denied");
[Link]("");
[Link]("");
[Link]();
ctr+=1;
}
else{
[Link](null,"You've reached the
maximum login tries. Goodbye!");
dispose();
}
}
}
if([Link]()==btnCancel){
}
}
}