Package javax.swing

Examples of javax.swing.ListSelectionModel


            topHalf.add( listContainer );

            //Create JList for items, add to scroll pane and then add to parent
            // container
            JList list = new JList( items );
            ListSelectionModel listSelectionModel = list.getSelectionModel();
            listSelectionModel.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
            //handler adds item to shopping cart
            list.addMouseListener( new ListSelectionHandler() );
            JScrollPane listPane = new JScrollPane( list );
            listContainer.add( listPane );

            JPanel tableContainer = new JPanel( new GridLayout( 1,
                                                                1 ) );
            tableContainer.setBorder( BorderFactory.createTitledBorder( "Table" ) );
            topHalf.add( tableContainer );

            //Container that displays table showing items in cart
            tableModel = new TableModel();
            JTable table = new JTable( tableModel );
            //handler removes item to shopping cart
            table.addMouseListener( new TableSelectionHandler() );
            ListSelectionModel tableSelectionModel = table.getSelectionModel();
            tableSelectionModel.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
            TableColumnModel tableColumnModel = table.getColumnModel();
            //notice we have a custom renderer for each column as both columns
            // point to the same underlying object
            tableColumnModel.getColumn( 0 ).setCellRenderer( new NameRenderer() );
            tableColumnModel.getColumn( 1 ).setCellRenderer( new PriceRenderer() );
View Full Code Here


   */
  public void copySystemPropertiesToClipboard()
  {

    final StringBuffer buffer = new StringBuffer(500);
    final ListSelectionModel selection = this.table.getSelectionModel();
    final int firstRow = selection.getMinSelectionIndex();
    final int lastRow = selection.getMaxSelectionIndex();
    if ((firstRow != -1) && (lastRow != -1))
    {
      for (int r = firstRow; r <= lastRow; r++)
      {
        for (int c = 0; c < this.table.getColumnCount(); c++)
View Full Code Here

      {
        return;
      }

      final FormulaParameterEntity[] data = parameterTableModel.getGroupedData();
      final ListSelectionModel listSelectionModel = table.getSelectionModel();
      final ArrayList<FormulaParameterEntity> result = new ArrayList<FormulaParameterEntity>(data.length);
      for (int i = 0; i < data.length; i++)
      {
        final FormulaParameterEntity parameter = data[i];
        if (parameter == null)
        {
          continue;
        }
        if (listSelectionModel.isSelectedIndex(model.mapFromModel(i)) == false ||
            parameter.getType() != FormulaParameterEntity.Type.ARGUMENT)
        {
          result.add(data[i]);
        }
      }
View Full Code Here

  items[1] = new LabelledComponent(acr.getString(acr.I_VALUE) + ":", valueText);

  model = new PropsTableModel();
  table = new JTable(model);
  table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  ListSelectionModel lsm = table.getSelectionModel();
  lsm.addListSelectionListener(this);
  JScrollPane scrollPane = new JScrollPane(table);
  scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 
  items[2] = new LabelledComponent(" ", scrollPane);
View Full Code Here

    /*
     * BEGIN INTERFACE ListSelectionListener
     */
    public void valueChanged(ListSelectionEvent e)  {
  ListSelectionModel lsm = (ListSelectionModel)e.getSource();
  boolean  isAdjusting = e.getValueIsAdjusting();
  int  firstIndex = e.getFirstIndex();
  int  lastIndex = e.getLastIndex();

  if (isAdjusting == false) {
      /*
       * Query model for selected index and get the object at the
       * index.
       */
      if (lsm.isSelectionEmpty()) {
    delButton.setEnabled(false);
    chgButton.setEnabled(false);
      } else {
    //
    // Selected something in list so
    // change the combo box of properties and display its
    // value.
    //
          int selectedRow = lsm.getMinSelectionIndex();

    String selectedItem = (String)model.getValueAt(selectedRow, 0);
    comboBox.setSelectedItem(selectedItem);
    valueText.setText(jndiProps.getProperty(selectedItem));

View Full Code Here

        model = new PropsTableModel();
        table = new JTable(model);
  int w2 = table.getColumnModel().getTotalColumnWidth();
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        ListSelectionModel lsm = table.getSelectionModel();
        lsm.addListSelectionListener(this);

  /*
   * Set vertical scrollbar policy to VERTICAL_SCROLLBAR_ALWAYS
   * initially to workaround a layout problem which occurs when
   * a scrollbar is actually needed.
View Full Code Here

    /*
     * BEGIN INTERFACE ListSelectionListener
     */
    public void valueChanged(ListSelectionEvent e)  {
        ListSelectionModel lsm = (ListSelectionModel)e.getSource();
        boolean isAdjusting = e.getValueIsAdjusting();

  if (isAdjusting) {
            if (lsm.isSelectionEmpty()) {
                deleteButton.setEnabled(false);
                purgeButton.setEnabled(false);
      } else {
                selectedRow = lsm.getMinSelectionIndex();
                selectedDurName = (String)model.getValueAt(selectedRow, 0);
                selectedClientID = (String)model.getValueAt(selectedRow, 1);

                deleteButton.setEnabled(true);
                purgeButton.setEnabled(true);
View Full Code Here

  public void valueChanged(ListSelectionEvent e) {
    JList list = (JList)e.getSource();
   
    if(list == sequenceList){
      ListSelectionModel lsm = list.getSelectionModel();
     
      //list.getSelectedIndices();
       //ListSelectionModel lsm = (JList)e.getSource();
      //System.out.println(lsm.getMinSelectionIndex() + " -- " + lsm.getMaxSelectionIndex());
      if(!lsm.isSelectionEmpty())
        structurePanel.selectedSeqRange(selectedChainIndex, lsm.getMinSelectionIndex(), lsm.getMaxSelectionIndex());
    }
   
    else if(list == chainList){
      String chainName = (String)list.getSelectedValue();
      try {
View Full Code Here

    //select default station as long as there is more than one station
    if (jtp != null) {     
      jtp.setUI(new MyTabbedPaneUI(jtp));

      // Make correct tabbed panel visible when user selects a station
      ListSelectionModel rowSM = stationTable.getSelectionModel(); // Add ListListener to station table
      rowSM.addListSelectionListener (
        new ListSelectionListener()
        {
          public void valueChanged(ListSelectionEvent e)
          {
            if (e.getValueIsAdjusting()) return; //Ignore if value is being changed.
            //get the selected row
            int iRow = 0;
            ListSelectionModel lsm = (ListSelectionModel)e.getSource();
            if (lsm.isSelectionEmpty())
            {
              logger_.debug("No station are selected.");
            }
            else
            {
              iRow = lsm.getMinSelectionIndex();
            }
            //activate the selected station
            String stationName = (String)stationDtm_.getValueAt(iRow, 0);
            CardLayout cl = (CardLayout)(dataPanel_.getLayout());
            cl.show(dataPanel_, stationName);
View Full Code Here

      measurementTable.getColumnModel().getColumn(i).setPreferredWidth(15);

    measurementTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    measurementTable.setRowSelectionAllowed(true);
    measurementTable.setColumnSelectionAllowed(false);
    ListSelectionModel measurementSelection = measurementTable.getSelectionModel();
    measurementSelection.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
          if (e.getValueIsAdjusting()) return;
          ListSelectionModel lsm = (ListSelectionModel)e.getSource();
          if (lsm.isSelectionEmpty()) {
            selectedMeasurementRow = -1;
            deleteButton.setEnabled(false);
          } else {
            selectedMeasurementRow = lsm.getMinSelectionIndex();
            deleteButton.setEnabled(true);
          }
        }
      });
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.