Posted on 2013-07-23 11:02
TWaver 阅读(1634)
评论(3) 编辑 收藏
属性编辑页面可以自己扩展editor,自定义A,B两个Editor,B的值受A值改变而改变
思路很简单,存在一个容器,给TDataBox添加网元属性变化监听器ElementPropertyChangeListener,当网元属性A变化后,改变容器中的值,然后属性B的Editor加载容器中的值,这样就可以实现功能了
1 public void propertyChange(PropertyChangeEvent evt) {
2 String pro = TWaverUtil.getPropertyName(evt);
3 Element element = (Element)evt.getSource();
4 if("A".equals(pro)){
5 CustomUtil.ref = CustomUtil.getBRefs((Integer)element.getUserProperty("A"));
6 }
7 }
8 public static String[] getBRefs(int v){
9 switch(v){
10 case 1:
11 case 2:
12 return REF1;
13 default:
14 return REF2;
15 }
16 }
17 public Component getTableCellEditorComponent(JTable table, Object value,
18 boolean isSelected, int row, int column) {
19 JComboBox comboBox = (JComboBox)this.getComponent();
20 comboBox.removeAllItems();
21 if(CustomUtil.ref!=null){
22 for(int i=0;i<CustomUtil.ref.length;i++){
23 comboBox.addItem(CustomUtil.ref[i]);
24 }
25 }
26
27 return super.getTableCellEditorComponent(table, value, isSelected, row, column);
28 }
可运行代码下载:
Archive