private void btnDeleteControlActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteControlActionPerformed
   int selectedRow = appVisualControlsTable.getSelectedRow();
   int selectedColumn = appVisualControlsTable.getSelectedColumn();
   appVisualControlsTable.clearSelection();
   appVisualControlsTable.getModel().setValueAt(null, selectedRow, selectedColumn);
 } // GEN-LAST:event_btnDeleteControlActionPerformed
Example #2
0
 public void setEnabled(boolean arg0) {
   table.setEnabled(arg0);
   table.clearSelection();
   add.setEnabled(arg0);
   edit.setEnabled(false);
   remove.setEnabled(false);
 }
Example #3
0
 private void filterUsers(final String fragment) {
   table.clearSelection();
   userCertificatePanel.setUserCertificateModel(null);
   if (StringUtils.isEmpty(fragment)) {
     table.setRowSorter(defaultSorter);
     return;
   }
   RowFilter<UserCertificateTableModel, Object> containsFilter =
       new RowFilter<UserCertificateTableModel, Object>() {
         @Override
         public boolean include(
             Entry<? extends UserCertificateTableModel, ? extends Object> entry) {
           for (int i = entry.getValueCount() - 1; i >= 0; i--) {
             if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
               return true;
             }
           }
           return false;
         }
       };
   TableRowSorter<UserCertificateTableModel> sorter =
       new TableRowSorter<UserCertificateTableModel>(tableModel);
   sorter.setRowFilter(containsFilter);
   table.setRowSorter(sorter);
 }
Example #4
0
  private void selectInAllMethods(JipMethod selectedMethod) {

    if (selectedMethod == null) {
      mMethods.clearSelection();
      return;
    }

    // which row should we select?
    boolean foundIt = false;
    int nRow = mAllMethodsModel.getRowCount();
    int iRow;
    for (iRow = 0; iRow < nRow; iRow++) {
      MethodRow scan = mAllMethodsModel.getRow(iRow);
      if (scan.getMethod().equals(selectedMethod)) {
        foundIt = true;
        break;
      }
    }
    if (!foundIt) {
      System.out.println("couldn't find " + selectedMethod.getName());
      return;
    }

    // update the listSelectionModel
    int iRowInView = mAllMethodsSorterModel.viewIndex(iRow);
    mMethods.getSelectionModel().setSelectionInterval(iRowInView, iRowInView);

    // scroll to contain the new selection
    Rectangle selectionRect = mMethods.getCellRect(iRowInView, 0, true);
    mMethods.scrollRectToVisible(selectionRect);
  }
 /** Creates and displays the main GUI This GUI has the list and the main * buttons */
 public void showGUI() {
   final JScrollPane scrollPane = new JScrollPane();
   table =
       new JTable(
           new DefaultTableModel(
               new Object[][] {}, new String[] {"Username", "Password", "Pin", "Reward"}));
   AccountManager.loadAccounts();
   if (AccountManager.hasAccounts()) {
     for (Account account : AccountManager.getAccounts()) {
       ((DefaultTableModel) table.getModel())
           .addRow(
               new Object[] {
                 account.getUsername(), account.getReward(), account.getPin(), account.getReward()
               });
     }
   }
   final JToolBar bar = new JToolBar();
   bar.setMargin(new Insets(1, 1, 1, 1));
   bar.setFloatable(false);
   removeButton = new JButton("Remove");
   final JButton newButton = new JButton("Add");
   final JButton doneButton = new JButton("Save");
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   table.getSelectionModel().addListSelectionListener(new TableSelectionListener());
   table.setShowGrid(true);
   final TableColumnModel cm = table.getColumnModel();
   cm.getColumn(cm.getColumnIndex("Password")).setCellRenderer(new PasswordCellRenderer());
   cm.getColumn(cm.getColumnIndex("Password")).setCellEditor(new PasswordCellEditor());
   cm.getColumn(cm.getColumnIndex("Pin")).setCellRenderer(new PasswordCellRenderer());
   cm.getColumn(cm.getColumnIndex("Pin")).setCellEditor(new PasswordCellEditor());
   cm.getColumn(cm.getColumnIndex("Reward")).setCellEditor(new RandomRewardEditor());
   scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   scrollPane.setViewportView(table);
   add(scrollPane, BorderLayout.CENTER);
   newButton.setFocusable(false);
   newButton.setToolTipText(newButton.getText());
   newButton.setText("+");
   bar.add(newButton);
   removeButton.setFocusable(false);
   removeButton.setToolTipText(removeButton.getText());
   removeButton.setText("-");
   bar.add(removeButton);
   bar.add(Box.createHorizontalGlue());
   doneButton.setToolTipText(doneButton.getText());
   bar.add(doneButton);
   newButton.addActionListener(this);
   removeButton.addActionListener(this);
   doneButton.addActionListener(this);
   add(bar, BorderLayout.SOUTH);
   final int row = table.getSelectedRow();
   removeButton.setEnabled(row >= 0 && row < table.getRowCount());
   table.clearSelection();
   doneButton.requestFocus();
   setPreferredSize(new Dimension(600, 300));
   pack();
   setLocationRelativeTo(getOwner());
   setResizable(false);
 }
 /**
  * Selects the result with the given index in the results list.
  *
  * @param index the index of the result to select
  */
 public void setSelectedResult(int index) {
   if (index < 0 || index > bgResultsTable.getRowCount() - 1) {
     bgResultsTable.clearSelection();
   } else {
     bgResultsTable.setRowSelectionInterval(index, index);
     int colCount = bgResultsTable.getColumnCount();
     bgResultsTable.setColumnSelectionInterval(0, colCount - 1);
   }
 }
 @Override
 public void setEnabled(boolean enabled) {
   super.setEnabled(enabled);
   _table.setEnabled(enabled);
   if (!enabled) {
     _table.clearSelection();
     _table.editingCanceled(new ChangeEvent(_table));
   }
 }
 public void LimpaCampos() { // seta tudo para limpar os campos
   txtBairro.setText(null);
   txtCidade.setText(null);
   txtCod.setText(null);
   txtNome.setText(null);
   txtRua.setText(null);
   txtTelefone.setText(null);
   tabelaProduto.clearSelection();
 }
