Skip to content

Commit d50e3a8

Browse files
Add files via upload
1 parent e863f14 commit d50e3a8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Practicals/VoteGUI.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import javax.swing.*;
2+
import java.awt.event.*;
3+
public class VoteGUI{
4+
public static void main(String[] args) {
5+
JFrame f=new JFrame("Vote Eligibility");
6+
JLabel l=new JLabel("Enter Age: ");
7+
JTextField tf=new JTextField();
8+
JButton b=new JButton("CHECK");
9+
JLabel ans=new JLabel();
10+
f.add(l);f.add(tf);f.add(b);f.add(ans);
11+
f.setSize(300,300);
12+
f.setLayout(null);
13+
f.setVisible(true);
14+
l.setBounds(50,70,100,20);
15+
tf.setBounds(150,70,100,20);
16+
b.setBounds(100,140,100,30);
17+
ans.setBounds(100,200,200,20);
18+
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
19+
b.addActionListener(new ActionListener(){
20+
public void actionPerformed(ActionEvent e)
21+
{
22+
int a=Integer.parseInt(tf.getText());
23+
if(a>=18)
24+
ans.setText("ELIGIBLE");
25+
else
26+
ans.setText("NOT ELIGIBLE");
27+
}
28+
});
29+
}
30+
}

0 commit comments

Comments
 (0)