zoukankan      html  css  js  c++  java
  • e792. 建立一个包括所有数据的SpinnerListModel

    By default, if the user is browsing the values in a SpinnerListModel, the iteration stops when either end is reached. This example demonstrates a subclass that allows the user to continuously loop through the values.

        SpinnerCircularListModel listModel = new SpinnerCircularListModel(
            new String[]{"red", "green", "blue"});
        JSpinner spinner = new JSpinner(listModel);
        
        public class SpinnerCircularListModel extends SpinnerListModel {
            public SpinnerCircularListModel(Object[] items) {
                super(items);
            }
        
            // Returns the next value. If the current value is at the end
            // of the list, returns the first value.
            // There must be at least one item in the list.
            public Object getNextValue() {
                java.util.List list = getList();
                int index = list.indexOf(getValue());
        
                index = (index >= list.size()-1) ? 0 : index+1;
                return list.get(index);
            }
        
            // Returns the previous value. If the current value is at the
            // start of the list, returns the last value.
            // There must be at least one item in the list.
            public Object getPreviousValue() {
                java.util.List list = getList();
                int index = list.indexOf(getValue());
        
                index = (index <= 0) ? list.size()-1 : index-1;
                return list.get(index);
            }
        }
    
    Related Examples
  • 相关阅读:
    搭建视频网站光线cms
    Linux FTP服务配置
    Chromium下载地址
    Ubuntu Server批量ping选择最快源
    vs2010扩展
    私有云
    mssql格式化输出
    CSLA .NET 3.6支持Silverlight 2
    Unity Application Block 1.2 for Silverlight December 2008
    silverlight寻奇 Graphite
  • 原文地址:https://www.cnblogs.com/borter/p/9596248.html
Copyright © 2011-2022 走看看