import java.awt.*;
import java.awt.event.*;
import javax.swing.*; 

/**
 * Create a window with a toolbar that has icons
 *
 */

public class ToolBar extends JFrame {

    public static void main(String[] arguments) {
        ToolBar frame = new ToolBar();          //instantiate a pgm object
    }

    public ToolBar() {
        super("A Toolbar with Icons");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel   window = new JPanel();         //create a window
        JToolBar menu   = new JToolBar();       //create a menu toolbar

        ImageIcon image1 = new ImageIcon("button1.gif");    //get image URL
        JButton button1  = new JButton(image1);             //create button from image
        ImageIcon image2 = new ImageIcon("button2.gif");
        JButton button2  = new JButton(image2);
        ImageIcon image3 = new ImageIcon("button3.gif");
        JButton button3  = new JButton(image3);

        menu.add(button1);              //add buttons to toolbar
        menu.add(button2);
        menu.add(button3);

        JTextArea   edit  = new JTextArea(8,40);    //create a text area
        JScrollPane edit2 = new JScrollPane(edit);  //make it scrollable

        BorderLayout lay = new BorderLayout();      //create a border layout 
        window.setLayout(lay);                      //use the layout on the window

        window.add("North" , menu);                 //add the toolbar to the top
        window.add("Center", edit2);                //add the field to the center

        setContentPane(window);                     //set all the components down   
        pack();                                     //shrink them to proper size
        setVisible(true);                           //make window visible
    }

}