/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user changed the service filter option if (e.getSource() == service_box) { service_list.setEnabled(service_box.isSelected()); service_list.clearSelection(); remove_service_button.setEnabled(false); add_service_field.setEnabled(service_box.isSelected()); add_service_field.setText(""); add_service_button.setEnabled(false); } // Check if the user pressed the add service button if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) { String text = add_service_field.getText(); if ((text != null) && (text.length() > 0)) { service_data.addElement(text); service_list.setListData(service_data); } add_service_field.setText(""); add_service_field.requestFocus(); } // Check if the user pressed the remove service button if (e.getSource() == remove_service_button) { Object[] sels = service_list.getSelectedValues(); for (int i = 0; i < sels.length; i++) { service_data.removeElement(sels[i]); } service_list.setListData(service_data); service_list.clearSelection(); } }
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); }