001    // make some instance variables local instead
002    // remove underscores
003    // comment
004    // javadoc
005    
006    package pnc;
007    import java.awt.*;
008    import java.applet.*;
009    import cs101.awt.DisplayField;
010    
011    public
012    abstract class PNC extends Applet {
013      protected Buffer store;
014      protected DisplayField toProduce;
015      protected DisplayField toConsume;
016    
017    
018      public void init() { 
019    
020        // create components 
021        if (this.store == null) // should be newed in subclass
022          System.out.println("Subclass did not initialize buffer");
023    
024        this.toProduce = new DisplayField("0", true, Color.white,
025                                      Color.blue);
026        this.toConsume = new DisplayField("0", true, Color.white,
027                                      Color.lightGray);
028    
029        // lay them out
030        this.setBackground(Color.white);
031        this.setForeground(Color.black);
032    
033        // top
034        Panel topPanel = new Panel();
035        topPanel.setLayout(new BorderLayout());
036        topPanel.add("West",this.store.getWriteFlag());
037        topPanel.add("East",this.store.getReadFlag());
038    
039        // center
040        Panel centerPanel = new Panel();
041        centerPanel.setLayout(new BorderLayout());
042        Panel proPanel = new Panel();
043        proPanel.add(new Label("Waiting to write"));
044        proPanel.add(this.toProduce);
045        Panel conPanel = new Panel();
046        conPanel.add(new Label("Waiting to read"));
047        conPanel.add(this.toConsume);       
048        centerPanel.add("West",proPanel);
049        centerPanel.add("East",conPanel);
050        centerPanel.add("Center",this.store.getStoragePanel());
051        
052        // put it all together
053        this.setLayout(new BorderLayout());
054        this.add("North", topPanel);
055        this.add("Center", centerPanel);
056    
057      }
058    
059    }
060    
061    
062    
063    
064    
065    
066    
067    
068    
069    
070    
071    
072    
073    
074    
075    
076    
077    
078    
079    
080