NEP -JAVA

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6

PART B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

t

 
  
 /*
 
 4. Program which creates a frame with two buttons father and mother. When we click the
father button the name of the father, his age and designation must appear. When we click
mother similar details of mother also appear.
 */
 
 import java.awt.event.*;  
import javax.swing.*;   
 
public class programB4 {  
public static void main(String[] args) { 
 
    JFrame f=new JFrame("PROGRAM B4"); 
  
    final JTextArea  tf=new JTextArea ();  
    tf.setBounds(50,50, 250,150);  

    JButton b=new JButton("FATHER");  
    b.setBounds(50,250,95,30);  


    b.addActionListener(new ActionListener(){  
    public void actionPerformed(ActionEvent e){  
            tf.setText(" FATHER AGE= 40 \n designation = Manager.");  
        }  
    });  


      JButton b2=new JButton("Mother");  
      b2.setBounds(150,250,95,30);  


    b2.addActionListener(new ActionListener(){  
    public void actionPerformed(ActionEvent e){  
            tf.setText(" Mother AGE= 35 \n designation = teacher.");  
        }  
    }); 

 
   
    f.add(tf); 
    f.add(b);
    f.add(b2); 
    f.setSize(500,500);  
    f.setLayout(null);  
    f.setVisible(true);   
}  
}