SEP -JAVA

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

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
    {

        public static void main(String args[])
        {

    
        	JFrame frame = new JFrame("Original Frame");
            frame.setSize(300,300);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            
        	programb2 obj = new programb2();
         	JButton button = new JButton("View Message");

        	frame.add(button);
        	button.addActionListener(obj);

         	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);
           
    	    JLabel label = new JLabel("!!! Hello !!!");
            sub_frame.add(label);
         	sub_frame.setVisible(true);

        }

    }