File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments