fuliqi
2024-08-29 4163c93761115c7524ef74a557a1f5e01eafb429
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
package com.ycl.api.YS.util;
 
import javax.swing.*;
import javax.swing.table.TableCellEditor;
 
 
public class ComboBoxTable extends JTable {
     /**
      * 序列化
      */
     private static final long serialVersionUID = 1L;
     private int myRow = -1, myCol = -1;
     TableCellEditor myEditor;
 
     public void setComboCell(int r, int c, String[]items) {
             this.myRow = r;
             this.myCol = c;
             TableCellEditor ce = new MyComboBoxEditor(items);
             this.myEditor = ce;
     }
 
     @Override
     public TableCellEditor getCellEditor(int row, int column) {
             System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor);
             if (row == myRow && column == myCol && myEditor != null)
                     return myEditor;
             return super.getCellEditor(row, column);
     }
 
    class MyComboBoxEditor extends DefaultCellEditor {
         /**
          *
          */
         private static final long serialVersionUID = 1L;
 
         public MyComboBoxEditor(String[] items) {
                 super(new JComboBox(items));
         }
    }
 
}