@Override public void actionPerformed(ActionEvent e) { ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString()); IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString()); if (e.getSource() == buttonInsert) { try { Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS); RoomsController.roomsController.save(rooms); int c = model.getRowCount(); for (int i = c - 1; i >= 0; i--) { model.removeRow(i); jRoom.revalidate(); } all(); JOptionPane.showMessageDialog(this, "ok"); } catch (Exception ex) { ex.printStackTrace(); } } if (e.getSource() == buttonUpdate) { try { Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS); rooms.setRoomID(IDROOM); RoomsController.roomsController.update(rooms); int c = model.getRowCount(); for (int i = c - 1; i >= 0; i--) { model.removeRow(i); jRoom.revalidate(); } all(); JOptionPane.showMessageDialog(this, "Update to succeed !"); } catch (Exception ex) { ex.printStackTrace(); } } if (e.getSource() == buttonDelete) { try { List<CheckIn> temp = CheckInController.checkInController.all(); for (int i = 0; i < temp.size(); i++) { if (IDROOM == temp.get(i).getRoomID()) { this.error = 0; } else { this.error = 0; RoomsController.roomsController.delete(IDROOM); int c = model.getRowCount(); for (int ii = c - 1; ii >= 0; ii--) { model.removeRow(ii); jRoom.revalidate(); } all(); } } JOptionPane.showMessageDialog(this, "Delete to succeed !"); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "can't delete row bcause check still !"); } } if (e.getSource() == buttonRefresh) {} }
public void getData() { for (int i = model.getRowCount() - 1; i >= 0; i--) { model.removeRow(i); } ArrayList<Book> list = bm.bookAllData(); for (Book book : list) { String[] data = {String.valueOf(book.getNo()), book.getTitle(), book.getAuthor()}; model.addRow(data); } }
public void getFindData() { for (int i = model.getRowCount() - 1; i >= 0; i--) { model.removeRow(i); } String pub = box.getSelectedItem().toString(); ArrayList<Book> list = bm.bookFindData(pub); tf.setText(pub); for (Book book : list) { String[] data = {String.valueOf(book.getNo()), book.getTitle(), book.getAuthor()}; model.addRow(data); } }
/** * Gets the list of selected records. * * @return the list of selected records. */ public Variability[] getSelectedRecords() { ArrayList list = new ArrayList(); int check_column = getCheckColumn(); for (int i = 0; i < model.getRowCount(); i++) { if (((Boolean) getValueAt(i, check_column)).booleanValue()) { Variability record = (Variability) record_list.elementAt(index.get(i)); list.add(record); } } Variability[] records = new Variability[list.size()]; return (Variability[]) list.toArray(records); }
public void getFindData(String column, String fdata) { for (int i = model.getRowCount() - 1; i >= 0; i--) { model.removeRow(i); } EmpDAO dao = new EmpDAO(); ArrayList<EmpDTO> list = dao.empFindData(column, fdata); for (EmpDTO d : list) { String[] data = { String.valueOf(d.getEmpno()), d.getEname(), d.getJob(), d.getHiredate().toString(), String.valueOf(d.getDeptno()) }; model.addRow(data); } }
private void backBind() { status.setText(viewModel.getStatus()); compute.setEnabled(viewModel.isButtonEnabled()); monthlyPayment.setText(viewModel.getMonthlyPayment()); overpaymentWithFees.setText(viewModel.getOverpaymentWithFees()); overpayment.setText(viewModel.getOverpayment()); DefaultTableModel model = viewModel.getGraphicOfPayments(); graphicOfPayments.setModel(model); graphicOfPayments.setPreferredSize( new Dimension( graphicOfPayments.getWidth(), graphicOfPayments.getRowHeight() * model.getRowCount())); List<String> log = viewModel.getLog(); String[] items = log.toArray(new String[log.size()]); logList.setListData(items); }