Example #9
0
  /**
   * Runs search within table
   *
   * @return Returns true if found
   */
  private boolean runSearch() {

    ListSelectionModel lsm = table.getSelectionModel();
    foundRowIndices = new Vector();
    boolean selectAll = this.selectAllButton.isSelected();
    boolean found = false;

    searchStr = (String) this.jComboBox1.getSelectedItem();
    if (searchStr == null || numSearchCols == 0 || searchStr.equals("")) return found;

    table.clearSelection();
    this.jComboBox1.insertItemAt(searchStr, 0);

    if (this.matchCaseChkBox.isSelected()) {
      for (int row = 0; row < numRows; row++) {

        for (int col = (numClasses + 2); col < numCols; col++) {
          if (((String) table.getValueAt(row, col)).indexOf(searchStr) != -1) {
            // select row;
            if (selectAll || !found) {
              table.addRowSelectionInterval(row, row);
              // first occurance
              if (!found) {
                table.scrollRectToVisible(table.getCellRect(row, 0, true));
                found = true;
              }
            } else foundRowIndices.add(new Integer(row));
            break;
          }
        }
      }
    } else {

      String upperCaseStr = searchStr.toUpperCase();

      for (int row = 0; row < numRows; row++) {

        for (int col = (numClasses + 2); col < numCols; col++) {
          if ((((String) table.getValueAt(row, col)).toUpperCase()).indexOf(upperCaseStr) != -1) {
            // select row;
            if (selectAll || !found) {
              table.addRowSelectionInterval(row, row);
              // first occurance
              if (!found) {
                table.scrollRectToVisible(table.getCellRect(row, 0, true));
                found = true;
              }
            } else foundRowIndices.add(new Integer(row));
            break;
          }
        }
      }
    }

    return found;
  }
