Package javax.swing

Examples of javax.swing.DefaultListSelectionModel$Segment


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


  }
 
  public void testSingleSelection(TestHarness harness)
  {
    harness.checkPoint("SINGLE_SELECTION");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.addSelectionInterval(1, 2);
    harness.check(m.isSelectedIndex(1), false);
    harness.check(m.isSelectedIndex(2), true);
    harness.check(m.isSelectedIndex(3), false);
    m.addListSelectionListener(this);
    m.removeSelectionInterval(2, 3);
    harness.check(m.isSelectionEmpty(), true);
   
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 2);
    harness.check(lastEvent.getLastIndex(), 3);
  }
View Full Code Here

  }

  public void testSingleInterval(TestHarness harness)
  {
    harness.checkPoint("SINGLE_INTERVAL_SELECTION");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    m.addSelectionInterval(2, 6);
    harness.check(m.isSelectedIndex(1), false);
    harness.check(m.isSelectedIndex(2), true);
    harness.check(m.isSelectedIndex(3), true);
    harness.check(m.isSelectedIndex(4), true);
    harness.check(m.isSelectedIndex(5), true);
    harness.check(m.isSelectedIndex(6), true);
    harness.check(m.isSelectedIndex(7), false);
    m.addListSelectionListener(this);
    m.removeSelectionInterval(3, 5);
    harness.check(m.isSelectedIndex(1), false);
    harness.check(m.isSelectedIndex(2), true);
    harness.check(m.isSelectedIndex(3), false);
    harness.check(m.isSelectedIndex(4), false);
    harness.check(m.isSelectedIndex(5), false);
    harness.check(m.isSelectedIndex(6), false);
    harness.check(m.isSelectedIndex(7), false);
   
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 2);
    harness.check(lastEvent.getLastIndex(), 6);
  }
View Full Code Here

  }

  public void testMultipleInterval(TestHarness harness)
  {
    harness.checkPoint("MULTIPLE_INTERVAL_SELECTION");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    m.addSelectionInterval(2, 6);
    harness.check(m.isSelectedIndex(1), false);
    harness.check(m.isSelectedIndex(2), true);
    harness.check(m.isSelectedIndex(3), true);
    harness.check(m.isSelectedIndex(4), true);
    harness.check(m.isSelectedIndex(5), true);
    harness.check(m.isSelectedIndex(6), true);
    harness.check(m.isSelectedIndex(7), false);
    m.addListSelectionListener(this);
    m.removeSelectionInterval(3, 5);
    harness.check(m.isSelectedIndex(1), false);
    harness.check(m.isSelectedIndex(2), true);
    harness.check(m.isSelectedIndex(3), false);
    harness.check(m.isSelectedIndex(4), false);
    harness.check(m.isSelectedIndex(5), false);
    harness.check(m.isSelectedIndex(6), true);
    harness.check(m.isSelectedIndex(7), false);
   
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 2);
    harness.check(lastEvent.getLastIndex(), 6);
  }
View Full Code Here

   * @param harness  the test harness.
   */
  private void testSingleInterval(TestHarness harness)
  {
    harness.checkPoint("SINGLE_INTERVAL_SELECTION (1)");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    events.clear();
    m.addListSelectionListener(this);
    m.setSelectionInterval(6, 7);
    harness.check(m.isSelectedIndex(5), false);
    harness.check(m.isSelectedIndex(6), true);
    harness.check(m.isSelectedIndex(7), true);
    harness.check(m.isSelectedIndex(8), false);
    harness.check(m.getAnchorSelectionIndex(), 6);
    harness.check(m.getLeadSelectionIndex(), 7);
    harness.check(events.size(), 1);
    ListSelectionEvent lastEvent = (ListSelectionEvent) events.get(0);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 6);
    harness.check(lastEvent.getLastIndex(), 7);

    // no event is generated if we update the same again
    harness.checkPoint("SINGLE_INTERVAL_SELECTION (2)");   
    events.clear();
    m.setSelectionInterval(6, 7);
    harness.check(events.size(), 0);

    // now if we set another selection, the event range should cover the old
    // index too
    harness.checkPoint("SINGLE_INTERVAL_SELECTION (3)");   
    events.clear();
    m.setSelectionInterval(3, 3);
    harness.check(m.isSelectedIndex(3), true);
    harness.check(m.isSelectedIndex(6), false);
    harness.check(m.isSelectedIndex(7), false);
    harness.check(events.size(), 1);
    lastEvent = (ListSelectionEvent) events.get(0);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 3);
    harness.check(lastEvent.getLastIndex(), 7);
   
    // the anchor can move around independently of the selection, is it
    // included in the event range? YES
    harness.checkPoint("SINGLE_INTERVAL_SELECTION (3)");   
    m.setAnchorSelectionIndex(5);
    events.clear();
    m.setSelectionInterval(4, 4);
    harness.check(m.isSelectedIndex(3), false);
    harness.check(m.isSelectedIndex(4), true);
    harness.check(m.isSelectedIndex(5), false);
    lastEvent = (ListSelectionEvent) events.get(0);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 3);
    harness.check(lastEvent.getLastIndex(), 5);
  }
