Skip to content

Commit 191ab71

Browse files
Initial Commit
1 parent f908043 commit 191ab71

1 file changed

Lines changed: 121 additions & 0 deletions

File tree

FATANSWERKEY/src/TaxSystem.java

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import java.awt.EventQueue;
2+
import java.awt.event.*;
3+
import java.util.HashMap;
4+
5+
import javax.swing.JFrame;
6+
import javax.swing.JLabel;
7+
import javax.swing.JOptionPane;
8+
9+
import java.awt.Font;
10+
import javax.swing.JTextField;
11+
import javax.swing.JButton;
12+
import javax.swing.JPasswordField;
13+
14+
/**
15+
*
16+
*/
17+
18+
/**
19+
* @author M.NAVEEN
20+
* RANDOM CODER'S
21+
* Tech/Project Lead Android Club
22+
*/
23+
public class TaxSystem {
24+
25+
private JFrame frame;
26+
private JTextField userName;
27+
private JPasswordField passwordField;
28+
29+
public static void main(String[] args) {
30+
EventQueue.invokeLater(new Runnable() {
31+
public void run() {
32+
try {
33+
TaxSystem window = new TaxSystem();
34+
window.frame.setVisible(true);
35+
} catch (Exception e) {
36+
e.printStackTrace();
37+
}
38+
}
39+
});
40+
}
41+
42+
public TaxSystem() {
43+
initialize();
44+
}
45+
46+
private void initialize() {
47+
HashMap<String,String> map=new HashMap<String,String>();
48+
map.put("Naveen", "123456789");
49+
map.put("Praveen","963852741");
50+
map.put("Rhea", "789456123");
51+
map.put("Thilak","741852963");
52+
System.out.println(map);
53+
frame = new JFrame();
54+
frame.setTitle("Please Enter Name and Password");
55+
frame.setBounds(100, 100, 450, 300);
56+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
57+
frame.getContentPane().setLayout(null);
58+
59+
JLabel name = new JLabel("Name :");
60+
name.setFont(new Font("Tahoma", Font.BOLD, 16));
61+
name.setBounds(53, 65, 96, 29);
62+
frame.getContentPane().add(name);
63+
64+
JLabel password = new JLabel("Password :");
65+
password.setFont(new Font("Tahoma", Font.BOLD, 16));
66+
password.setBounds(53, 133, 96, 29);
67+
frame.getContentPane().add(password);
68+
69+
userName = new JTextField();
70+
userName.setBounds(188, 67, 184, 29);
71+
frame.getContentPane().add(userName);
72+
userName.setColumns(10);
73+
passwordField = new JPasswordField();
74+
passwordField.setBounds(188, 133, 184, 29);
75+
frame.getContentPane().add(passwordField);
76+
frame.setTitle("Please Enter Name and Password");
77+
JButton submit = new JButton("Ok\r\n");
78+
submit.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
79+
submit.setBounds(150, 194, 96, 36);
80+
81+
submit.addActionListener(new ActionListener () {
82+
83+
@Override
84+
public void actionPerformed(ActionEvent e) {
85+
try {
86+
if(map.get(userName.getText()).equals(passwordField.getText()))
87+
{
88+
JOptionPane.showMessageDialog(submit,"Login Successfull!!!");
89+
newFrame nf=new newFrame();
90+
nf.setVisible(true);
91+
92+
}
93+
else
94+
JOptionPane.showMessageDialog(submit,"Login Failed Invalid Username and Password!!");
95+
96+
}
97+
catch(NullPointerException f1) {JOptionPane.showMessageDialog(submit,"Login Failed Invalid Username and Password!!"); //usename is not in HashMap
98+
}
99+
}
100+
});
101+
frame.getContentPane().add(submit);
102+
103+
104+
JButton cancel = new JButton("Cancel\r\n");
105+
cancel.addActionListener(new ActionListener() {
106+
107+
@Override
108+
public void actionPerformed(ActionEvent arg0) {
109+
frame.dispose();
110+
111+
}
112+
113+
});
114+
cancel.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
115+
cancel.setBounds(260, 194, 96, 36);
116+
frame.getContentPane().add(cancel);
117+
118+
119+
}
120+
}
121+

0 commit comments

Comments
 (0)