/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. import javax.swing.*; 

2. import java.awt.*; 

3. import java.net.*; 

4. import java.awt.event.*; 

5.  

6. public class Toolb 

7.     extends JApplet implements ActionListener 

8.

9.   JToolBar tb ; 

10.   JButton bt1, bt2 ; 

11.  

12.   public void init() 

13.   { 

14.     tb = new JToolBar ( ); 

15.  

16.     URL url; 

17.     try

18.     url = new URL ( getCodeBase(), "pic.gif"); 

19.     bt1 = new JButton ( new ImageIcon( url ) ); 

20.     bt1.setToolTipText ( "Do this" ) ; 

21.     bt1.addActionListener(this); 

22.  

23.     tb.add ( bt1 ) ; 

24.  

25.     url = new URL ( getCodeBase( ), "tpic.gif"); 

26.     bt2 = new JButton ( new ImageIcon( url ) ); 

27.     bt2.setToolTipText ( "Can be done" ) ; 

28.     bt2.addActionListener(this); 

29.  

30.     tb.addSeparator( new Dimension(20,0) ); 

31.     tb.add ( bt2 ) ; 

32.  

33.     cp = getContentPane ( ) ; 

34.     cp.setLayout ( new BorderLayout ( )  ); 

35.     cp.add ( tb, BorderLayout.NORTH ); 

36.     cp.setBackground ( Color.yellow ); 

37.     } 

38.     catch ( MalformedURLException ex ) 

39.     {  System.err.println( ex );  } 

40.   } 

41.  

42.   public void actionPerformed ( ActionEvent ev ) 

43.   { 

44.     if ( ev.getSource()==bt1 ) 

45.       cp.setBackground( Color.cyan ); 

46.     else 

47.       cp.setBackground( Color.yellow ); 

48.   } 

49.   Container cp ; 

50.

51.  

52.