List of usage examples for javax.swing.event TableModelListener TableModelListener
TableModelListener
From source file:table.TablePanel.java
public TablePanel(JPanel parent, GridBagConstraints c) { this.parent = parent; this.c = c;/*ww w. j a v a 2 s . c o m*/ dataHandler = null; data = new ArrayList<>(); selectedRows = new ArrayList<>(); tableModel = new MyTableModel(data); table = new JTable(tableModel); table.getColumnModel().getColumn(0).setResizable(false); table.getColumnModel().getColumn(0).setMaxWidth(60); table.getColumnModel().getColumn(1).setResizable(false); table.getColumnModel().getColumn(1).setMaxWidth(50); table.getColumnModel().getColumn(2).setMaxWidth(90); table.getColumnModel().getColumn(49).setMaxWidth(60); for (int i = 0; i < tableModel.getColumnCount(); i++) { if (i > 14 && i < 31) { table.getColumnModel().getColumn(i).setMaxWidth(70); } else if (tableModel.columnNamesTemp[i].contains("LEVEL")) { if (tableModel.columnNamesTemp[i].equals("QEC LEVEL")) { table.getColumnModel().getColumn(i).setMinWidth(90); table.getColumnModel().getColumn(i).setMaxWidth(200); } else { table.getColumnModel().getColumn(i).setMaxWidth(90); } if (tableModel.columnNamesTemp[i - 1].equals("Work Pace")) { table.getColumnModel().getColumn(i - 1).setMinWidth(90); table.getColumnModel().getColumn(i - 1).setMaxWidth(150); } else { table.getColumnModel().getColumn(i - 1).setMaxWidth(90); } } else { // table.getColumnModel().getColumn(i).setMinWidth(120); // table.getColumnModel().getColumn(i).setMaxWidth(250); } } table.getColumnModel().getColumn(table.getColumnCount() - 1).setMaxWidth(60); table.getColumnModel().getColumn(table.getColumnCount() - 1).setResizable(false); table.setRowSelectionAllowed(true); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (!dataHandler.getDeleting() && (table.getSelectedRow() != -1) && e.getColumn() != table.getColumnCount() - 1 && e.getColumn() != 1) { int row = table.getSelectedRow(); int col = e.getColumn(); if (col == 0 && (boolean) table.getValueAt(row, col) == true) { if (!selectedRows.contains((Integer) row)) selectedRows.add(row); } else if (col == 0 && (boolean) table.getValueAt(row, col) == false) { selectedRows.remove((Object) row); } else if (col != 0 && (boolean) table.getValueAt(row, table.getColumnCount() - 1)) { dataHandler.dataEdited(); } } } }); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { private int count = 0; @Override public void valueChanged(ListSelectionEvent arg0) { if (count > 1 && !arg0.getValueIsAdjusting()) { int[] draggedRows = table.getSelectedRows(); for (int i = 0; i < draggedRows.length; i++) if (selectedRows.contains((Integer) draggedRows[i])) { selectedRows.remove((Integer) draggedRows[i]); table.setValueAt(false, draggedRows[i], 0); } else { selectedRows.add((Integer) draggedRows[i]); table.setValueAt(true, draggedRows[i], 0); } // Finalize count = 0; } else if (arg0.getValueIsAdjusting()) count++; else count = 0; } }); // { // // @Override // public Component prepareRenderer(TableCellRenderer renderer, // int row, int column) { // JLabel label = (JLabel) super.prepareRenderer(renderer, row, column); // if ((boolean) table.getValueAt(row, table.getColumnCount() - 1) == // false) { // if ((int) row % 2 == 0) { // label.setBackground(new Color(244, 226,215)); // } else { // label.setBackground(new Color(241, 220,205)); // } // } else { // if ((int) row% 2 == 0) { // label.setBackground(new Color(255, 255, 255)); // } else { // label.setBackground(new Color(252, 252, 252)); // } // // } // if(table.getSelectedRow()==row) // label.setBackground(Color.LIGHT_GRAY); // return label; // } // }; // table.prepareRenderer(null, WIDTH, WIDTH); // table.setRowSelectionAllowed(true); // table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setDefaultRenderer(Object.class, new MyTableCellRenderer()); // { // // @Override // public Component getTableCellRendererComponent(JTable table, Object // value, boolean isSelected, boolean hasFocus, int row, int column) { // JLabel label = (JLabel) table.prepareRenderer(null, row, column); // if ((boolean) table.getValueAt(row, table.getColumnCount() - 1) == // false) { // if ((int) row % 2 == 0) { // label.setBackground(new Color(244, 226,215)); // } else { // label.setBackground(new Color(241, 220,205)); // } // } else { // if ((int) row% 2 == 0) { // label.setBackground(new Color(255, 255, 255)); // } else { // label.setBackground(new Color(252, 252, 252)); // } // // } // if(table.getSelectedRow()==row) // label.setBackground(Color.LIGHT_GRAY); // return label; // } // }); // { // // @Override // public Component getTableCellRendererComponent(JTable table, Object // value, boolean isSelected, boolean hasFocus, int row, int column) { // Component cell= table.getCellRenderer(row, // column).getTableCellRendererComponent(table, value, isSelected, // hasFocus, row, column); // // // for(int i=1;i<table.getRowCount();i++) { // if((boolean)table.getValueAt(i, table.getColumnCount()-1) ==false) // { // setForeground(Color.black); // setBackground(Color.red); // } // else // { // setBackground(Color.white); // setForeground(Color.black); // } // } // return cell; // } // }); // DefaultTableCellRenderer rightRenderer = new // DefaultTableCellRenderer(); // rightRenderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT); for (int i = 0; i < tableModel.getColumnCount(); i++) { table.getTableHeader().getColumnModel().getColumn(i) .setHeaderRenderer(new HeaderRenderer(table, alignments[1])); // table.getColumnModel().getColumn(i).setCellRenderer(new // MyTableCellRenderer()); } table.getTableHeader().setReorderingAllowed(false); table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); table.setRowHeight(25); // table.setPreferredScrollableViewportSize(new Dimension(10000, 200)); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); // JViewport tableView = new JViewport(); // tableView.add(table); // scrollPane.setViewport(tableView); parent.setSize(table.getWidth(), table.getHeight()); // parent.setPreferredSize(new Dimension(70000,10000)); // scrollPane.setVerticalScrollBar(new JScrollBar(JScrollBar.VERTICAL)); // scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL)); // Add the scroll pane to this panel. // parent.add(table.getTableHeader()); // parent.add(table, c); // Add header in NORTH slot parent.add(table.getTableHeader(), BorderLayout.NORTH); // Add table itself to CENTER slot parent.add(table, BorderLayout.CENTER); }
From source file:gui.accessories.BattleSimFx.java
private BarChart createBarChart() { CategoryAxis xAxis = new CategoryAxis(); xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames())); xAxis.setLabel("Year"); double tickUnit = tableModel.getTickUnit(); NumberAxis yAxis = new NumberAxis(); yAxis.setTickUnit(tickUnit);//from www . j a va 2 s . c o m yAxis.setLabel("Units Sold"); final BarChart aChart = new BarChart(xAxis, yAxis, tableModel.getBarChartData()); tableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (e.getType() == TableModelEvent.UPDATE) { final int row = e.getFirstRow(); final int column = e.getColumn(); final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column); Platform.runLater(new Runnable() { @Override public void run() { XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) aChart.getData() .get(row); BarChart.Data data = s.getData().get(column); data.setYValue(value); } }); } } }); return aChart; }
From source file:com.att.aro.ui.view.menu.file.BPVideoWarnFailPanel.java
private JTable getTable() { if (table == null) { model = new VideoPreferenceTableModel(loadPrefs()); table = new JTable(model); table.setGridColor(Color.LIGHT_GRAY); table.setFocusable(false);//from www. j ava2s .c om table.setRowSelectionAllowed(false); table.setShowGrid(true); table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12)); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); table.getColumnModel().getColumn(0).setPreferredWidth(225); table.getColumnModel().getColumn(1).setPreferredWidth(50); table.getColumnModel().getColumn(2).setPreferredWidth(50); table.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { sError = model.getValidationError(); if (!sError.toString().isEmpty()) { compileResultsField.setVisible(true); compileResultsField.setForeground(Color.red); compileResultsField.setText(String.format("ERROR : %s", sError.toString())); } else { compileResultsField.setText(""); compileResultsField.setVisible(false); } } }); } else { model.setData(loadPrefs()); table.setModel(model); } return table; }
From source file:com.clank.launcher.dialog.LauncherFrame.java
private void initComponents() { webView = WebpagePanel.forURL(launcher.getNewsURL(), false); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, instanceScroll, webView); selfUpdateButton.setVisible(false);/* w w w.j a v a2s . co m*/ updateCheck.setSelected(true); instancesTable.setModel(instancesModel); launchButton.setFont(launchButton.getFont().deriveFont(Font.BOLD)); splitPane.setDividerLocation(200); splitPane.setDividerSize(4); SwingHelper.flattenJSplitPane(splitPane); buttonsPanel.addElement(refreshButton); buttonsPanel.addElement(updateCheck); buttonsPanel.addGlue(); buttonsPanel.addElement(selfUpdateButton); buttonsPanel.addElement(optionsButton); buttonsPanel.addElement(launchButton); container.setLayout(new BorderLayout()); container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); container.add(splitPane, BorderLayout.CENTER); add(buttonsPanel, BorderLayout.SOUTH); add(container, BorderLayout.CENTER); instancesModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (instancesTable.getRowCount() > 0) { instancesTable.setRowSelectionInterval(0, 0); } } }); instancesTable.addMouseListener(new DoubleClickToButtonAdapter(launchButton)); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadInstances(); checkLauncherUpdate(); } }); selfUpdateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selfUpdate(); } }); optionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showOptions(); } }); launchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { launch(); } }); instancesTable.addMouseListener(new PopupMouseAdapter() { @Override protected void showPopup(MouseEvent e) { int index = instancesTable.rowAtPoint(e.getPoint()); Instance selected = null; if (index >= 0) { instancesTable.setRowSelectionInterval(index, index); selected = launcher.getInstances().get(index); } popupInstanceMenu(e.getComponent(), e.getX(), e.getY(), selected); } }); }
From source file:com.stanley.captioner.MainFrame.java
private void initListeners() { videoTable.getModel().addTableModelListener(new TableModelListener() { @Override//from w ww . j a v a 2 s . c o m public void tableChanged(TableModelEvent e) { if (e.getType() == TableModelEvent.INSERT || e.getType() == TableModelEvent.DELETE) { if (videoTable.getRowCount() > 0) { clearButton.setEnabled(true); if (outputDirectoryField.getText() != null && outputDirectoryField.getText().length() > 0) { convertButton.setEnabled(true); } else { convertButton.setEnabled(false); } } else { clearButton.setEnabled(false); convertButton.setEnabled(false); } } } }); videoTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (videoTable.getSelectedRowCount() > 0) { removeButton.setEnabled(true); } else { removeButton.setEnabled(false); } } }); }
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateLibrariesPanel.java
public void initialize() { PlatformUI.MIRTH_FRAME.codeTemplatePanel.doRefreshCodeTemplates(new ActionListener() { @Override/*from w ww. ja v a2s .c o m*/ public void actionPerformed(ActionEvent evt) { for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel .getCachedCodeTemplateLibraries().values()) { libraryMap.put(library.getId(), new CodeTemplateLibrary(library)); } Map<String, CodeTemplate> codeTemplateMap = PlatformUI.MIRTH_FRAME.codeTemplatePanel .getCachedCodeTemplates(); DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(); for (CodeTemplateLibrary library : libraryMap.values()) { boolean enabled = library.getEnabledChannelIds().contains(channelId) || (library.isIncludeNewChannels() && !library.getDisabledChannelIds().contains(channelId)); DefaultMutableTreeTableNode libraryNode = new DefaultMutableTreeTableNode( new ImmutableTriple<String, String, Boolean>(library.getId(), library.getName(), enabled)); for (CodeTemplate codeTemplate : library.getCodeTemplates()) { codeTemplate = codeTemplateMap.get(codeTemplate.getId()); if (codeTemplate != null) { libraryNode.add( new DefaultMutableTreeTableNode(new ImmutableTriple<String, String, Boolean>( codeTemplate.getId(), codeTemplate.getName(), enabled))); } } rootNode.add(libraryNode); } ((DefaultTreeTableModel) libraryTreeTable.getTreeTableModel()).setRoot(rootNode); libraryTreeTable.expandAll(); libraryTreeTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent evt) { for (Enumeration<? extends MutableTreeTableNode> libraryNodes = ((DefaultMutableTreeTableNode) libraryTreeTable .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) { Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) libraryNodes .nextElement().getUserObject(); CodeTemplateLibrary library = libraryMap.get(triple.getLeft()); if (triple.getRight()) { library.getDisabledChannelIds().remove(channelId); library.getEnabledChannelIds().add(channelId); } else { library.getDisabledChannelIds().add(channelId); library.getEnabledChannelIds().remove(channelId); } } } }); parent.codeTemplateLibrariesReady(); } }); }
From source file:edu.ku.brc.specify.config.init.TreeDefSetupPanel.java
/** * @param classType the class of the TreeDef * @param classTitle the already localized title of the actual tree * @param panelName the name of the panel * @param descKey L10N key to label description above the table * @param nextBtn the next button/* ww w . ja v a 2 s . c o m*/ * @param dbPanel the */ public TreeDefSetupPanel(final Class<?> classType, final String classTitle, final String panelName, final String helpContext, final String descKey, final JButton nextBtn, final JButton prevBtn, final DisciplinePanel disciplinePanel) { super(panelName, helpContext, nextBtn, prevBtn); this.classType = classType; this.classTitle = classTitle; this.disciplinePanel = disciplinePanel; if (classType == TaxonTreeDef.class || classType == GeographyTreeDef.class || classType == StorageTreeDef.class) { model = new TreeDefTableModel(); if (classType != TaxonTreeDef.class) { loadTree(disciplinePanel != null && disciplinePanel.getDisciplineType() != null ? disciplinePanel.getDisciplineType().getDisciplineType() : null); } table = new JTable(model); directionCBX = UIHelper .createComboBox(new String[] { getResourceString("FORWARD"), getResourceString("REVERSE") }); fullnameDisplayTxt = new JEditorPane(); fullnameDisplayTxt.setBackground(Color.WHITE); fullnameDisplayTxt.setOpaque(true); fullnameDisplayTxt.setContentType("text/html"); fullnameDisplayTxt.setEditable(false); table.setRowSelectionAllowed(false); table.setColumnSelectionAllowed(false); //table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false)); model.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateBtnUI(); } }); JScrollPane spex = new JScrollPane(fullnameDisplayTxt, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder( new FormLayout("p,2px,p,250px,f:p:g", "p,4px,min(p;250px),4px,p,4px,65px,2px,p"), this); JScrollPane sp = createScrollPane(table); sp.getViewport().setBackground(Color.WHITE); String lbl = getLocalizedMessage(descKey, classTitle); pb.add(createLabel(lbl, SwingConstants.CENTER), cc.xyw(1, 1, 4)); pb.add(sp, cc.xyw(1, 3, 5)); pb.add(createI18NFormLabel("DIRECTION"), cc.xy(1, 5)); pb.add(directionCBX, cc.xy(3, 5)); pb.add(createI18NFormLabel("EXAMPLE"), cc.xy(1, 7)); pb.add(spex, cc.xywh(3, 7, 2, 3)); makeTableHeadersCentered(table, true); directionCBX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateBtnUI(); } }); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateBtnUI(); int inx = table.getSelectedColumn(); if (inx > -1) { TreeDefRow row = treeDefList.get(table.getSelectedRow()); String msgKey = null; if (row.isRequired() && (inx == 1 || inx == 3)) { msgKey = inx == 1 ? "NO_CHANGE_INCL" : "NO_CHANGE_REQ"; } else if (inx == 4 && !row.isIncluded()) { msgKey = "NO_CHANGE_INFN"; } if (msgKey != null) { final String mk = msgKey; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { showLocalizedMsg(mk); } }); } } } } }); updateBtnUI(); } }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatMultiplePanel.java
/** * @param model/* w w w . java 2 s. c o m*/ */ protected void addTableModelListener(DefaultTableModel model) { TableModelListener tml = new TableModelListener() { public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); DefaultTableModel localModel = (DefaultTableModel) e.getSource(); String columnName = localModel.getColumnName(column); if (columnName.equals(FIELD_VALUE_COL)) { int formatColumn = formatSwitchTbl.getColumnModel().getColumnIndex(DISPLAY_FORMAT_COL); DataObjDataFieldFormat format = (DataObjDataFieldFormat) localModel.getValueAt(row, formatColumn); String value = (String) localModel.getValueAt(row, column); format.setValue(value); enableUIControls(); } } }; model.addTableModelListener(tml); }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.SequencingClasses.GUIComponents.XYSequencing.java
private void setControlDefaults() { pmdp_ = new PlateMapDrawPanel(this); sap_ = SeqAcqProps.getInstance();//from ww w. j av a 2s . c om plateMapBasePanel.setLayout(new BorderLayout()); plateMapBasePanel.add(pmdp_, BorderLayout.CENTER); tableModel_ = new FOVTableModel(pp_); searchFOVtableModel_ = new FOVTableModel(pp_); //Not sure if this is the best way, but try it for now. tableModel_.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { } }); fovTable_ = new JTable(); fovTable_.setModel(tableModel_); fovTable_.setSurrendersFocusOnKeystroke(true); fovTable_.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); JScrollPane scroller = new javax.swing.JScrollPane(fovTable_); fovTable_.setPreferredScrollableViewportSize(new java.awt.Dimension(190, 130)); fovTablePanel.setLayout(new BorderLayout()); fovTablePanel.add(scroller, BorderLayout.CENTER); final JPopupMenu popupMenu = new JPopupMenu(); JMenuItem deleteItem = new JMenuItem("Delete FOV"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fovTable_.getSelectedRow(); tableModel_.removeRow(r); } }); JMenuItem addItem = new JMenuItem("Add FOV"); addItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fovTable_.getSelectedRow(); tableModel_.insertRow(r, new FOV("A1", pp_, 6000)); } }); JMenuItem goToFOVItem = new JMenuItem("Go to FOV"); goToFOVItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fovTable_.getSelectedRow(); // FOV fov = tableModel_.getData().get(r); xyzmi_.gotoFOV(tableModel_.getData().get(r)); if (!zAsOffset_) { double zval = tableModel_.getData().get(r).getZ(); xyzmi_.moveZAbsolute(zval); } else { // obviously, this isn't quite right - we want to get // the offset of the CURRENT FOV (perhaps from parent in // later implementations?) and subtract from that of the // NEWLY SELECTED FOV. // TODO: fix for proper zAsOffset behaviour. // Wait for move completion while (xyzmi_.isStageBusy()) { System.out.println("Stage moving..."); } ; if (parent_.checkifAFenabled()) { // If we have gone to the FOV, and have AF, do AF xyzmi_.customAutofocus(parent_.getAFOffset()); } else { // If we don't have AF, go to the 'good offset position' xyzmi_.moveZAbsolute(parent_.getFixedAFDefault()); } //Now do the relative shift xyzmi_.moveZRelative(tableModel_.getData().get(r).getZ()); System.out.println("Z value" + tableModel_.getData().get(r).getZ()); } } }); popupMenu.add(addItem); popupMenu.add(deleteItem); popupMenu.add(goToFOVItem); fovTable_.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { // System.out.println("pressed"); } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { JTable source = (JTable) e.getSource(); int row = source.rowAtPoint(e.getPoint()); int column = source.columnAtPoint(e.getPoint()); if (!source.isRowSelected(row)) { source.changeSelection(row, column, false, false); } popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); // fovTable_.setDefaultRenderer(FOV.class, new TableRenderer()); setupInsertComboBox(); }
From source file:com.jskj.asset.client.panel.slgl.GuDingZiChanLingYongTuiKuJDialog.java
/** * Creates new form GuDingZiChanRuKu// w ww. jav a2s . c o m */ public GuDingZiChanLingYongTuiKuJDialog() { super(); initComponents(); zc = new ArrayList<ZiChanLieBiaotb>(); userId = AssetClientApp.getSessionMap().getUsertb().getUserId(); userName = AssetClientApp.getSessionMap().getUsertb().getUserName(); department = AssetClientApp.getSessionMap().getDepartment().getDepartmentName(); kucunmap = new HashMap(); jTextFieldShenqingren.setText(userName); jTextFieldDept.setText(department); jTextField1.setText(DanHao.getDanHao("ZCTK")); jTextField1.setEditable(false); jTextField2.setText(dateformate.format(new Date()).toString()); jTextField2.setEditable(false); final BaseTable.SingleEditRowTable editTable = ((BaseTable) jTable1).createSingleEditModel(new String[][] { { "gdzcId", "?" }, { "gdzcName", "??", "true" }, { "gdzcType", "" }, { "gdzcPinpai", "?", "false" }, { "gdzcXinghao", "?" }, { "unitId", "??", "false" }, { "kucun.price", "", "false" }, { "lylb.barcode", "??", "false" } }); editTable.registerPopup(1, new IPopupBuilder() { @Override public int getType() { return IPopupBuilder.TYPE_POPUP_TABLE; } @Override public String getWebServiceURI() { return Constants.HTTP + Constants.APPID + "tkgdzc"; } @Override public String getConditionSQL() { int selectedColumn = jTable1.getSelectedColumn(); int selectedRow = jTable1.getSelectedRow(); Object newColumnObj = jTable1.getValueAt(selectedRow, selectedColumn); String sql = ""; if (newColumnObj instanceof String && !newColumnObj.toString().trim().equals("")) { sql = "(gdzc_name like \"%" + newColumnObj.toString() + "%\"" + " or zujima like \"%" + newColumnObj.toString().toLowerCase() + "%\")"; } return sql; } @Override public String[][] displayColumns() { return new String[][] { { "gdzcId", "ID" }, { "gdzcName", "??" }, { "lylb.barcode", "??" } }; } @Override public void setBindedMap(HashMap bindedMap) { if (bindedMap != null) { Object gdzcId = bindedMap.get("gdzcId"); Object gdzcName = bindedMap.get("gdzcName"); Object gdzcType = bindedMap.get("gdzcType"); Object gdzcPinpai = bindedMap.get("gdzcPinpai"); // Object gdzcValue = bindedMap.get("gdzcValue"); Object gdzcXinghao = bindedMap.get("gdzcXinghao"); Object gdzcDanwei = bindedMap.get("unitId"); editTable.insertValue(0, gdzcId); editTable.insertValue(1, gdzcName); editTable.insertValue(2, gdzcType); editTable.insertValue(3, gdzcPinpai); editTable.insertValue(4, gdzcXinghao); editTable.insertValue(5, gdzcDanwei); HashMap map = (HashMap) bindedMap.get("kucun"); saleprice = Float.parseFloat(map.get("price").toString()); editTable.insertValue(6, saleprice); map = (HashMap) bindedMap.get("lylb"); pihao = (String) map.get("barcode"); editTable.insertValue(7, pihao); Object lycount = bindedMap.get("count"); // ZiChanLieBiaotb zclb = new ZiChanLieBiaotb(); // zclb.setCgsqId(jTextField1.getText()); // zclb.setCgzcId((Integer)gdzcId); // zclb.setQuantity(0); // zc.add(zclb); //??? kucunmap.put(gdzcId + pihao, lycount); } } }); jTable1.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { int rows = jTable1.getRowCount(); total = 0; for (int i = 0; i < rows; i++) { if (!(("" + jTable1.getValueAt(i, 6)).equals(""))) { total += Float.parseFloat("" + jTable1.getValueAt(i, 6)); } } totalprice.setText(total + ""); } }); }