Example #10
0
  /** Selects next row in table */
  public void findNext() {

    if (foundRowIndices.isEmpty()) return;

    int row = ((Integer) foundRowIndices.remove(0)).intValue(); // take off first element
    table.clearSelection();
    table.addRowSelectionInterval(row, row);
    table.scrollRectToVisible(table.getCellRect(row, 0, true));
    if (foundRowIndices.size() == 0) findNextButton.setEnabled(false);
  }
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the remove button
   if (e.getSource() == remove_button) {
     int row = table.getSelectedRow();
     model.removeRow(row);
     table.clearSelection();
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the remove all button
   if (e.getSource() == remove_all_button) {
     model.clearAll();
     table.setRowSelectionInterval(0, 0);
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the filter button
   if (e.getSource() == filter_button) {
     filter.showDialog();
     if (filter.okPressed()) {
       // Update the display with new filter
       model.setFilter(filter);
       table.repaint();
     }
   }
   // Check if the user pressed the start button
   if (e.getSource() == start_button) {
     start();
   }
   // Check if the user pressed the stop button
   if (e.getSource() == stop_button) {
     stop();
   }
   // Check if the user wants to switch layout
   if (e.getSource() == layout_button) {
     details_panel.remove(details_soap);
     details_soap.removeAll();
     if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
       details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
     } else {
       details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     }
     details_soap.setTopComponent(request_panel);
     details_soap.setRightComponent(response_panel);
     details_soap.setResizeWeight(.5);
     details_panel.add(details_soap, BorderLayout.CENTER);
     details_panel.validate();
     details_panel.repaint();
   }
   // Check if the user is changing the reflow option
   if (e.getSource() == reflow_xml) {
     request_text.setReflowXML(reflow_xml.isSelected());
     response_text.setReflowXML(reflow_xml.isSelected());
   }
 }
Example #12
0
 public static void main(String[] args) {
   /*
   构造函数有很多下面先介绍几个:
   JTable()
   JTable(int numRows, int numColumns)
   JTable(Object[][] rowData, Object[] columnNames)
   */
   JTable example1 = new JTable(); // 看不到但存在
   JTable example2 = new JTable(8, 6);
   final Object[] columnNames = {
     "姓名", "性别", "家庭地址", // 列名最好用final修饰
     "电话号码", "生日", "工作", "收入", "婚姻状况", "恋爱状况"
   };
   Object[][] rowData = {
     {"ddd", "男", "江苏南京", "1378313210", "03/24/1985", "学生", "寄生中", "未婚", "没"},
     {"eee", "女", "江苏南京", "13645181705", "xx/xx/1985", "家教", "未知", "未婚", "好象没"},
     {"fff", "男", "江苏南京", "13585331486", "12/08/1985", "汽车推销员", "不确定", "未婚", "有"},
     {"ggg", "女", "江苏南京", "81513779", "xx/xx/1986", "宾馆服务员", "确定但未知", "未婚", "有"},
     {"hhh", "男", "江苏南京", "13651545936", "xx/xx/1985", "学生", "流放中", "未婚", "无数次分手后没有"}
   };
   JTable friends = new JTable(rowData, columnNames);
   friends.setPreferredScrollableViewportSize(new Dimension(600, 100)); // 设置表格的大小
   friends.setRowHeight(30); // 设置每行的高度为20
   friends.setRowHeight(0, 20); // 设置第1行的高度为15
   friends.setRowMargin(5); // 设置相邻两行单元格的距离
   friends.setRowSelectionAllowed(true); // 设置可否被选择.默认为false
   friends.setSelectionBackground(Color.white); // 设置所选择行的背景色
   friends.setSelectionForeground(Color.red); // 设置所选择行的前景色
   friends.setGridColor(Color.black); // 设置网格线的颜色
   friends.selectAll(); // 选择所有行
   friends.setRowSelectionInterval(0, 2); // 设置初始的选择行,这里是1到3行都处于选择状态
   friends.clearSelection(); // 取消选择
   friends.setDragEnabled(false); // 不懂这个
   friends.setShowGrid(false); // 是否显示网格线
   friends.setShowHorizontalLines(false); // 是否显示水平的网格线
   friends.setShowVerticalLines(true); // 是否显示垂直的网格线
   friends.setValueAt("tt", 0, 0); // 设置某个单元格的值,这个值是一个对象
   friends.doLayout();
   friends.setBackground(Color.lightGray);
   JScrollPane pane1 = new JScrollPane(example1); // JTable最好加在JScrollPane上
   JScrollPane pane2 = new JScrollPane(example2);
   JScrollPane pane3 = new JScrollPane(friends);
   JPanel panel = new JPanel(new GridLayout(0, 1));
   panel.setPreferredSize(new Dimension(600, 400));
   panel.setBackground(Color.black);
   panel.add(pane1);
   panel.add(pane2);
   panel.add(pane3);
   JFrame frame = new JFrame("JTableDemo");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setContentPane(panel);
   frame.pack();
   frame.show();
 }
