private void getDatas(SearchBean searchBean) { totalNumber = codeDictMapper.getCount(searchBean); if (null != pageTool) { pageTool.setTotalNumber(totalNumber); pageTool.setBounds( new Rectangle(668 - pageTool.getPanelLength(), 455, pageTool.getPanelLength() - 3, 22)); } List<CodeDictBean> codeDictBeanList = codeDictMapper.selectCodeDictsByParams(searchBean); if (CollectionUtils.isNotEmpty(codeDictBeanList)) { rowData.clear(); parent.clear(); Map<String, Object> black = new HashMap<String, Object>(); black.put("label", ""); black.put("value", null); parent.add(black); for (CodeDictBean codeDictBean : codeDictBeanList) { rowData.add(buildVectorData(codeDictBean)); Map<String, Object> item = new HashMap<String, Object>(); item.put("label", codeDictBean.getId() + " - " + codeDictBean.getValue()); item.put("value", codeDictBean.getId()); parent.add(item); } } else { rowData.clear(); } if (table != null) { table.updateTable(); table.getColumnModel().getColumn(4).setCellEditor(new ComboBoxEditor(parent)); table.rows.clear(); } }
public CodeDictFrame() { this.setLayout(null); init(); label = new JLabel("编号:"); label.setFont(new Font("宋体", Font.PLAIN, 13)); label.setBounds(new Rectangle(5, 15, 50, 20)); field = new JTextField(); field.setBounds(new Rectangle(45, 15, 120, 20)); label3 = new JLabel("分类:"); label3.setFont(new Font("宋体", Font.PLAIN, 13)); label3.setBounds(new Rectangle(185, 15, 80, 20)); type = new MyComboBox(str); type.setFont(new Font("宋体", Font.PLAIN, 13)); type.setBounds(new Rectangle(250, 15, 90, 20)); type.setCursor(new Cursor(Cursor.HAND_CURSOR)); search = new JButton("搜索"); search.setCursor(new Cursor(Cursor.HAND_CURSOR)); search.setBounds(new Rectangle(360, 15, 80, 20)); table = new Table(rowData, columns) { /** */ private static final long serialVersionUID = 1L; public boolean isCellEditable(int row, int column) { if (column == 1) { return false; } else { return true; } } }; table.setPreferredScrollableViewportSize(new Dimension(670, 450)); table.isCellEditable(0, 1); // 设置第一列的宽度 table.changeColumnWidth(0, 30); // 设置第二列的宽度 table.changeColumnWidth(1, 150); // 设置第3列的宽度 table.changeColumnWidth(2, 150); // 设置第4列的宽度 table.changeColumnWidth(3, 190); // 设置第5列的宽度 table.changeColumnWidth(4, 150); table.setCellEditor(2, new ComboBoxEditor(str)); table.setCellEditor(4, new ComboBoxEditor(parent)); table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); List<Integer> columns = new ArrayList<Integer>(); columns.add(2); columns.add(4); table.initCombox(columns); table.setOpaque(false); pane3 = new JScrollPane(table); pane3.setOpaque(false); pane3.getViewport().setOpaque(false); pane3.setBounds(new Rectangle(2, 50, 670, 450)); pageTool = new PageToolBar<CodeDictFrame>(this, totalNumber); pageTool.setBounds( new Rectangle(668 - pageTool.getPanelLength(), 455, pageTool.getPanelLength() - 3, 22)); button = new JButton("添加"); button.setBounds(new Rectangle(240, 508, 60, 25)); save = new JButton("保存"); save.setCursor(new Cursor(Cursor.HAND_CURSOR)); save.setBounds(new Rectangle(310, 508, 60, 25)); delete = new JButton("删除"); delete.setCursor(new Cursor(Cursor.HAND_CURSOR)); delete.setBounds(new Rectangle(380, 508, 60, 25)); search.addActionListener(this); button.addActionListener(this); save.addActionListener(this); delete.addActionListener(this); this.add(label); this.add(field); this.add(label3); this.add(type); this.add(search); this.add(pageTool); this.add(pane3); this.add(button); this.add(save); this.add(delete); this.setVisible(false); }