Bonjour,

Je sollicite votre aide concernant un soucis en java lié au JComboBox d'un JTable.

Contexte:
Une JTable contenant dans 2 de ces colonnes des JComboBox.
La seconde colonne de JComboBox est dépendante du choix de la 1ère (JComboBox2 de la ligne N dépend du choix de la JComboBox1 de la même ligne).

Statut:
J'arrive bien à afficher ces 2 JComboBox avec les items à l'intérieur.

Problème:
Lorsque j'effectue un choix sur une JComboBox1, la JComboBox2 liée ne se met pas à jour.

Question:
Comment rafraichir la JComboBox2 pour afficher les sous-catégorie liée à la catégorie sélectionnée dans la JComboBox1 ?

Code:
Class Main/Application:
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
 
...
		tab = new CustomTableModel(pilote,host,login,pw,sql);
		T = new JTable(tab);
		T.setModel(tab);
 
		////////////////////////////
		// JCombobox
 
		// CATEGORIE
		TableColumn catColumn = getColumnEntity(2);
		tab.setUpCategoryColumn(catColumn);
		String categorie = tab.getCategorie();
		System.out.println(categorie);
 
		// SOUSCATEGORIE
		TableColumn sscatColumn = T.getColumnModel().getColumn(3);
		tab.setUpSousCategoryColumn(sscatColumn, categorie);
 
		JScrollPane jsp= new JScrollPane(T);//ScrollPane
 
	    topPanel.add(jsp);
...
	public TableColumn getColumnEntity(int idCol) {
		TableColumn catColumn = T.getColumnModel().getColumn(idCol);
		return catColumn;
	}
Class CustomTableModel:
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
 
...
	 public void setUpCategoryColumn(TableColumn catColumn) {
		 //ComboBox for the CATEGORIE cells
		 JComboBox categorieCb = new JComboBox();
		 categorieCb.addItem("Categorie 1");
		 categorieCb.addItem("Categorie 2");
		 categorieCb.setEditable(true);
		 catColumn.setCellEditor(new DefaultCellEditor(categorieCb));
		 //Set up tool tips for the CATEGORIE cells
		 //DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		 //renderer.setToolTipText("Click for combo box");
		 //sportColumn.setCellRenderer(renderer);
		 categorieCb.addItemListener(this);
	 }
 
	 public void setUpSousCategoryColumn(TableColumn scColumn, String categorie) {
		 if(categorie == "Categorie 1") {
			 System.out.println("passage HighTech");
			 //ComboBox for the SOUSCATEGORIE cells
			 JComboBox souscategorieCb = new JComboBox();
			 souscategorieCb.addItem("Sous Categorie 11");
			 souscategorieCb.addItem("Sous Categorie 12");
			 scColumn.setCellEditor(new DefaultCellEditor(souscategorieCb));
		}
		else if(categorie == "Categorie 2") {
			System.out.println("passage else");
			//ComboBox for the SOUSCATEGORIE cells
			JComboBox souscategorieCb = new JComboBox();
			souscategorieCb.addItem("Sous Categorie 21");
			souscategorieCb.addItem("Sous Categorie 22");
			scColumn.setCellEditor(new DefaultCellEditor(souscategorieCb));
		}
	 }
...
	  public void itemStateChanged(ItemEvent ie) {
	      categorie = (String)ie.getItem();
	      System.out.println("CAT: "+categorie);
	      //TableColumn sscatColumn = getColumnModel().getColumn(3);
	      Application ap = new Application();
	      TableColumn sscatColumn = ap.getColumnEntity(3);
	      setUpSousCategoryColumn(sscatColumn,categorie);
 
	  }
 
	  public String getCategorie() {
		  return categorie;
	  }
Merci d'avance !