/** Gets the order history from text file and outputs to console. */ private void getOrderHistory() { ArrayList<String> tOrderHistory = new ArrayList<String>(); tOrderHistory = OrderHistory.sReadFileData(); for (int i = 0; i < tOrderHistory.size(); i++) { console.appendToOutput(tOrderHistory.get(i) + "\n", Color.BLACK, false); } }
/** * The Create function creates all buttons and tables required for the first tab. * * @return Tab1 */ @SuppressWarnings("serial") public JPanel create() { tab1 = new JPanel(); tab1.setLayout(new MigLayout()); // Creating buttons for gui display. JButton restockButton = new JButton("Restock"); JButton newStockButton = new JButton("New Stock"); JButton deleteStockButton = new JButton("Delete Stock"); // Creating scroll panel for console. cPanel = new JPanel(); cPanel.setPreferredSize(new Dimension(300, 400)); console = new ScrollTextArea(300, 400); console.setPreferredSize(new Dimension(320, 475)); cPanel.add(console); getOrderHistory(); // Make the Table for stocks. tModel = new StockTableModel(); stockTableModel = new DefaultTableModel( tModel.data, new Object[] {"Name", "Current in Stock in /g or /cm", "# to restock"}) { @Override public boolean isCellEditable(int row, int column) { return column == 2; } }; stockTable = new JTable(stockTableModel); stockTable.getTableHeader().setReorderingAllowed(false); JScrollPane scrollPane = new JScrollPane(stockTable); // add created objects to tab1 in correct locations tab1.add(scrollPane, "cell 0 0, split 2"); tab1.add(cPanel, "cell 0 0"); tab1.add(restockButton, "cell 0 1, split 3,grow"); tab1.add(newStockButton, "cell 0 1 , grow"); tab1.add(deleteStockButton, "cell 0 1,grow"); // add action listeners to buttons. newStockButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { newStock.newStock(stockTableModel); } }); deleteStockButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { deleteStock.delete(stockTableModel); } }); restockButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { restock.restock(stockTable, console); } }); return tab1; }