NEP -R PROGRAMMING

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

PART B

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

 
 
     
     
     
         /* B2: Program which create and displays a message on the window */

    import javax.swing.*;

    import java.awt.event.*;

    import java.awt.*;

    class programb2 implements ActionListener

    {

        //Function to create the original frame

        public static void main(String args[])

        {

    	//Create a frame

    	JFrame frame = new JFrame("Original Frame");

    	frame.setSize(300,300);

    	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

     

    	//Create an object

    	programb2 obj = new programb2();

     

    	//Create a button to view message

    	JButton button = new JButton("View Message");

    	frame.add(button);

    	button.addActionListener(obj);

     

    	//View the frame

    	frame.setVisible(true);

        }

          

        public void actionPerformed(ActionEvent e)

        {
 

    	JFrame sub_frame = new JFrame("Sub Frame");

    	sub_frame.setSize(200,200);

        Window win = new Window(sub_frame);
        Canvas c = new Canvas();


        c.setBackground(Color.RED);

            c.fillCircle(100, 200, 20);

	        JLabel label = new JLabel("!!! Hello !!!");

	         win.add(label);
             win.add(c);
             win.show();
  
           sub_frame.add(c);
      

     	sub_frame.setVisible(true);

        }

    }