开发者

Change value in column on select JComboBox

开发者 https://www.devze.com 2023-03-07 04:17 出处:网络
I have table with two columns and lot of rows, each column contain JComboBox. I wrap JComboBox into D开发者_Go百科efaultCellEditor and added to model. How to implement that when I choose in JComboBox

I have table with two columns and lot of rows, each column contain JComboBox. I wrap JComboBox into D开发者_Go百科efaultCellEditor and added to model. How to implement that when I choose in JComboBox ( example row=3 column=0) I set some value at JComboBox ( row=3 column =1)?


In your Table Model's setValue method, when you have a change in column 0 call setValue again for column 1 with the value you want in column 1.


A TableModelListener will let you be notified of changes in a cell's value. Once notified you use that information to change the value in your other cells via setValue as jzd mentions.


please read this tutoriar http://download.oracle.com/javase/tutorial/uiswing/components/table.html#combobox example shows basic workaround for TableCellEditor, tons of examples for that http://www.java2s.com/Code/Java/Swing-JFC/CatalogSwing-JFC.htm subfolder http://www.java2s.com/Code/Java/Swing-JFC/Table-Renderer-Editor.htm

0

精彩评论

暂无评论...
验证码 换一张
取 消