Package javax.swing

Examples of javax.swing.ListSelectionModel



  private void configurePanelWithoutSelection()
  {
    final JLabel columnsLabel = new JLabel(UtilMessages.getInstance().getString("ArrayCellEditorDialog.SelectedItems"));
    final ListSelectionModel selectionModel = table.getSelectionModel();

    final Action addGroupAction = new AddEntryAction(tableModel);
    final Action removeGroupAction = new RemoveEntryAction(tableModel, selectionModel);
    final Action sortUpAction = new SortBulkUpAction(tableModel, selectionModel, table);
    final Action sortDownAction = new SortBulkDownAction(tableModel, selectionModel, table);
View Full Code Here


  protected Component createContentPane()
  {
    table = new JTable(tableModel);
    table.setDefaultEditor(GroupDataEntry.class, groupDataEntryCellEditor);
    table.setDefaultRenderer(GroupDataEntry.class, new GroupDataEntryCellRenderer());
    final ListSelectionModel selectionModel = table.getSelectionModel();

    final Action addGroupAction = new AddGroupAction(tableModel);
    final Action removeGroupAction = new RemoveGroupAction(tableModel, selectionModel);
    final Action editGroupAction = new EditGroupAction(tableModel, selectionModel);
View Full Code Here

    {
      final KeyedComboBoxModel keyedComboBoxModel =
          DefaultParameterComponentFactory.createModel(listParameter, parameterContext);
      list.setModel(keyedComboBoxModel);

      final ListSelectionModel selectionModel = list.getSelectionModel();
      final Object value = updateContext.getParameterValue(listParameter.getName());
      final HashSet keylist = getNormalizedSet(value);
      selectionModel.setValueIsAdjusting(true);
      list.clearSelection();

      final int size = keyedComboBoxModel.getSize();
      for (int i = 0; i < size; i++)
      {
        final Object key = keyedComboBoxModel.getKeyAt(i);
        if (isSafeMatch(key, keylist))
        {
          selectionModel.addSelectionInterval(i, i);
        }
      }
      selectionModel.setValueIsAdjusting(false);
    }
    finally
    {
      adjustingToExternalInput = false;
    }
View Full Code Here

      try
      {
        adjustingToUserInput = true;

        final KeyedComboBoxModel listModel = (KeyedComboBoxModel) list.getModel();
        final ListSelectionModel selectionModel = list.getSelectionModel();
        selectionModel.setValueIsAdjusting(true);

        // Determine if this selection has added or removed items
        final HashSet<Integer> newSelections = new HashSet<Integer>();
        final int size = listModel.getSize();
        for (int i = 0; i < size; i++)
        {
          if (selectionModel.isSelectedIndex(i))
          {
            newSelections.add(i);
          }
        }

        // Turn on everything that was selected previously
        Iterator it = selectionCache.iterator();
        while (it.hasNext())
        {
          final Integer integer = (Integer) it.next();
          final int index = integer.intValue();
          selectionModel.addSelectionInterval(index, index);
        }

        // Add or remove the delta

        if (newSelections.containsAll(selectionCache) == false)
        {
          it = newSelections.iterator();
          while (it.hasNext())
          {
            final Integer nextInt = (Integer) it.next();
            final int index = nextInt.intValue();
            if (selectionCache.contains(nextInt))
            {
              selectionModel.removeSelectionInterval(index, index);
            }
            else
            {
              selectionModel.addSelectionInterval(index, index);
            }
          }

          // Save selections for next time
          selectionCache.clear();
          for (int i = 0; i < size; i++)
          {
            if (selectionModel.isSelectedIndex(i))
            {
              selectionCache.add(i);
            }
          }
        }

        selectionModel.setValueIsAdjusting(false);

        final int[] indices = list.getSelectedIndices();
        final Object[] keys = new Object[indices.length];
        for (int i = 0; i < keys.length; i++)
        {
View Full Code Here

            col.setMaxWidth( col.getPreferredWidth() / 2 );
            col = connectionTable.getColumnModel().getColumn(REQ_COLUMN);
            col.setPreferredWidth( col.getPreferredWidth() * 2 );


            ListSelectionModel sel = connectionTable.getSelectionModel();

            sel.addListSelectionListener( new ListSelectionListener() {
                    public void valueChanged(ListSelectionEvent event) {
                        if (event.getValueIsAdjusting()) return ;
                        ListSelectionModel m = (ListSelectionModel) event.getSource();
                        int divLoc = outPane.getDividerLocation();

                        if (m.isSelectionEmpty()) {
                            setLeft( new JLabel(" " + getMessage("wait00", "Waiting for Connection...") ) );
                            setRight( new JLabel("") );
                            removeButton.setEnabled(false);
                            removeAllButton.setEnabled(false);
                            saveButton.setEnabled(false);
                            resendButton.setEnabled(false);
                        }
                        else {
                            int row = m.getLeadSelectionIndex();

                            if ( row == 0 ) {
                                if ( connections.size() == 0 ) {
                                    setLeft(new JLabel(" " + getMessage("wait00", "Waiting for connection...")));
                                    setRight(new JLabel(""));
View Full Code Here

                e.printStackTrace();
            }
        }

        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

            if ( bot > connections.size() ) bot = connections.size();
            lsm.setSelectionInterval(bot, bot);
        }

        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

            if ( rc == JFileChooser.APPROVE_OPTION ) {
                try {
                    File             file = dialog.getSelectedFile();
                    FileOutputStream out  = new FileOutputStream( file );

                    ListSelectionModel lsm = connectionTable.getSelectionModel();

                    rc = lsm.getLeadSelectionIndex();
                    if ( rc == 0 ) rc = connections.size();
                    Connection conn = (Connection) connections.get( rc - 1 );

                    rc = Integer.parseInt( portField.getText() );
                    out.write( (new String(getMessage("listenPort01", "Listen Port:") + " " + rc + "\n" )).getBytes() );
View Full Code Here

        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();
View Full Code Here

                inputText  = new JTextArea( null, null, 20, 80 );
                inputScroll = new JScrollPane( inputText );
                outputText = new JTextArea( null, null, 20, 80 );
                outputScroll = new JScrollPane( outputText );

                ListSelectionModel lsm = listener.connectionTable.getSelectionModel();

                if ( count == 0 || lsm.getLeadSelectionIndex() == 0 ) {
                    listener.outPane.setVisible( false );
                    int divLoc = listener.outPane.getDividerLocation();

                    listener.setLeft( inputScroll );
                    listener.setRight( outputScroll );
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.