zxl
3 天以前 3b0516a2959e25576e4f3fda697a3b025d06c8c9
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
package com.ycl.api.YS.config.motion;
 
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.lib.NetDEVSDKLib;
import com.ycl.api.YS.lib.NetDEVSDKLib.*;
 
import javax.swing.*;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
 
 
public class MotionDetectionAreaWindow extends JDialog{
 
    private static final long serialVersionUID = 1L;
    private JTable rectangleTable;
    private JTable gridTable;
    private Pointer lpUserId;
    private int ChannelID;
    JPanel MotionDetectionAreaPanel = new JPanel();
    //矩形
    NETDEV_MOTION_DETECTION_AREA_RECTANGLE_INFO_LIST_S stRectangleInfo;
    JButton RectangleAreaAdd = new JButton("Add");
    JButton RectangleAreaSave = new JButton("Save");
    JButton RectangleAreaDelete = new JButton("Delete");
    //宏块
    NETDEV_MOTION_DETECTION_AREA_GRID_INFO_S stGridInfo;
    private JTextField textFieldConfigChannelMotionGridAreaSensitivity;
    JButton GridAreaSave = new JButton("Save");
    JCheckBox textFieldConfigChannelMotionGridAreaEnabled;
 
    NetDEVSDKLib netdevsdk = NetDEVSDKLib.NETDEVSDK_INSTANCE;
 
    public static class Montion_DETECTION_AREA_WINDOW_EFFECT{
        public static final int Montion_DETECTION_AREA_WINDOW_ADD             = 1;        /* 添加运动检测区域信息 */
        public static final int Montion_DETECTION_AREA_WINDOW_MODIFY          = 2;        /* 修改运动检测区域信息 */
    }
 
