/* 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. public class ColxBulk 

2.   extends JFrame 

3.   implements ActionListener 

4.

5.   Set sunset = new TreeSet() ; 

6.   Set teaset = new HashSet(4) ; 

7.  

8.  public void actionPerformed ( ActionEvent ev ) 

9.  { 

10.     bt.setEnabled(false); 

11.  

12.     sunset.add ( "aces" ); 

13.     sunset.add ( "bees" ); 

14.     sunset.add ( "seas" ); 

15.  

16.     teaset.add ( "jeans" ); 

17.     teaset.add ( "seas" ); 

18.  

19.     if ( sunset.addAll( teaset ) ) 

20.     { 

21.       ta.append ( "1. sunset changed by Union : " + sunset + "\n\n" ) ; 

22.     } 

23.  

24.     ta.append ( "2. "+ sunset.containsAll(teaset) + "\n\n" ) ; 

25.  

26.     Set tempset = new HashSet(sunset); 

27.  

28.     tempset.retainAll( teaset ) ; 

29.     ta.append ( "3. Intersection : " + tempset + "\n\n" ) ; 

30.  

31.     sunset.removeAll( teaset ) ; 

32.     ta.append ( "4. sunset - teaset : " + sunset + "\n\n" ) ; 

33.  

34.     Map mp = new HashMap(); 

35.     mp.put ( "LA", new Integer(535) ); 

36.     mp.put ( "Amsterdam", new Integer(72) ); 

37.     mp.put ( "Caracas", new Integer(72) ); 

38.     Map mpother = new HashMap(); 

39.     mpother.put ( "Caracas", new Integer(72) ); 

40.     mp.keySet().removeAll( mpother.keySet() ); 

41.     ta.append ( "5. map - othermap : " + mp + "\n\n" ) ; 

42.   } 

43.    ColxBulk() 

44.    { 

45.     bt.addActionListener ( this ) ; 

46.     ta.setFont(new Font("Monospaced",Font.BOLD,12)); 

47.     Container cp = getContentPane(); 

48.     cp.add( bt, BorderLayout.NORTH ); 

49.     cp.add( ta, BorderLayout.CENTER ); 

50.     addWindowListener( 

51.       new WindowAdapter() { 

52.        public void windowClosing(WindowEvent ev) 

53.        { System.exit(0);} } 

54.     ); 

55.  } 

56.  public static void main (String[] s) 

57.  { 

58.     ColxBulk t = new ColxBulk(); 

59.     t.setSize( 400,300 ); 

60.     t.setVisible(true); 

61.  } 

62.     JTextArea ta = new JTextArea ( 10, 30 ) ; 

63.     JButton bt = new JButton ( "Do it" ) ; 

64.