package PS7; import javax.swing.*; import java.awt.*; public class StackingAreaPanel extends JPanel{ final int numProducts = 6; private StackArea [] stacks; private JLabel [] textFields; public StackingAreaPanel(StackArea [] s) { stacks = s; textFields = new JLabel[6]; setLayout(new GridLayout(4,3)); add(new JLabel(" Stereo Type 0 ")); add(new JLabel(" Stereo Type 1 ")); add(new JLabel(" Stereo Type 2 ")); for (int count = 0; count < numProducts/2; count++) { textFields[count]= new JLabel("0"); add(textFields[count]); } add(new JLabel(" Stereo Type 3 ")); add(new JLabel(" Stereo Type 4 ")); add(new JLabel(" Stereo Type 5 ")); for (int count = numProducts/2; count < numProducts; count++) { textFields[count]= new JLabel("0"); add(textFields[count]); } } public void updateDrawing() { for (int count = 0; count < 6; count++) { textFields[count].setText(Integer.toString(stacks[count].getTotalSize())); } } }