Bonjour,
Désolée de vous embeter avec un sujet
qui a été maintes fois abordé dans le forum, mais j'y arrive toujours pas
Ca fait plusieurs jour que je suis dessus, O SE COOOOOOOURS !
Aprsè avoir lu le forum et le tutorial de sun voici mon code.
Mais je n'ai toujours pas de combox qui s'affiche.
Qu'un peux m'aider ?
et le code de ma TableModele
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public void setUpSportColumn(JTable table, TableColumn sportColumn) { //Set up the editor for the sport cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("1"); comboBox.addItem("2"); comboBox.addItem("3"); comboBox.addItem("4"); comboBox.addItem("5"); comboBox.addItem("6"); sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); //Set up tool tips for the sport cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); sportColumn.setCellRenderer(renderer); } private JTable getJTable() { if (jTable == null) { jTable = new JTable(); jTable.setModel(getTableActesCCAMModel()); TableColumn sportColumn = jTable.getColumnModel().getColumn(5); setUpSportColumn(jTable, sportColumn); } return jTable; } private TableActesCCAMModel getTableActesCCAMModel() { if (tableActesCCAMModel == null) { tableActesCCAMModel = new TableActesCCAMModel(null); } return tableActesCCAMModel; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
118
119 package inov_sante.ihm.tablesModels; import inovans.tools.metier.CotationCCAM; import javax.swing.DefaultCellEditor; import javax.swing.JComboBox; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumn; import org.openoffice.java.accessibility.ComboBox; public class TableActesCCAMModel extends AbstractTableModel implements SuperTableModel { private CotationCCAM[] tableCotationCCAM = null; private String[] columnNames = {"Acte","Code","Montant","Modificateurs","Activité","Phase","Associataion"}; public TableActesCCAMModel(CotationCCAM[] tableCotationCCAM) { super(); this.tableCotationCCAM = tableCotationCCAM; if (this.tableCotationCCAM == null) { this.tableCotationCCAM = new CotationCCAM[5]; } } public int getColumnCount() { return columnNames.length; } public int getRowCount() { int nb = 0; for (int i = 0; i < 5; i++) { if (tableCotationCCAM[i] != null) { nb++; } } return nb; } public Object getValueAt(int rowIndex, int columnIndex) { CotationCCAM cotationCCAM = tableCotationCCAM[rowIndex]; if (cotationCCAM == null) return ""; switch (columnIndex) { case 0: return cotationCCAM.getLibelle(); case 1: return cotationCCAM.getCodeCCAM(); case 2: return new Float(cotationCCAM.getMontant()); case 3: return cotationCCAM.getModificateurs(); case 4: return cotationCCAM.getCodeActivite(); case 5: return cotationCCAM.getCodePhase(); case 6: return cotationCCAM.getCodeAssociation(); default: return "WARNING"; } } public String getColumnName(int col) { return columnNames[col]; } public Object getDataAt(int rowIndex) { return tableCotationCCAM[rowIndex]; } public boolean removeRow(int rowindex) { tableCotationCCAM[rowindex] = null; fireTableRowsDeleted(rowindex, rowindex); return true; } public boolean removeAllRow() { for (int i = 0; i < 5; i++) { tableCotationCCAM[i] = null; } fireTableDataChanged(); return true; } public boolean insertRow(Object object) { for (int i = 0; i < 5; i++) { if (tableCotationCCAM[i] == null) { tableCotationCCAM[i] = (CotationCCAM) object; break; } } fireTableDataChanged(); return true; } public Class getColumnClass(int columnIndex) { return getValueAt(0, columnIndex).getClass(); } }
Partager