-
Notifications
You must be signed in to change notification settings - Fork 0
/
VoteGUI.java
30 lines (30 loc) · 1 KB
/
VoteGUI.java
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
import javax.swing.*;
import java.awt.event.*;
public class VoteGUI{
public static void main(String[] args) {
JFrame f=new JFrame("Vote Eligibility");
JLabel l=new JLabel("Enter Age: ");
JTextField tf=new JTextField();
JButton b=new JButton("CHECK");
JLabel ans=new JLabel();
f.add(l);f.add(tf);f.add(b);f.add(ans);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
l.setBounds(50,70,100,20);
tf.setBounds(150,70,100,20);
b.setBounds(100,140,100,30);
ans.setBounds(100,200,200,20);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
int a=Integer.parseInt(tf.getText());
if(a>=18)
ans.setText("ELIGIBLE");
else
ans.setText("NOT ELIGIBLE");
}
});
}
}