View Full Code Here

  }
 
  private void testMultipleInterval(TestHarness harness)
  {
    harness.checkPoint("MULTIPLE_INTERVAL_SELECTION");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    events.clear();
    m.addListSelectionListener(this);
    m.setSelectionInterval(3, 5);
    harness.check(m.isSelectedIndex(2), false);
    harness.check(m.isSelectedIndex(3), true);
    harness.check(m.isSelectedIndex(4), true);
    harness.check(m.isSelectedIndex(5), true);
    harness.check(m.isSelectedIndex(6), false);
    harness.check(m.getAnchorSelectionIndex(), 3);
    harness.check(m.getLeadSelectionIndex(), 5);
    harness.check(m.getMinSelectionIndex(), 3);
    harness.check(m.getMaxSelectionIndex(), 5);
    harness.check(events.size(), 1);
    ListSelectionEvent lastEvent = (ListSelectionEvent) events.get(0);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 3);
    harness.check(lastEvent.getLastIndex(), 5);
    events.clear();
   
    m.setSelectionInterval(2, 3);
    harness.check(m.isSelectedIndex(2), true);
    harness.check(m.isSelectedIndex(3), true);
    harness.check(m.isSelectedIndex(4), false);
    harness.check(m.isSelectedIndex(5), false);
    harness.check(m.isSelectedIndex(6), false);
    harness.check(m.getAnchorSelectionIndex(), 2);
    harness.check(m.getLeadSelectionIndex(), 3);
    harness.check(m.getMinSelectionIndex(), 2);
    harness.check(m.getMaxSelectionIndex(), 3);
    lastEvent = (ListSelectionEvent) events.get(0);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 2);
    harness.check(lastEvent.getLastIndex(), 5);
  }
View Full Code Here

   * @param harness
   */
  private void testSingleX(TestHarness harness)
  {
    harness.checkPoint("SINGLE_SELECTION_X");
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.addSelectionInterval(2, 4);
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    events.clear();
    m.addListSelectionListener(this);
    m.setSelectionInterval(0, 1);
    harness.check(m.isSelectedIndex(0), false);
    harness.check(m.isSelectedIndex(1), true);
    harness.check(m.getAnchorSelectionIndex(), 1);
    harness.check(m.getLeadSelectionIndex(), 1);
    harness.check(events.size(), 1);
    ListSelectionEvent lastEvent = (ListSelectionEvent) events.get(0);
    harness.check(lastEvent.getSource(), m);
    harness.check(lastEvent.getFirstIndex(), 1);
    harness.check(lastEvent.getLastIndex(), 4);
View Full Code Here

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

    // ignore
  }

  public void test(TestHarness harness)
  {
    DefaultListSelectionModel m1 = new DefaultListSelectionModel();
    m1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    m1.setLeadAnchorNotificationEnabled(false);
    m1.addListSelectionListener(this);
    m1.addSelectionInterval(5, 9);
   
    DefaultListSelectionModel m2 = null;
    try
      {
        m2 = (DefaultListSelectionModel) m1.clone();
      }
    catch (CloneNotSupportedException e)
      {
       
      }
    harness.check(m2.getSelectionMode(),
            ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    harness.check(m2.isLeadAnchorNotificationEnabled(), false);
    harness.check(m2.isSelectedIndex(4), false);
    harness.check(m2.isSelectedIndex(5), true);
    harness.check(m2.isSelectedIndex(9), true);
    harness.check(m2.isSelectedIndex(10), false);
   
    // confirm that m1 and m2 are independent
    m2.clearSelection();
    harness.check(m2.isSelectionEmpty(), true);
    harness.check(m1.isSelectionEmpty(), false);
   
    // confirm that m2 doesn't have any listeners
    ListSelectionListener[] listeners = m2.getListSelectionListeners();
    harness.check(listeners.length, 0);
    listeners = m1.getListSelectionListeners();
    harness.check(listeners.length, 1);   
  }
View Full Code Here

    // ignore
  }

  public void test(TestHarness harness)
  {
    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.addListSelectionListener(this);
    harness.check(m.getListSelectionListeners().length, 1);
    m.removeListSelectionListener(this);
    harness.check(m.getListSelectionListeners().length, 0);   
    // remove a listener that isn't there
    m.removeListSelectionListener(this);
    harness.check(m.getListSelectionListeners().length, 0);   
    // try null
    m.removeListSelectionListener(null);
    harness.check(m.getListSelectionListeners().length, 0);   
  }
View Full Code Here

TOP

Related Classes of javax.swing.DefaultListSelectionModel$Segment

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.