import java.sql.*; import java.util.*; import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; public class UpdateFoodItems extends JFrame implements ListSelectionListener,ActionListener { private static final int FRAME_WIDTH = 1200; private static final int FRAME_HEIGHT =900; private static final int FRAME_X_ORIGIN = 0; private static final int FRAME_Y_ORIGIN = 0; private static final int BUTTON_WIDTH = 200; private static final int BUTTON_HEIGHT = 30; private DefaultListModel listModel = new DefaultListModel(); private JList list = new JList(listModel); private JScrollPane scrollPane; private JButton UpdateButton; private JButton mainButton; private JTextField dishName = new JTextField(); private JTextField price = new JTextField(); private final String[] comboList = {"Main", "Dish", "Side"}; private JComboBox ddl = new JComboBox(comboList); public UpdateFoodItems() { setTitle ("Update Food Item Into Data Base!"); setSize (FRAME_WIDTH, FRAME_HEIGHT); setResizable (false); setLocation (FRAME_X_ORIGIN, FRAME_Y_ORIGIN); JPanel panel = new JPanel(null); UpdateButton = new JButton("Update To Data Base"); mainButton = new JButton ("Main"); mainButton.setBounds (700,500,120,30); mainButton.addActionListener (this); panel.add(mainButton); list.addListSelectionListener(this); scrollPane = new JScrollPane(list); scrollPane.setBounds(10,10,200,140); dishName.setBounds(10,160,130,23); price.setBounds(10,190,130,23); UpdateButton.setBounds (30,300, 180, 23); ddl.setBounds(10,220,130,23); panel.add(scrollPane); panel.add(dishName); panel.add(price); panel.add(ddl); panel.add(UpdateButton); getContentPane().add(panel); setVisible(true); listModel = retrieveAndSetObjectToList(listModel); list.setModel(listModel); } private DefaultListModel retrieveAndSetObjectToList(DefaultListModel listModel) { listModel = new DefaultListModel(); ArrayList list = RetrieveFoodItems.retrieveAllFromDB(); for(int count=0; count