@@ -0,0 +1,1786 @@
+%0Aimport javax.swing.*;%0Aimport java.awt.*;%0Aimport java.awt.event.*;%0A%0A%0A/* orig: TwoButtons */%0A%0Apublic class p379AnonAndLambda %7B%0A    JFrame frame;%0A    JLabel label;%0A    public static void main (String%5B%5D args) %7B%0A%09%09p379AnonAndLambda gui = new p379AnonAndLambda ();%0A%09%09gui.go();%0A    %7D%0A    public void go() %7B%0A%09%09frame = new JFrame();%0A%09%09frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A%09%09JButton labelButton = new JButton(%22Change Label%22);%0A%09%09labelButton.addActionListener%0A%09%09%09(%0A%09%09%09 new ActionListener() %7B %0A%09%09%09%09 public void actionPerformed(ActionEvent event) %7B%0A%09%09%09%09%09 label.setText(%22Ouch!%22);%0A%09%09%09%09%09 %0A%09%09%09%09 %7D%0A%09%09%09 %7D%0A%09%09%09 );%0A%09%09JButton colorButton = new JButton(%22Change Circle%22);%0A%09%09colorButton.addActionListener((e) -%3E frame.repaint());%0A%09%09label = new JLabel(%22I%E2%80%99m a label%22);%0A%09%09MyDrawPanel drawPanel = new MyDrawPanel();%0A%09%09%0A%09%09frame.getContentPane().add(BorderLayout.SOUTH, colorButton);%0A%09%09frame.getContentPane().add(BorderLayout.CENTER, drawPanel);%0A%09%09frame.getContentPane().add(BorderLayout.EAST, labelButton);%0A%09%09frame.getContentPane().add(BorderLayout.WEST, label);%0A%09%09frame.setSize(300,300);%0A%09%09frame.setVisible(true);%0A    %7D%0A%09%0A    /** From p. 371 and p. 367 */%0A    %0A    public class MyDrawPanel extends JPanel %7B%0A%09%09%0A%09%09public void paintComponent(Graphics g) %7B%0A%09%09%09Graphics2D g2d = (Graphics2D) g;%0A%09%09%09%0A%09%09%09int red = (int) (Math.random() * 256);%0A%09%09%09int green = (int) (Math.random() * 256);%0A%09%09%09int blue = (int) (Math.random() * 256);%0A%09%09%09Color startColor = new Color(red, green, blue);%0A%09%09%09red = (int) (Math.random() * 256);%0A%09%09%09green = (int) (Math.random() * 256);%0A%09%09%09blue = (int) (Math.random() * 256);%0A%09%09%09Color endColor = new Color(red, green, blue);%0A%09%09%09GradientPaint gradient = new GradientPaint(70,70,startColor, 150,150, endColor);%0A%09%09%09g2d.setPaint(gradient);%0A%09%09%09g2d.fillOval(70,70,100,100);%0A%09%09%7D%0A%09%09%0A    %7D%0A%09%0A%7D%0A

add anonymous class and lamnda example