/** * If the add button is pressed, this function creates a spot for it in the scroll pane, and tells * the restaurant panel to add a new person. * * @param name name of new person */ public void addPerson(String name, boolean isHungry) { if (name != null) { JButton button = new JButton(name); button.setBackground(Color.white); Dimension paneSize = scrollPane.getSize(); Dimension buttonSize = new Dimension( (paneSize.width / NUM_BUTTONS_COLS) - BUTTON_WIDTH_ADJUST, paneSize.height / NUM_BUTTONS_ROWS); button.setPreferredSize(buttonSize); button.setMinimumSize(buttonSize); button.setMaximumSize(buttonSize); button.addActionListener(this); list.add(button); view.add(button); if (isHungry) restPanel.addPerson(null, "Hungry" + type, name, 50); // puts hungry customer on list else restPanel.addPerson(null, type, name, 50); // puts customer on list // restPanel.showInfo(type, name);//puts hungry button on panel validate(); } }