Package javax.swing

Examples of javax.swing.ListSelectionModel


    /**
     * Method remove
     */
    public void remove() {
        ListSelectionModel lsm = connectionTable.getSelectionModel();
        int bot = lsm.getMinSelectionIndex();
        int top = lsm.getMaxSelectionIndex();
        for (int i = top; i >= bot; i--) {
            ((Connection) connections.get(i - 1)).remove();
        }
        if (bot > connections.size()) {
            bot = connections.size();
        }
        lsm.setSelectionInterval(bot, bot);
    }
View Full Code Here


    /**
     * Method removeAll
     */
    public void removeAll() {
        ListSelectionModel lsm = connectionTable.getSelectionModel();
        lsm.clearSelection();
        while (connections.size() > 0) {
            ((Connection) connections.get(0)).remove();
        }
        lsm.setSelectionInterval(0, 0);
    }
View Full Code Here

        int rc = dialog.showSaveDialog(this);
        if (rc == JFileChooser.APPROVE_OPTION) {
            try {
                File file = dialog.getSelectedFile();
                FileOutputStream out = new FileOutputStream(file);
                ListSelectionModel lsm =
                        connectionTable.getSelectionModel();
                rc = lsm.getLeadSelectionIndex();
                int n = 0;
                for (Iterator i = connections.iterator(); i.hasNext();
                     n++) {
                    Connection conn = (Connection) i.next();
                    if (lsm.isSelectedIndex(n + 1)
                            || (!(i.hasNext())
                            && (lsm.getLeadSelectionIndex() == 0))) {
                        rc = Integer.parseInt(portField.getText());
                        out.write("\n==============\n".getBytes());
                        out.write(((TCPMon.getMessage("listenPort01",
                                "Listen Port:")
                                + " " + rc + "\n")).getBytes());
View Full Code Here

     * Method resend
     */
    public void resend() {
        int rc;
        try {
            ListSelectionModel lsm = connectionTable.getSelectionModel();
            rc = lsm.getLeadSelectionIndex();
            if (rc == 0) {
                rc = connections.size();
            }
            Connection conn = (Connection) connections.get(rc - 1);
            if (rc > 0) {
                lsm.clearSelection();
                lsm.setSelectionInterval(0, 0);
            }
            InputStream in = null;
            String text = conn.inputText.getText();

            // Fix Content-Length HTTP headers
View Full Code Here

            setupListAnchor();
        }

        private void setupListAnchor() {
            ListSelectionModel selectionModel = getViewRepresentation().getSelectionModel();

            int selectionAnchor = selectionModel.getLeadSelectionIndex();
            selectionModel.clearSelection();
            if (selectionAnchor >= 0 && selectionAnchor < getModel().getSize()) {
                selectionModel.setAnchorSelectionIndex(selectionAnchor);
                selectionModel.setLeadSelectionIndex(selectionAnchor);
            }
        }
View Full Code Here

          if (bypassScrollSelection && scroll && table.getRowCount() > 0) {
            preferenceModel.setScrollToBottom(false);
          }
          previousLastIndex = evt.getLastIndex();

          final ListSelectionModel lsm = (ListSelectionModel) evt.getSource();

          if (lsm.isSelectionEmpty()) {
            if (isVisible()) {
              statusBar.setNothingSelected();
            }

            if (detail.getDocument().getDefaultRootElement() != null) {
View Full Code Here

    Filter[] filters = new Filter[] { requestHostFilter, targetHostFilter, interfaceFilter, operationFilter };

    FilterPipeline pipeline = new FilterPipeline( filters );
    logTable.setFilters( pipeline );

    ListSelectionModel sel = logTable.getSelectionModel();
    sel.addListSelectionListener( new ListSelectionListener()
    {
      public void valueChanged( ListSelectionEvent event )
      {
        int row = logTable.getSelectedRow();
        if( row == -1 )
View Full Code Here

        }
      }

      mFavoritesList = new JList(mFavoritesListModel);
      mFavoritesList.setCellRenderer(new FavoriteListCellRenderer());
      ListSelectionModel selModel = mFavoritesList.getSelectionModel();
      selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      selModel.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
          if(!evt.getValueIsAdjusting()) {
            favoriteSelectionChanged(true);
          }
        }
View Full Code Here

    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setDropTarget(new DropTarget(this, new TableDropAdapter(av, edit)));

    getTableHeader().setReorderingAllowed(false);
    ListSelectionModel lsm = this.getSelectionModel();
    lsm.addListSelectionListener(new TableSelectionListener(med));
  }
View Full Code Here

        return;
      } else if (selectedRow == 0) {
        Toolkit.getDefaultToolkit().beep();
      } else {
        tableModel.moveRowUp(selectedRow);
        ListSelectionModel lsm = annotationsTable.getSelectionModel();
        int newSelectedRow = selectedRow - 1;
        lsm.setSelectionInterval(newSelectedRow, newSelectedRow);

        StyleMapEntry e = (StyleMapEntry) styleList.get(selectedRow);
        styleList.remove(selectedRow);
        styleList.add(newSelectedRow, e);
      }
    } else if (source == moveRowDownButton) {
      int selectedRow = annotationsTable.getSelectedRow();
      if (selectedRow == -1) {
        JOptionPane.showMessageDialog(source, "Select table row", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;
      } else if (selectedRow == (tableModel.getRowCount() - 1)) {
        Toolkit.getDefaultToolkit().beep();
      } else {
        tableModel.moveRowDown(selectedRow);
        ListSelectionModel lsm = annotationsTable.getSelectionModel();
        int newSelectedRow = selectedRow + 1;
        lsm.setSelectionInterval(newSelectedRow, newSelectedRow);

        StyleMapEntry e = (StyleMapEntry) styleList.get(selectedRow);
        styleList.remove(selectedRow);
        styleList.add(newSelectedRow, e);
      }
    } else if (source == addTableEntryButton) {
      String typeName = annotationFeaturesViewer.getSelection();
      if (typeName == null) {
        JOptionPane.showMessageDialog(source,
                "You must first select an annotation type or feature", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;
      }

      addRow(typeName);
    } else if (source == removeTableRowButton) {
      int row = annotationsTable.getSelectedRow();
      if (row >= 0) {
        String message = "Are you sure you want to remove "
                + tableModel.getValueAt(row, StyleConstants.LABEL_COLUMN);
        int rv = JOptionPane.showConfirmDialog(removeTableRowButton, message, "Remove Table Row",
                JOptionPane.YES_NO_OPTION);
        if (rv == JOptionPane.YES_OPTION) {
          styleList.remove(row);
          styleList.trimToSize();
          tableModel.removeRow(row);

          ListSelectionModel lsm = annotationsTable.getSelectionModel();
          int newSelectedRow = (row == styleList.size() ? (row - 1) : row);
          lsm.setSelectionInterval(newSelectedRow, newSelectedRow);
        }
      } else {
        JOptionPane.showMessageDialog(source, "You must first select a table row to remove",
                "Error", JOptionPane.ERROR_MESSAGE);
      }
View Full Code Here

TOP

Related Classes of javax.swing.ListSelectionModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.