rendered paste body class TopMenu extends JPanel {
JDialog menuDialog; /////<<<<<<<<<<<<<<<<<<<<<<<
JPanel foodListPanel;
JButton addItemButton;
JButton removeButton;
JButton doneButton;
DefaultListModel menuItems;
JList list;
//JList priceList;
Font listFont = new Font("Courier New", Font.PLAIN, 15);
Font titleFont = new Font("Verdana", Font.BOLD, 25);
Font headingFont = new Font("Verdana", Font.BOLD, 10);
Color highlightColour = new Color(0,124,243);
Color titleColour = new Color(0,0,153);
TopMenu(String menuName, JDialog menuDialog) {
super(new BorderLayout());
this.menuDialog = menuDialog; ///<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
..........
ActionListener buttonListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == addItemButton) {
String item = JOptionPane.showInputDialog(null, "Enter Menu Item:", "Menu Item", JOptionPane.QUESTION_MESSAGE);
double price = 0.00;
menuItems.addElement(new MenuItem(item,price));
updateUI();
}
else if (e.getSource() == removeButton) {
try {
menuItems.remove(list.getSelectedIndex());
list.updateUI();
//priceList.updateUI();
}
catch (ArrayIndexOutOfBoundsException m) {
errorMessage("No value was selected");
}
}
else if (e.getSource() == doneButton) {
//PROBLEM HERE >>>>> menuDialog.setVisible(false);
}
}
};
......