    public MotionDetectionAreaWindow(int dwAreaType,Pointer lpUserID,int ChannelID) {
        this.lpUserId = lpUserID;
        this.ChannelID = ChannelID;
        this.setSize(1400,800);
        setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        this.setTitle("Modify Montion Dection Area");
        this.setVisible(true);
 
        Toolkit toolkit=Toolkit.getDefaultToolkit();
        Dimension screenSize =toolkit.getScreenSize();
        int x=(screenSize.width-this.getWidth())/2;
        int y=(screenSize.height-this.getHeight())/2;
        this.setLocation(x,y);
        getContentPane().add(MotionDetectionAreaPanel, BorderLayout.CENTER);
 
        if(dwAreaType == NETDEV_MOTION_DETECTION_AREA_TYPE_E.NETDEV_MOTION_DETECTION_AREA_TYPE_RECTANGLE){
        //判断运动检测区域类型为矩形
            MotionDetectionAreaPanel.setLayout(null);
            MotionDetectionAreaPanel.setVisible(true);
            rectangleTable = new JTable();
            JScrollPane scrollPaneConfigMotionRectangle = new JScrollPane(rectangleTable,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPaneConfigMotionRectangle.setBounds(10, 50, 1300, 500);
            MotionDetectionAreaPanel.add(scrollPaneConfigMotionRectangle, BorderLayout.CENTER);
            Vector<String> headerNames=new Vector<>();
            headerNames.add("Enable");
            headerNames.add("ID");
            headerNames.add("Sensitivity(1~100)");
            headerNames.add("Duration(1~100)");
            headerNames.add("TargetSize(1~100)");
            headerNames.add("TopLeftX");
            headerNames.add("TopLeftY");
            headerNames.add("BottomRightX");
            headerNames.add("BottomRightY");
            Vector data = this.getRectangleData();
            CheckTableModle RectangleAreatableModel=new CheckTableModle(data,headerNames);
            rectangleTable.setModel(RectangleAreatableModel);
            rectangleTable.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(rectangleTable));
 
            RectangleAreaAdd.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if(null == lpUserID) {
                        JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                        return;
                    }
                    if(ChannelID == 0) {
                        JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
                        return;
                    }
                    Vector RectangleVector = new Vector();
                    if(RectangleAreatableModel.getRowCount() >= NetDEVSDKLib.NETDEV_LEN_8) {
                        JOptionPane.showMessageDialog(null, "Please don't click add button beacuse array size is pass.");
                        return;
                    }
                    if(rectangleTable.getSelectedRowCount() == 0){
                        int i = RectangleAreatableModel.getRowCount();
                        RectangleVector.add(true);
                        RectangleVector.add(i);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleAreatableModel.insertRow(i, RectangleVector);
                    }else if(rectangleTable.getSelectedRowCount() == 1){
                        int i = rectangleTable.getRowCount();
                        RectangleVector.add(true);
                        RectangleVector.add(i);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleVector.add(0);
                        RectangleAreatableModel.insertRow(i, RectangleVector);
                    }else{
                        JOptionPane.showMessageDialog(null, "Can't select multiple! please select one");
                        return;
                    }
                }
            });
            RectangleAreaAdd.setBounds(400, 600, 93, 23);
            MotionDetectionAreaPanel.add(RectangleAreaAdd);
 
            RectangleAreaDelete.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if(null == lpUserID){
                        JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                        return;
                    }
                    if(ChannelID == 0) {
                        JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
                        return;
                    }
                    if(rectangleTable.getSelectedRowCount() == 0) {
                        RectangleAreatableModel.removeRow(RectangleAreatableModel.getRowCount()-1);
                    }else if(rectangleTable.getSelectedRowCount() == 1) {
                        RectangleAreatableModel.removeRow(rectangleTable.getSelectedRow());
                    }else{
                        JOptionPane.showMessageDialog(null, "Can't select multiple! please select one");
                    }
                }
            });
            RectangleAreaDelete.setBounds(600, 600, 93, 23);
            MotionDetectionAreaPanel.add(RectangleAreaDelete);
 
            RectangleAreaSave.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if(null == lpUserID){
                        JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                        return;
                    }
                    if(ChannelID == 0){
                        JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
                        return;
                    }
                    stRectangleInfo = new NETDEV_MOTION_DETECTION_AREA_RECTANGLE_INFO_LIST_S();
                    for(int i =0; i< RectangleAreatableModel.getRowCount(); i++)
                    {
                        stRectangleInfo.astRectangleAreaInfoList[i] = new NETDEV_MOTION_DETECTION_AREA_RECTANGLE_INFO_S();
                        if(new Boolean(RectangleAreatableModel.getValueAt(i, 0).toString()) == true){
                            stRectangleInfo.astRectangleAreaInfoList[i].bEnabled = 1;
 
                        }else{
                            stRectangleInfo.astRectangleAreaInfoList[i].bEnabled = 0;
 
                        }
                        stRectangleInfo.astRectangleAreaInfoList[i].udwID = Integer.valueOf(RectangleAreatableModel.getValueAt(i, 1).toString());
 
                        if( Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 2).toString())>100) {
                            JOptionPane.showMessageDialog(null, "Sensitivity can not more than one hundred");
                            return;
                        }
                        if( Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 2).toString())<=0) {
                            JOptionPane.showMessageDialog(null, "Sensitivity can not less than one");
                            return;
                        }
 
                        if( Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 3).toString())>100) {
                            JOptionPane.showMessageDialog(null, "Duration can not more than one hundred");
                            return;
                        }
                        if( Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 3).toString())<=0) {
                            JOptionPane.showMessageDialog(null, "Duration can not less than one");
                            return;
                        }
 
                        if( Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 4).toString())>100) {
                            JOptionPane.showMessageDialog(null, "TargetSize can not more than one hundred");
                            return;
                        }
                        if( Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 4).toString())<=0) {
                            JOptionPane.showMessageDialog(null, "TargetSize can not less than one");
                            return;
                        }
 
                        stRectangleInfo.astRectangleAreaInfoList[i].udwSensitivity = Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 2).toString());
                        stRectangleInfo.astRectangleAreaInfoList[i].udwDuration = Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 3).toString());
                        stRectangleInfo.astRectangleAreaInfoList[i].udwTargetSize = Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 4).toString());
                        stRectangleInfo.astRectangleAreaInfoList[i].stRectAreaInfo.udwTopLeftX = Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 5).toString());
                        stRectangleInfo.astRectangleAreaInfoList[i].stRectAreaInfo.udwTopLeftY = Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 6).toString());
                        stRectangleInfo.astRectangleAreaInfoList[i].stRectAreaInfo.udwBottomRightX = Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 7).toString());
                        stRectangleInfo.astRectangleAreaInfoList[i].stRectAreaInfo.udwBottomRightY = Integer.valueOf((String) RectangleAreatableModel.getValueAt(i, 8).toString());
                    }
                    stRectangleInfo.udwNum = RectangleAreatableModel.getRowCount();
 
                    stRectangleInfo.write();
                    boolean bRet = netdevsdk.NETDEV_SetDevConfig(lpUserID, ChannelID, NETDEV_CONFIG_COMMAND_E.NETDEV_SET_MOTION_DETECTION_AREA_RECTANGLE_INFO_LIST, stRectangleInfo.getPointer(), stRectangleInfo.size());
                    if(bRet != true)
                    {
                        JOptionPane.showMessageDialog(null, "Set failed,Number of area excess capacity");
                        System.out.printf("NETDEV_SetDevConfig failed:%d\n", netdevsdk.NETDEV_GetLastError());
                        return;
                    }else {
                        JOptionPane.showMessageDialog(null, "Set success!");
                    }
                }
            });
            RectangleAreaSave.setBounds(800, 600, 93, 23);
            MotionDetectionAreaPanel.add(RectangleAreaSave);
 
        }else if(dwAreaType == NETDEV_MOTION_DETECTION_AREA_TYPE_E.NETDEV_MOTION_DETECTION_AREA_TYPE_MB){
            //判断运动检测区域类型为宏块
            MotionDetectionAreaPanel.setLayout(null);
            MotionDetectionAreaPanel.setVisible(true);
            JLabel lblAreaGridEnabled = new JLabel("AreaGrid_Enabled");
            lblAreaGridEnabled.setBounds(10, 10, 120, 35);
            MotionDetectionAreaPanel.add(lblAreaGridEnabled);
            textFieldConfigChannelMotionGridAreaEnabled = new JCheckBox("Enable");
            textFieldConfigChannelMotionGridAreaEnabled.setBounds(130, 10, 100, 35);
            MotionDetectionAreaPanel.add(textFieldConfigChannelMotionGridAreaEnabled);
            MotionDetectionAreaPanel.add(textFieldConfigChannelMotionGridAreaEnabled);
 
            JLabel lblAreaGridSensitivity = new JLabel("AreaGrid_Sensitivity");
            lblAreaGridSensitivity.setBounds(400, 10, 140, 35);
            MotionDetectionAreaPanel.add(lblAreaGridSensitivity);
            textFieldConfigChannelMotionGridAreaSensitivity = new JTextField();
            textFieldConfigChannelMotionGridAreaSensitivity.setColumns(10);
            textFieldConfigChannelMotionGridAreaSensitivity.setBounds(560, 10, 160, 35);
            MotionDetectionAreaPanel.add(textFieldConfigChannelMotionGridAreaSensitivity);
 
            JLabel lblAreaGridPanel = new JLabel();
            lblAreaGridPanel.setBorder(new TitledBorder(null, "AreaGrid_Info", TitledBorder.LEADING, TitledBorder.TOP, null, null));
            lblAreaGridPanel.setBounds(10, 110, 1300, 600);
            MotionDetectionAreaPanel.add(lblAreaGridPanel);
 
            gridTable = new JTable();
            JScrollPane scrollPaneConfigMotionGridRow = new JScrollPane(gridTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPaneConfigMotionGridRow.setBounds(30, 140, 1260, 520);
            MotionDetectionAreaPanel.add(scrollPaneConfigMotionGridRow, BorderLayout.CENTER);
            Vector headerColumnNames=new Vector();
            for(int i = 0;i < 22; i++){
                headerColumnNames.add(i+1);
            }
 
            Vector rowData = this.getGridData();
            CheckTableModle GridTableModel=new CheckTableModle(rowData,headerColumnNames);
            gridTable.setModel(GridTableModel);
            gridTable.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(gridTable));
 
            GridAreaSave.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if(null == lpUserID){
                        JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                        return;
                    }
                    if(ChannelID == 0){
                        JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
                        return;
                    }
                    stGridInfo = new NETDEV_MOTION_DETECTION_AREA_GRID_INFO_S();
                    if(textFieldConfigChannelMotionGridAreaEnabled.isSelected() == true){
                        stGridInfo.bEnabled = 1;
                    }else{
                        stGridInfo.bEnabled = 0;
                    }
                    if("".equals(textFieldConfigChannelMotionGridAreaSensitivity.getText()) || textFieldConfigChannelMotionGridAreaSensitivity.getText() == null){
                        JOptionPane.showMessageDialog(null, "Must input Sensitivity !");
                        return;
                    }
 
                    if(Integer.valueOf(textFieldConfigChannelMotionGridAreaSensitivity.getText().toString())<=0) {
                        JOptionPane.showMessageDialog(null, "Sensitivity can not less than one");
                        return;
                    }
 
                    if(Integer.valueOf(textFieldConfigChannelMotionGridAreaSensitivity.getText().toString())>100) {
                        JOptionPane.showMessageDialog(null, "Sensitivity can not more than hundred");
                        return;
                    }
 
                    stGridInfo.udwSensitivity = Integer.valueOf(textFieldConfigChannelMotionGridAreaSensitivity.getText().toString());
 
                    for(int i =0; i< NetDEVSDKLib.NETDEV_SCREEN_INFO_ROW; i++)
                    {
                        for(int j =0; j< NetDEVSDKLib.NETDEV_SCREEN_INFO_COLUMN; j++)
                        {
                            try{
                                if(Boolean.valueOf(gridTable.getValueAt(i, j).toString()) == true){
                                    stGridInfo.awGridInfo[i*NetDEVSDKLib.NETDEV_SCREEN_INFO_COLUMN+j] = 1;
                                }else{
                                    stGridInfo.awGridInfo[i*NetDEVSDKLib.NETDEV_SCREEN_INFO_COLUMN+j] = 0;
                                }
                            }catch (Exception exp){
                                exp.printStackTrace();
                            }
                        }
                    }
 
                    stGridInfo.write();
                    boolean bRet = netdevsdk.NETDEV_SetDevConfig(lpUserID, ChannelID, NETDEV_CONFIG_COMMAND_E.NETDEV_SET_MOTION_DETECTION_AREA_GRID_INFO, stGridInfo.getPointer(), stGridInfo.size());
                    if(bRet != true)
                    {
                        System.out.printf("NETDEV_SetDevConfig failed:%d\n", netdevsdk.NETDEV_GetLastError());
                        return;
                    }
                        JOptionPane.showMessageDialog(null, "Set success!");
                }
            });
            GridAreaSave.setBounds(570, 715, 120, 40);
            MotionDetectionAreaPanel.add(GridAreaSave);
        }
    }
 
    /**
     *
     * @introduction Get rectangular area table data
     * @description
     *
     */
    public Vector getRectangleData(){
        Vector data = new Vector();
        if(null == lpUserId){
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return null;
        }
        if(ChannelID == 0){
            JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
            return null;
        }
 
        IntByReference dwBytesReturned = new IntByReference();
        stRectangleInfo = new NETDEV_MOTION_DETECTION_AREA_RECTANGLE_INFO_LIST_S();
        boolean bRet = netdevsdk.NETDEV_GetDevConfig(lpUserId, ChannelID, NETDEV_CONFIG_COMMAND_E.NETDEV_GET_MOTION_DETECTION_AREA_RECTANGLE_INFO_LIST, stRectangleInfo.getPointer(),stRectangleInfo.size(),dwBytesReturned);
        if(bRet != true) {
            System.out.printf("NETDEV_GetDevConfig failed:%d\n", netdevsdk.NETDEV_GetLastError());
            return null;
        }
        stRectangleInfo.read();
        for(int i = 0; i <  stRectangleInfo.udwNum; i++){
            Vector<Object> vtData = new Vector<>();
            if(stRectangleInfo.astRectangleAreaInfoList[i].bEnabled == 1) {
                vtData.add(true);
            }else{
                vtData.add(false);
            }
            vtData.add(stRectangleInfo.astRectangleAreaInfoList[i].udwID);
            vtData.add(stRectangleInfo.astRectangleAreaInfoList[i].udwSensitivity);
            vtData.add(stRectangleInfo.astRectangleAreaInfoList[i].udwDuration);
            vtData.add(stRectangleInfo.astRectangleAreaInfoList[i].udwTargetSize);
            vtData.add(stRectangleInfo.astRectangleAreaInfoList[i].stRectAreaInfo.udwTopLeftX);
            vtData.add(stRectangleInfo.astRectangleAreaInfoList[i].stRectAreaInfo.udwTopLeftY);
            vtData.add(stRectangleInfo.astRectangleAreaInfoList[i].stRectAreaInfo.udwBottomRightX);
            vtData.add(stRectangleInfo.astRectangleAreaInfoList[i].stRectAreaInfo.udwBottomRightY);
            data.add(vtData);
        }
        return data;
    }
 
    /**
     *
     * @introduction Get macro block area data
     * @description
     *
     */
    public Vector getGridData(){
        Vector data = new Vector();
        if(null == lpUserId){
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return null;
        }
        if(ChannelID == 0){
            JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
            return null;
        }
 
        IntByReference dwBytesReturned = new IntByReference();
        stGridInfo = new NETDEV_MOTION_DETECTION_AREA_GRID_INFO_S();
        boolean bRet = netdevsdk.NETDEV_GetDevConfig(lpUserId, ChannelID, NETDEV_CONFIG_COMMAND_E.NETDEV_GET_MOTION_DETECTION_AREA_GRID_INFO, stGridInfo. getPointer(),stGridInfo.size(),dwBytesReturned);
        if(bRet != true) {
            System.out.printf("NETDEV_GetDevConfig failed:%d\n", netdevsdk.NETDEV_GetLastError());
            return null;
        }
 
        stGridInfo.read();
        textFieldConfigChannelMotionGridAreaSensitivity.setText(Integer.valueOf(stGridInfo.udwSensitivity).toString());
        if(stGridInfo.bEnabled == 1){
            textFieldConfigChannelMotionGridAreaEnabled.setSelected(true);
        }else{
            textFieldConfigChannelMotionGridAreaEnabled.setSelected(false);
        }
 
        int i=0;
        while(i<NetDEVSDKLib.NETDEV_SCREEN_INFO_ROW){
            Vector vtData = new Vector();
            int j=0;
            while(j<NetDEVSDKLib.NETDEV_SCREEN_INFO_COLUMN){
                if(stGridInfo.awGridInfo[i*NetDEVSDKLib.NETDEV_SCREEN_INFO_COLUMN+j]==1){
                    vtData.add(true);
                }else{
                    vtData.add(false);
                }
                j++;
            }
            data.add(vtData);
            i++;
        }
        return data;
    }
 
    class CheckTableModle extends DefaultTableModel {
        public CheckTableModle(Vector data,Vector columnNames) {
            super(data, columnNames);
        }
 
        // /**
        // * 根据类型返回显示空间
        // * 布尔类型返回显示checkbox
        // */
        public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
        }
 
        public void selectAllOrNull(boolean value) {
            for (int i = 0; i < getRowCount(); i++) {
            this.setValueAt(value, i, 0);
                }
        }
    }
 
    class CheckHeaderCellRenderer implements TableCellRenderer {
        CheckTableModle tableModel;
        JTableHeader tableHeader;
 
        public CheckHeaderCellRenderer(JTable table) {
            this.tableModel = (CheckTableModle)table.getModel();
            this.tableHeader = table.getTableHeader();
            }
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value,
                boolean isSelected, boolean hasFocus, int row, int column) {
            String valueStr = (String) value;
            JLabel label = new JLabel(valueStr);
            label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签居中
            JComponent component = label;
            component.setForeground(tableHeader.getForeground());
            component.setBackground(tableHeader.getBackground());
            component.setFont(tableHeader.getFont());
            component.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
 
            return component;
        }
    }
}