/* 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);
}
}