Example #13
0
  /**
   * Refresh current selection.
   *
   * <p>This method ensures listeners are invoked just once.
   *
   * @param <Q> the type of the rows.
   * @param table the table.
   * @see #changeSelection(JTable, List, Boolean)
   */
  public static <Q> void refreshSelection(final JTable table) {

    Assert.notNull(table, "table");

    final List<Integer> selectedViewIndexes = TableUtils.getSelectedViewIndexes(table);

    // (JAF), 20110116, clear selection before turning on valueIsAdjusting, otherwise listeners may
    // not be notified
    table.clearSelection();

    TableUtils.changeSelection(table, selectedViewIndexes, Boolean.TRUE);
  }
 public void setSwingFocus(ICFLibAnyObj value) {
   final String S_ProcName = "setSwingFocus";
   if ((value == null) || (value instanceof ICFSecurityISOCountryObj)) {
     super.setSwingFocus(value);
   } else {
     throw CFLib.getDefaultExceptionFactory()
         .newUnsupportedClassException(
             getClass(), S_ProcName, "value", value, "ICFSecurityISOCountryObj");
   }
   if (dataTable == null) {
     return;
   }
   if (value == null) {
     dataTable.clearSelection();
   } else {
     ICFInternetISOCountryObj curSelected;
     PickerTableModel tblDataModel = getDataModel();
     int selectedRow = dataTable.getSelectedRow();
     int modelIndex = dataTable.convertRowIndexToModel(selectedRow);
     if (selectedRow >= 0) {
       Object selectedRowData = tblDataModel.getValueAt(modelIndex, COLID_ROW_HEADER);
       curSelected = (ICFInternetISOCountryObj) selectedRowData;
     } else {
       curSelected = null;
     }
     if (curSelected != value) {
       int len = tblDataModel.getRowCount();
       int idx = 0;
       while ((idx < len) && (tblDataModel.getValueAt(idx, COLID_ROW_HEADER) != value)) {
         idx++;
       }
       if (idx < len) {
         int viewRow = dataTable.convertRowIndexToView(idx);
         dataTable.clearSelection();
         dataTable.addRowSelectionInterval(viewRow, viewRow);
       }
     }
   }
 }
Example #15
0
 public void updateTreeAndLabels() {
   ImagePlus imp = WindowManager.getCurrentImage();
   if (imp == null) return;
   Reader reader = ServiceMediator.getReader();
   reader.updateMetadata(imp);
   if (imp.getOriginalFileInfo() instanceof LSMFileInfo) {
     lsm = (LSMFileInfo) imp.getOriginalFileInfo();
     setTitle(title + " - " + lsm.fileName);
     detailsTree.clearSelection();
     table.clearSelection();
     collapseAll();
     if (filterCBItem.isSelected()) updateFilteredTree(true);
     else updateFilteredTree(false);
   }
 }
