-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_form
More file actions
82 lines (82 loc) · 2.56 KB
/
basic_form
File metadata and controls
82 lines (82 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
class SwingProject implements ActionListener
{
JLabel jlabTitle,jlabName,jlabPassword,jlabDesig,jlabRemark;
JButton jbtnSubmit;
JTextField jtfName,jtfPassword,jtfDesig;
SwingProject()
{
JFrame jfrm1= new JFrame("This is Home");
jfrm1.setLayout(new FlowLayout());
jfrm1.setSize(250,230);
jfrm1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jfrm1.setBackground(Color.red);
jlabTitle= new JLabel("Register");
jlabName= new JLabel("Enter name");
jlabPassword= new JLabel("Enter password");
jlabDesig= new JLabel("Enter Designation");
jlabRemark= new JLabel(" ");
jbtnSubmit= new JButton("Submit");
jtfName=new JTextField(15);
jtfPassword= new JTextField(15);
jtfDesig= new JTextField(15);
jtfName.setActionCommand("Name");
jtfPassword.setActionCommand("Password");
jtfDesig.setActionCommand("Time");
jbtnSubmit.addActionListener(this);
jfrm1.add(jlabName);
jfrm1.add(jtfName);
jfrm1.add(jlabPassword);
jfrm1.add(jtfPassword);
jfrm1.add(jlabDesig);
jfrm1.add(jtfDesig);
jfrm1.add(jlabRemark);
jfrm1.add(jbtnSubmit);
jfrm1.setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
int i=0,j=0;
if(ae.getActionCommand().equals("Submit"))
{
String strName=jtfName.getText();
String strPassword=jtfPassword.getText();
String strDesig=jtfDesig.getText();
if(strPassword.equals("employee"))
{
try(FileInputStream f1= new FileInputStream(strName);
FileInputStream f2= new FileInputStream(strDesig))
{
do
{
i=f1.read();
}while(i!=-1);
do
{
j=f2.read();
}while(j!=-1);
}catch(IOException exc)
{
jlabRemark.setText("Welcome "+strName+" as "+strDesig);
}
}
else
{
jlabRemark.setText("Sorry wrong password");
}
}
}
public static void main(String args[])
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new SwingProject();
}
});
}
}