001 package pnc; 002 import java.awt.*; 003 import java.awt.event.*; 004 005 public 006 abstract class InterPNC extends PNC { 007 private Button consume; 008 private Button produce; 009 010 public void init() { 011 // call super class layout 012 super.init(); 013 014 // create buttons 015 this.consume = new Button("Consume"); 016 this.consume.addActionListener(new ActionListener() { 017 public void actionPerformed(ActionEvent e) { 018 Consumer unmaker = 019 new Consumer(InterPNC.this.store, 020 InterPNC.this.toConsume); 021 unmaker.start(); 022 } 023 }); 024 this.produce = new Button("Produce"); 025 this.produce.addActionListener(new ActionListener() { 026 public void actionPerformed(ActionEvent e) { 027 Producer maker = 028 new Producer(InterPNC.this.store, 029 InterPNC.this.toProduce); 030 maker.start(); 031 } 032 }); 033 034 // layout buttons 035 Panel panel = new Panel(); 036 panel.add(this.produce); 037 panel.add(this.consume); 038 this.add("South", panel); 039 } 040 } 041 042 043 044 045 046