1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
/*
* Created by JFormDesigner on Sat Jan 23 21:52:40 CET 2010
*/
package WCIhm;
+import java.awt.*;
public class V_RefCompanyType extends JPanel implements ActionListener {
private void buttonDeleteRow(ActionEvent e) {
int reponse = JOptionPane.showConfirmDialog(this,
"Êtes-vous sûr de vouloir supprimer ce type de société ?",
"", JOptionPane.YES_NO_OPTION);
if (reponse == JOptionPane.YES_OPTION) {
try {
model1.removeRow(table1.getSelectedRow());
} catch (Exception ee) {
JOptionPane.showMessageDialog(this, ee.getMessage(),
"Erreur", JOptionPane.ERROR_MESSAGE);
}
}
}
public V_RefCompanyType() throws HibernateException {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// JFormDesigner - End of component initialization //GEN-END:initComponents
// ************** //
// BEGIN SPECIFIC //
// ************** //
T_refcompanytype = vC_WCRefCompanyType.read("from RefCompanyType");
model1 = new tabModel() {
Class[] columnTypes = new Class[] { String.class, String.class };
@Override
public Class<?> getColumnClass(int columnIndex) {
return columnTypes[columnIndex];
}
};
table1.setModel(model1);
table1.setEditingColumn(0);
table1.setEditingColumn(1);
// Renderer
table1.getColumnModel().getColumn(0).setCellRenderer(new R_TableCellRenderer());
table1.getColumnModel().getColumn(1).setCellRenderer(new R_TableCellRenderer());
table1.setVisible(true);
scrollPane1.setViewportView(table1);
scrollPane1.setVisible(true);
setLocation(0, 0);
setVisible(true);
// ************** //
// END SPECIFIC //
// ************** //
}
public class tabModel extends DefaultTableModel {
public tabModel() {
super();
}
public int getRowCount() {
return T_refcompanytype.length;
}
public int getColumnCount() {
return columnNames.length;
}
public String getColumnName(int columnIndex) {
return columnNames[columnIndex];
}
public Object getValueAt(int rowIndex, int columnIndex) {
switch (columnIndex) {
case 0:
return T_refcompanytype[rowIndex].getCompanyTypeCode();
case 1:
return T_refcompanytype[rowIndex].getCompanyTypeLabel();
default:
return null; // Ne devrait jamais arriver
}
}
}
public void actionPerformed(ActionEvent arg0) {
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// JFormDesigner - End of variables declaration //GEN-END:variables
// ************** //
// BEGIN SPECIFIC //
// ************** //
static RefCompanyType[] T_refcompanytype;
static String[] columnNames = { "Code", "Libellé"};
static WCRefCompanyType vC_WCRefCompanyType = new WCRefCompanyType();
static RefCompanyType[] v_T_refcompanytype;
static tabModel model1;
// ************** //
// END SPECIFIC //
// ************** //
} |
Partager