private void delete_branch_locations() { int row = tbl_branch_locations.getSelectedRow(); if (row < 0) { return; } final to_branch_locations to = (to_branch_locations) tbl_branch_locations_ALM.get(tbl_branch_locations.convertRowIndexToModel(row)); if (to.status == 1) { Alert.set(0, "Cannot Delete Default Location"); return; } Window p = (Window) this; Dlg_auth nd = Dlg_auth.create(p, true); nd.setTitle(""); nd.setCallback( new Dlg_auth.Callback() { @Override public void ok(CloseDialog closeDialog, Dlg_auth.OutputData data) { closeDialog.ok(); jProgressBar1.setString("Loading...Please wait..."); jProgressBar1.setIndeterminate(true); btn_new.setEnabled(false); btn_add.setEnabled(false); btn_edit.setEnabled(false); btn_delete.setEnabled(false); Thread t = new Thread( new Runnable() { @Override public void run() { S1_branch_locations.delete_branch_locations(to); data_cols(); clear_branch_locations(); Alert.set(3, ""); jProgressBar1.setString("Finished..."); jProgressBar1.setIndeterminate(false); btn_new.setEnabled(true); btn_add.setEnabled(true); btn_edit.setEnabled(true); btn_delete.setEnabled(true); } }); t.start(); } }); nd.setLocationRelativeTo(jScrollPane2); nd.setVisible(true); }
private void init_tbl_branch_locations() { tbl_branch_locations_ALM = new ArrayListModel(); tbl_branch_locations_M = new Tblbranch_locationsModel(tbl_branch_locations_ALM); tbl_branch_locations.getTableHeader().setPreferredSize(new Dimension(100, 40)); tbl_branch_locations.setModel(tbl_branch_locations_M); tbl_branch_locations.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); tbl_branch_locations.setRowHeight(25); int[] tbl_widths_branch_locations = {200, 200, 70, 0, 0, 0}; for (int i = 0, n = tbl_widths_branch_locations.length; i < n; i++) { if (i == 0) { continue; } TableWidthUtilities.setColumnWidth(tbl_branch_locations, i, tbl_widths_branch_locations[i]); } Dimension d = tbl_branch_locations.getTableHeader().getPreferredSize(); d.height = 25; tbl_branch_locations.getTableHeader().setPreferredSize(d); tbl_branch_locations.getTableHeader().setFont(new java.awt.Font("Arial", 0, 11)); tbl_branch_locations.setRowHeight(25); tbl_branch_locations.setFont(new java.awt.Font("Arial", 0, 11)); }