Example #16
0
 public void actionPerformed(ActionEvent ae) {
   Object src = ae.getSource();
   replaceTable.clearSelection();
   if (replaceTable.isEditing()) replaceTable.getCellEditor().stopCellEditing();
   if (src instanceof JComponent) {
     ((JComponent) src).requestFocusInWindow();
   }
   if (src == btEval) {
     if (apply(btEval.getActionCommand())) setVisible(false);
   } else if (src == btSub) {
     if (apply(btSub.getActionCommand())) setVisible(false);
   } else if (src == btNumeric) {
     if (apply(btNumeric.getActionCommand())) setVisible(false);
   }
 }
Example #17
0
 protected void moveTableViewToSelected() {
   if (re == null) {
     return;
   }
   // Remove the listener as this change will re-activate it and we end up in a loop!
   dataTable.getSelectionModel().removeListSelectionListener(tableSelectionListener);
   dataTable.clearSelection();
   int entires = dataTable.getRowCount();
   for (int i = 0; i < entires; i++) {
     if (dataTable.getValueAt(i, RosterTableModel.IDCOL).equals(re.getId())) {
       dataTable.addRowSelectionInterval(i, i);
       dataTable.scrollRectToVisible(new Rectangle(dataTable.getCellRect(i, 0, true)));
     }
   }
   dataTable.getSelectionModel().addListSelectionListener(tableSelectionListener);
 }
Example #18
0
  /**
   * Called whenever the value of the selection changes.
   *
   * @param e the event that characterizes the change.
   */
  @Override
  public void valueChanged(final ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) {
      return;
    } // ignore extra messages

    if (e.getSource() == table.getSelectionModel()) {
      int i = table.getSelectedRow();
      if (i >= 0) {
        Wrapper w = model.getWrapperAt(i);
        w.print = !w.print;
        model.fireTableRowsUpdated(i, i);
        table.clearSelection();
      }
    }
  }
 private void listSelectionChaged(ListSelectionEvent e) {
   dlmInc.clear();
   if (tblPackages.getSelectedRow() == -1) {
     // dlmInc.removeRange(0, dlmInc.size() - 1);
     return;
   }
   if (tblPackages.getSelectedRow() == -1) {
     setButtonState(false);
     tblPackages.clearSelection();
     return;
   }
   setButtonState(true);
   String sql1 =
       "SELECT ps.ProductSupplierId, pro.ProductId, ProdName, sup.SupplierId, SupName "
           + " FROM Packages pkg, Packages_Products_Suppliers pps, Products_Suppliers ps, Products pro, Suppliers sup "
           + " WHERE pkg.PackageId = pps.PackageId "
           + " AND pps.ProductSupplierId = ps.ProductSupplierId "
           + " AND ps.ProductId = pro.ProductId "
           + " AND ps.SupplierId = sup.SupplierId "
           + " AND pkg.PackageId = "
           + tblPackages.getValueAt(tblPackages.getSelectedRow(), PackagesTableModel.PACKAGE_ID)
           + " ORDER BY ProdName, SupName";
   if (tblPackages.getValueAt(tblPackages.getSelectedRow(), PackagesTableModel.PACKAGE_ID) == null
       || tblPackages.getValueAt(tblPackages.getSelectedRow(), PackagesTableModel.PACKAGE_ID)
           == "") {
     return;
   }
   TXLogger.logger.debug("tblPackages listSelectionChaged:" + sql1);
   //		System.out.println(sql1);
   try {
     rs1 = stmt1.executeQuery(sql1);
     while (rs1.next()) {
       Products_Suppliers ps = new Products_Suppliers();
       ps.setProductSupplierID(rs1.getInt(1));
       ps.setProductID(rs1.getInt(2));
       ps.setPsProdName(rs1.getString(3));
       ps.setSupplierID(rs1.getInt(4));
       ps.setPsSuppName(rs1.getString(5));
       dlmInc.addElement(ps);
     }
     getAllProdList(cmbProdFilter.getSelectedItem().toString());
     rs1.close();
   } catch (SQLException ex) {
     TXLogger.logger.error(ex.getMessage());
     // ex.printStackTrace();
   }
 }
  /**
   * Sets whether or not this component is enabled. Disabling this pane will
   * also disable its children.
   *
   * @param enabled <code>true<code> if this component and its children should
   * be enabled, <code>false<code> otherwise
   */
  public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);

    addButton.setEnabled(enabled);
    table.setEnabled(enabled);
    table.getTableHeader().setEnabled(enabled);

    if (enabled) {
      editButton.setEnabled(selectionModel.getSelectedValues().length == 1);
      removeButton.setEnabled(!selectionModel.isSelectionEmpty());
    } else {
      table.clearSelection();

      editButton.setEnabled(enabled);
      removeButton.setEnabled(enabled);
    }
  }
