Bonjour à tous,

Je me suis attaqué à la création de tableau depuis hier soir, après avoir réussi a faire des trucs là j'avou je bloque. Voici mon problème :

J'ai créer un modèle pour le tableau avec notamment une méthode insertLine et pour tester j'ai utilisé une méthode ProcessingJTable() seulement la gros probleme il ne veut rien m'afficher !!!

Pour créer un JTable et le modifier un AbtractsModel suffit ou faut-il des render etc ... ??

Ais-je oublier quelquechose ?

Merci de votre aide

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
	/***************************************************************************
	 * Part Describing Table Solution
	 */
	public class EquipmentsModel extends AbstractTableModel {
		/**
		 * 
		 */
		private static final long serialVersionUID = 5588440056592186407L;

		private final String[] columnsNames = new String[] { "Selection",
				"Equipements", "XML", "Accessibility", "Audited" };

		private Object[][] data;

		public EquipmentsModel(Object[][] data) {
			this.data = data;
		}

		public void insertLine(int i, Object[] value) {
			this.data[i] = value;
		}

		public int getColumnCount() {
			return columnsNames.length;
		}

		public int getRowCount() {
			return data.length;
		}

		public int findColumnIndex(String columnName) {
			for (int i = 0; i < getColumnCount(); i++) {
				if (columnsNames[i].indexOf(columnName) != -1) {
					return i;
				}
			}
			// Should never return -1
			return -1;
		}

		public String getColumnName(int columnIndex) {
			return columnsNames[columnIndex];
		}

		public Object getValueAt(int rowIndex, int columnIndex) {
			return data[rowIndex][columnIndex];
		}

		public Class getColumnClass(int columnIndex) {
			return getValueAt(0, columnIndex).getClass();
		}

		public boolean isCellEditable(int rowIndex, int columnIndex) {
			if (columnIndex != 0)
				return false;
			else
				return true;
		}

		public void setValueAt(Object value, int rowIndex, int columnIndex) {
			data[rowIndex][columnIndex] = value;
			fireTableCellUpdated(rowIndex, columnIndex);
		}

	}



	public JScrollPane ProcessingJTable() {

		

		EquipmentsModel TP = new EquipmentsModel(new Object [3][5]);
		
		TP.insertLine(1, new Object[] {null ,"tot", null, null, null });

		System.out.println(TP.getColumnCount() + " " + TP.getRowCount());
		
		JTable toto = new JTable(TP);

		
		System.out.println(TP.isCellEditable(1, 1));

		JScrollPane SP = new JScrollPane(toto);
		
		return SP;
	}