public void update() { graphicPanel.removeAll(); graphicPanel.add(title); graphicPanel.add(mainMenuButton); graphicPanel.add(refreshButton); graphicPanel.add(logoutButton); graphicPanel.setLayout(new FlowLayout()); JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL); separator.setPreferredSize(new Dimension(600, 10)); graphicPanel.add(separator); if (page.matches("main")) { graphicPanel.add(reportLocationButton); graphicPanel.add(loadShipmentButton); } else if (page.matches("reportloc")) { locationComboBox = new JComboBox(driver.getLocation().getNeighbours().toArray()); graphicPanel.add(locationComboBox); graphicPanel.add(reportButton); } else if (page.matches("loadShipment")) { shipmentList = new ArrayList<Shipment>(); for (int i = 0; i < driverService.getAssignedShipments().size(); ++i) { if (driverService.canPickup(driver, driverService.getAssignedShipments().get(i))) { shipmentList.add(driverService.getAssignedShipments().get(i)); } } Object[][] tableContent = new Object[shipmentList.size()][shipmentTableColumnTitles.length]; for (int i = 0; i < shipmentList.size(); ++i) { tableContent[i][0] = shipmentList.get(i).getType(); tableContent[i][1] = shipmentList.get(i).getApproximateWeight(); tableContent[i][2] = shipmentList.get(i).getDueDate(); tableContent[i][3] = shipmentList.get(i).getDestination(); } shipmentTable = new JTable(tableContent, shipmentTableColumnTitles); shipmentTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane tablePane = new JScrollPane(shipmentTable); tablePane.setPreferredSize(new Dimension(550, 250)); graphicPanel.add(tablePane); graphicPanel.add(pickupButton); } graphicPanel.validate(); graphicPanel.repaint(); }