Example #21
0
  protected void moveSelectedRow(JTable from, JTable to) {

    SimpleColorTableModel fromModel = (SimpleColorTableModel) from.getModel();
    SimpleColorTableModel toModel = (SimpleColorTableModel) to.getModel();

    for (int index : from.getSelectedRows()) {

      Vector rowValue = (Vector) fromModel.getDataVector().get(index);

      toModel.addRow(rowValue);
    }

    int selectedRow = -1;
    while ((selectedRow = from.getSelectedRow()) != -1) {

      fromModel.removeRow(selectedRow);
    }

    from.clearSelection();
  }
Example #22
0
 public void setSelection(RosterEntry... selection) {
   // Remove the listener as this change will re-activate it and we end up in a loop!
   dataTable.getSelectionModel().removeListSelectionListener(tableSelectionListener);
   dataTable.clearSelection();
   if (selection != null) {
     for (RosterEntry entry : selection) {
       re = entry;
       int entires = dataTable.getRowCount();
       for (int i = 0; i < entires; i++) {
         if (dataTable.getValueAt(i, RosterTableModel.IDCOL).equals(re.getId())) {
           dataTable.addRowSelectionInterval(i, i);
         }
       }
     }
     if (selection.length > 1) {
       re = null;
     } else {
       this.moveTableViewToSelected();
     }
   } else {
     re = null;
   }
   dataTable.getSelectionModel().addListSelectionListener(tableSelectionListener);
 }
  // copy to a new row
  private void copyAndCreate(int selectedRow) {

    String filterKey =
        cmbPkgFilter.getSelectedItem() == null ? "" : cmbPkgFilter.getSelectedItem().toString();
    if (pkgTblModel.hasEmptyRow()) {
      tblPackages.setRowSelectionInterval(
          tblPackages.getRowCount() - 1, tblPackages.getRowCount() - 1);
      return;
    }
    Vector<Products_Suppliers> v_psInc = new Vector<Products_Suppliers>();
    for (int i = 0; i < dlmInc.size(); i++) {
      v_psInc.addElement((Products_Suppliers) dlmInc.elementAt(i));
    }
    addNewRow();
    pkgTblModel.setRowValueTo(
        pkgTblModel.getRowValueFrom(selectedRow),
        v_psInc,
        tblPackages.getRowCount() - 1,
        filterKey);
    tblPackages.clearSelection();
    tblPackages.setRowSelectionInterval(
        tblPackages.getRowCount() - 1, tblPackages.getRowCount() - 1);
    cmbOrderBy.setSelectedIndex(0);
  }
 /** The action of the table loosing the focus. */
 public void segmentTable_focusLost(FocusEvent e) {
   segmentTable.clearSelection();
 }
  private void clear_official_schedule_types() {
    jTextField1.setText("");

    tbl_official_schedule_types.clearSelection();
    jTextField1.grabFocus();
  }
Example #26
0
 @Override
 public void setDownloadArea(Bounds area) {
   tblSearchResults.clearSelection();
 }
Example #27
0
 /** Clear any selected rows. */
 public void clearSelection() {
   table.clearSelection();
 }
 public void selectExclusive() {
   methodTable.clearSelection();
 }
Example #29
0
 /** The action of the table loosing focus */
 public void callStackTable_focusLost(FocusEvent e) {
   callStackTable.clearSelection();
 }
Example #30
0
 /** Resets the contents of this CallStackComponent. */
 public void reset() {
   methodNames.removeAllElements();
   callStackTable.revalidate();
   callStackTable.clearSelection();
 }