Package javax.swing

Examples of javax.swing.SpinnerListModel


public class getModel implements Testlet
{
  public void test(TestHarness harness)
  {
    harness.checkPoint("()");
    SpinnerListModel m = new SpinnerListModel(new String[] {"A", "B", "C"});
    JSpinner s = new JSpinner(m);
    JSpinner.ListEditor editor = (JSpinner.ListEditor) s.getEditor();
    harness.check(editor.getModel(), m);
  }
View Full Code Here


public class ArrayModel implements Testlet
{

  public void test(TestHarness harness)
  {
    SpinnerListModel model;
    Object[] array;
    boolean threwException;

    /* Create array */
    array = new Object[]{"GNU", "Classpath"};
    /* Create model */
    model = new SpinnerListModel(array);
    /* Check retrieval */
    harness.check(model.getList() != null, "Array model creation check");
    harness.check(model.getValue(), "GNU", "Array model current value check");
    harness.check(model.getNextValue(), "Classpath", "Array model next value check");
    harness.check(model.getValue(), "GNU", "Array model no change of current value after next check");
    harness.check(model.getPreviousValue(), null, "Array model previous value check");
    /* Value change check */
    array[0] = "GNU's Not UNIX";
    harness.check(model.getValue(), "GNU's Not UNIX", "Array model backing list change check");
    /* Value setting check */
    model.setValue("Classpath");
    harness.check(model.getValue(), "Classpath", "Array model successful set check");
    threwException = false;
    try
      {
        model.setValue("Sun");
      }
    catch (IllegalArgumentException exception)
      {
  threwException = true;
      }
View Full Code Here

public class ListModel implements Testlet
{

  public void test(TestHarness harness)
  {
    SpinnerListModel model;
    List list;
    boolean threwException = false;
   
    /* Create list */
    list = new ArrayList();
    list.add("GNU");
    list.add("Classpath");
    /* Create model */
    model = new SpinnerListModel(list);
    /* Check retrieval */
    harness.check(model.getList() != null, "List model creation check");
    harness.check(model.getValue(), "GNU", "List model current value check");
    harness.check(model.getNextValue(), "Classpath", "List model next value check");
    harness.check(model.getValue(), "GNU", "List model no change of current value after next check");
    harness.check(model.getPreviousValue(), null, "List model previous value check");
    /* Value change check */
    list.set(0, "GNU's Not UNIX");
    harness.check(model.getValue(), "GNU's Not UNIX", "List model backing list change check");
    /* Value setting check */
    model.setValue("Classpath");
    harness.check(model.getValue(), "Classpath", "List model successful set check");
    try
      {
        model.setValue("Sun");
      }
    catch (IllegalArgumentException exception)
      {
  threwException = true;
      }
View Full Code Here

public class SetList implements Testlet
{

public void test(TestHarness harness)
{
    SpinnerListModel model;
    List list;
    boolean threwException;

    /* Create default model */
    model = new SpinnerListModel();
    /* Invalid values */
    threwException = false;
    try
      {
        model.setList((ArrayList) null);
        harness.fail("Null list supplied to setList failed to throw an exception.");
      }
    catch (IllegalArgumentException exception)
      {
        threwException = true;
      }
    harness.check(threwException, "setList null list exception check.");
    threwException = false;
    try
      {
        model.setList(new ArrayList());
      }
    catch (IllegalArgumentException exception)
      {
        threwException = true;
      }
    harness.check(threwException, "setList empty list exception check.");
    /* Test a successful change */
    list = new ArrayList();
    list.add("GNU");
    model.setList(list);
    harness.check(model.getList(), list, "Model allowed successful change of list.");
  }
View Full Code Here

public class Ordering implements Testlet
{

  public void test(TestHarness harness)
  {
    SpinnerListModel model;
    List list;
   
    /* Create list */
    list = new ArrayList();
    list.add("a");
    list.add("z");
    list.add("a");
    list.add("b");
    /* Create model */
    model = new SpinnerListModel(list);
    /* Check retrieval */
    harness.check(model.getList() != null, "Array model ordering creation check");
    harness.check(model.getValue(), "a", "Array model ordering current value check");
    harness.check(model.getNextValue(), "z", "Array model ordering next value check");
    harness.check(model.getValue(), "a", "Array model ordering no change of current value after next check");
    harness.check(model.getPreviousValue(), null, "Array model ordering previous value check");
    /* Value ordering of setting check */
    model.setValue("a");
    harness.check(model.getValue(), "a", "Array model ordering successful set check");
    harness.check(model.getPreviousValue(), null, "Array model ordering post-set previous value check");
    harness.check(model.getNextValue(), "z", "Array model ordering post-set next value check");
  }
View Full Code Here

public class Constructors implements Testlet
{

  public void test(TestHarness harness)
  {
    SpinnerListModel model;
    boolean threwException = false;

    /* Invalid values */
    try
      {
        model = new SpinnerListModel((Object[]) null);
      }
    catch (IllegalArgumentException exception)
      {
  threwException = true;
      }
    harness.check(threwException, "Null array to constructor exception check");
    threwException = false;
    try
      {
        model = new SpinnerListModel(new ArrayList());
      }
    catch (IllegalArgumentException exception)
      {
  threwException = true;
      }
    harness.check(threwException, "Empty list to constructor exception check");
    threwException = false;
    try
      {
        model = new SpinnerListModel(new Object[]{});
        harness.fail("Empty array supplied to constructor failed to throw an exception.");
      }
    catch (IllegalArgumentException exception)
      {
  threwException = true;
      }
    harness.check(threwException, "Empty array to constructor exception check");
    /* Test the default model */
    model = new SpinnerListModel();
    harness.check(model.getList() != null, "Default list construction check.");
    harness.check(model.getValue(), "empty", "Default list current value check.");
    harness.check(model.getNextValue(), null, "Default list next value check.");
    harness.check(model.getPreviousValue(), null, "Default list previous value check.");

  }
View Full Code Here

    harness.check(e2 instanceof JSpinner.DateEditor);
    // no listeners added to the editor yet
    EventListener[] e2l = e2.getListeners(ChangeListener.class);
    harness.check(e2l.length, 0);
   
    SpinnerModel m3 = new SpinnerListModel();
    MyJSpinner s3 = new MyJSpinner(m3);
    JComponent e3 = s3.createEditor(m3);
    harness.check(e3 instanceof JSpinner.ListEditor);
    // no listeners added to the editor yet
    EventListener[] e3l = e3.getListeners(ChangeListener.class);
View Full Code Here

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("");
        setLocationByPlatform(true);
        jPanelSeleccionar.setBorder(javax.swing.BorderFactory.createTitledBorder("Seleccione la tecla"));
        jSpinnerTeclas.setModel(new SpinnerListModel(disponibles));
        jSpinnerTeclas.setFocusCycleRoot(true);
        jSpinnerTeclas.setFocusable(false);

        javax.swing.GroupLayout jPanelSeleccionarLayout = new javax.swing.GroupLayout(jPanelSeleccionar);
        jPanelSeleccionar.setLayout(jPanelSeleccionarLayout);
View Full Code Here

            GregorianCalendar cal = (value == null ? new GregorianCalendar() : (GregorianCalendar) value);

            day = new SpinnerNumberModel(cal.get(Calendar.DATE), 1, 31, 1);
            addSpinner(new JSpinner(day), status);

            month = new SpinnerListModel(MONTH_STRINGS);
            month.setValue(MONTH_STRINGS[cal.get(Calendar.MONTH)]);
            JSpinner monthSpinner = new JSpinner(month);
            JComponent editor = monthSpinner.getEditor();
            if (editor instanceof JSpinner.DefaultEditor) {
                JFormattedTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
View Full Code Here

    public NamePropertiesPanel() {
        initComponents();
        String[] spinnerValues = new String[]{
            SMALL_STRING, REGULAR_STRING, LARGE_STRING};
        myNameFontSizeSpinner.setModel(new SpinnerListModel(spinnerValues));
        myNameFontSizeSpinner.setValue(REGULAR_STRING);
        otherNamesFontSizeSpinner.setModel(new SpinnerListModel(spinnerValues));
        otherNamesFontSizeSpinner.setValue(REGULAR_STRING);
        ((DefaultEditor) myNameFontSizeSpinner.getEditor()).getTextField().
                setEditable(false);
        ((DefaultEditor) otherNamesFontSizeSpinner.getEditor()).getTextField().
                setEditable(false);
View Full Code Here

TOP

Related Classes of javax.swing.SpinnerListModel

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.