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

e792. 建立一个包括所有数据的SpinnerListModel的更多相关文章

  1. 通过myclipse建立一个简单的Hibernate项目(PS:在单元测试中实现数据的向表的插入)

    Hibernate的主要功能及用法: Ⅰ.Hibernate封装了JDBC,使Java程序员能够以面向对象的思想对数据库进行操作 Ⅱ.Hibernate可以应用于EJB的J2EE架构,完成数据的持久化 ...

  2. 如何建立一个完整的游戏AI

    http://blog.friskit.me/2012/04/how-to-build-a-perfect-game-ai/ 人工智能(Artificial Intelligence)在游戏中使用已经 ...

  3. jmeter 建立一个网络服务的测试计划

    如何创建一个 测试计划 测试一个网络服务. 你会 创建5个用户发送请求到一页. 同时,你会告诉用户运行测试两次. 的总数 请求用户请求(5)x(1)x(重复2次)= 10 HTTP请求. 来 建立测试 ...

  4. Android在如何建立一个WebServer

    今天老板交待任务最终完成了,感觉收获颇多,所以写一个关于它的记录,首先,看一下.老板的需求 需求: 希望移动端的用户标识(IMEI)和HTML页面的用户标识(Cookie)连接起来,当中HTML页面可 ...

  5. [渣译文] 使用 MVC 5 的 EF6 Code First 入门 系列:建立一个EF数据模型

    英文渣水平,大伙凑合着看吧…… 这是微软官方教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译,这里是第一篇: ...

  6. C# Dictionary源码剖析---哈希处理冲突的方法有:开放定址法、再哈希法、链地址法、建立一个公共溢出区等

    C# Dictionary源码剖析 参考:https://blog.csdn.net/exiaojiu/article/details/51252515 http://www.cnblogs.com/ ...

  7. 建立一个php 基础类

    在些PHP文件的时候,一般首先都是要先写一下基础类: 主要包括以下几个方面: 1.服务器的链接:包括主机,用户名,密码 2.数据库的选择:要操作哪个数据库 3.字符集的设置:设置什么样的编码 4.查询 ...

  8. Rails 建立一个资源

    在blog 应用程序中.你可以通过脚手架(scaffolded)开始建立一个资源. 这将是单一的blog 提交.请输入以下命令 $ rails generate scaffold Post name: ...

  9. 使用 MVC 5 的 EF6 Code First 入门 系列:建立一个EF数据模型

    这是微软官方SignalR 2.0教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译,这里是第一篇:建立一个E ...

随机推荐

  1. 每日英语:America The Vulgar

    'What's celebrity sex, Dad?' It was my 7-year-old son, who had been looking over my shoulder at my c ...

  2. Python(九)之网络编程

    一般的网络通信: Python中利用socket模块实现网络主机间通讯: socket.socket(family,type) family:套接字类型 AF_INET AF_UNIX type: S ...

  3. 通用后台管理系统(ExtJS 4.2 + Spring MVC 3.2 + Hibernate)

    通用后台管理系统(ExtJS 4.2 +Spring MVC 3.2 + Hibernate) 开发语言JAVA 成品成品 前端技术extjs 数据库mysql,sql server,oracle 系 ...

  4. Scala开发入门指南

    作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs 一.下载Scala 当前Scala的最新版本为2.10.2版,Windows有两种发布包: 1)Windo ...

  5. Eigen教程(5)

    整理下Eigen库的教程,参考:http://eigen.tuxfamily.org/dox/index.html 块操作 块是matrix或array中的矩形子部分. 使用块 函数.block(), ...

  6. log4e下载地址

    Log4e的插件的下载地址:log4e.jayefem.de/content/view/3/1/

  7. [转]启动Tomcat提示:指定的服务未安装

    原文地址:http://blog.csdn.net/yilip/article/details/8066246 新下载的Tomcat7.0 解压缩完了运行tomcat7.exe屏幕一闪就没了 运行to ...

  8. C语言 · x的x次幂结果为10

    如果x的x次幂结果为10(参见[图1.png]),你能计算出x的近似值吗? 显然,这个值是介于2和3之间的一个数字. 请把x的值计算到小数后6位(四舍五入),并填写这个小数值. 注意:只填写一个小数, ...

  9. C语言 · 最长公共子序列 · 最长字符序列

    算法提高篇有两个此类题目: 算法提高 最长字符序列   时间限制:1.0s   内存限制:256.0MB      最长字符序列 问题描述 设x(i), y(i), z(i)表示单个字符,则X={x( ...

  10. keras系列︱图像多分类训练与利用bottleneck features进行微调(三)

    引自:http://blog.csdn.net/sinat_26917383/article/details/72861152 中文文档:http://keras-cn.readthedocs.io/ ...