Package javax.swing

Examples of javax.swing.DefaultListSelectionModel


public class getMinSelectionIndex implements Testlet
{
  public void test(TestHarness harness)
  {
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    harness.check(m.getMinSelectionIndex(), -1);
    m.addSelectionInterval(99, 101);
    harness.check(m.getMinSelectionIndex(), 99);
    m.clearSelection();
    harness.check(m.getMinSelectionIndex(), -1);
  }
View Full Code Here


  }
 
  private void testGeneral(TestHarness harness)
  {
    harness.checkPoint("testGeneral()");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.addListSelectionListener(this);
    harness.check(m.getSelectionMode(),
            ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    harness.check(m.getSelectionMode(),
            ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    harness.check(lastEvent, null);
   
    // try bad value
    boolean pass = false;
    try
      {
        m.setSelectionMode(99);
      }
    catch (IllegalArgumentException e)
      {
        pass = true
      }
View Full Code Here

  }
 
  private void testIntervalToSingle(TestHarness harness)
  {
    harness.checkPoint("testIntervalToSingle()");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    m.addSelectionInterval(2, 4);
    m.addListSelectionListener(this);
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    harness.check(m.getSelectionMode(), ListSelectionModel.SINGLE_SELECTION);
    harness.check(m.isSelectedIndex(2), true);
    harness.check(m.isSelectedIndex(3), true);
    harness.check(m.isSelectedIndex(4), true);
    harness.check(lastEvent, null);
  }
View Full Code Here

            TableColumn tc = makeTableColumn(x, c);
            columnList.add(tc);
            x++;
        }
        dlsm = new DefaultListSelectionModel();
        dlsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        orderUpdate();
        check();
    }
View Full Code Here

            for (TableColumnModelListener l : watchers) {
                l.columnAdded(new TableColumnModelEvent(this, x, x));
            }
            x++;
        }
        dlsm = new DefaultListSelectionModel();
        dlsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

        orderUpdate();

    }
View Full Code Here

    // ignore
  }

  public void test(TestHarness harness)
  {
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    ListSelectionListener[] listeners = m.getListSelectionListeners();
    harness.check(listeners.length, 0);
   
    m.addListSelectionListener(this);
    listeners = m.getListSelectionListeners();
    harness.check(listeners[0], this);
  }
View Full Code Here

public class isSelectionEmpty implements Testlet
{
  public void test(TestHarness harness)
  {
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    harness.check(m.isSelectionEmpty(), true);
    m.addSelectionInterval(99, 99);
    harness.check(m.isSelectionEmpty(), false);
    m.clearSelection();
    harness.check(m.isSelectionEmpty(), true);
  }
View Full Code Here

public class toString implements Testlet
{
  public void test(TestHarness harness)
  {
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    harness.check(m.toString().endsWith(" ={}"));
    m.addSelectionInterval(3, 5);
    harness.check(m.toString().endsWith(" ={3, 4, 5}"));
    m.addSelectionInterval(7, 7);
    harness.check(m.toString().endsWith(" ={3, 4, 5, 7}"));
  }
View Full Code Here

  }
 
  private void testSingleSelection(TestHarness harness)
  {
    harness.checkPoint("SINGLE_SELECTION (1)");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.addSelectionInterval(3, 3);
    m.addListSelectionListener(this);
    m.insertIndexInterval(3, 2, true);
    harness.check(m.isSelectedIndex(3), false);
    harness.check(m.isSelectedIndex(4), false);
    harness.check(m.isSelectedIndex(5), true);
    harness.check(m.getAnchorSelectionIndex(), 5);
    harness.check(m.getLeadSelectionIndex(), 5);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 3);
    harness.check(lastEvent.getLastIndex(), 5);
   
    harness.checkPoint("SINGLE_SELECTION (2)");
    lastEvent = null;
    m.insertIndexInterval(5, 2, false)// this does nothing
    harness.check(m.isSelectedIndex(5), true);
    harness.check(m.isSelectedIndex(6), false);
    harness.check(m.isSelectedIndex(7), false);
    harness.check(lastEvent, null);
   
    // try negative index
    harness.checkPoint("SINGLE_SELECTION (3)");
    boolean pass = false;
    try
    {
      m.insertIndexInterval(-1, 1, true);
    }
    catch (IndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try negative count
    harness.checkPoint("SINGLE_SELECTION (4)");
    pass = false;
    try
    {
      m.insertIndexInterval(0, -1, true);
    }
    catch (IndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass)
   
    // try zero count
    harness.checkPoint("SINGLE_SELECTION (5)");
    lastEvent = null;
    m.insertIndexInterval(0, 0, true);
    harness.check(lastEvent.getFirstIndex(), 0)
    harness.check(lastEvent.getLastIndex(), 6)
  }
View Full Code Here

  }

  private void testSingleInterval(TestHarness harness)
  {
    harness.checkPoint("SINGLE_INTERVAL_SELECTION (1)");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    m.setSelectionInterval(3, 3);
    m.addListSelectionListener(this);
   
    // here, we insert two new items in the list right before the selected item
    // 3 (which moves up to position 5).
    m.insertIndexInterval(3, 2, true);
    harness.check(m.isSelectedIndex(3), true); // FIXME: surely wrong?
    harness.check(m.isSelectedIndex(4), true); // FIXME: likewise?
    harness.check(m.isSelectedIndex(5), true);
    harness.check(m.isSelectedIndex(6), false);
    harness.check(m.getAnchorSelectionIndex(), 5);
    harness.check(m.getLeadSelectionIndex(), 5);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 3);
    harness.check(lastEvent.getLastIndex(), 5);

    harness.checkPoint("SINGLE_INTERVAL_SELECTION (2)");
    m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    m.setSelectionInterval(3, 3);
    m.addListSelectionListener(this);
    lastEvent = null;
   
    // here, we insert two new items in the list right AFTER the selected item
    // 3
    m.insertIndexInterval(3, 2, false);
    harness.check(m.isSelectedIndex(3), true);
    harness.check(m.isSelectedIndex(4), true); // FIXME: surely wrong?
    harness.check(m.isSelectedIndex(5), true); // FIXME: likewise?
    harness.check(m.isSelectedIndex(6), false);
    harness.check(m.getAnchorSelectionIndex(), 3);
    harness.check(m.getLeadSelectionIndex(), 3);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 4);
    harness.check(lastEvent.getLastIndex(), 5);
 
    // try negative index
    boolean pass = false;
    try
    {
      m.insertIndexInterval(-1, 1, true);
    }
    catch (IndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try negative count
    pass = false;
    try
    {
      m.insertIndexInterval(0, -1, true);
    }
    catch (IndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try zero count
    lastEvent = null;
    m.insertIndexInterval(0, 0, true);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 0);
    harness.check(lastEvent.getLastIndex(), 6);
  }
View Full Code Here

TOP

Related Classes of javax.swing.DefaultListSelectionModel

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.