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 |
e792. 建立一个包括所有数据的SpinnerListModel的更多相关文章
- 通过myclipse建立一个简单的Hibernate项目(PS:在单元测试中实现数据的向表的插入)
Hibernate的主要功能及用法: Ⅰ.Hibernate封装了JDBC,使Java程序员能够以面向对象的思想对数据库进行操作 Ⅱ.Hibernate可以应用于EJB的J2EE架构,完成数据的持久化 ...
- 如何建立一个完整的游戏AI
http://blog.friskit.me/2012/04/how-to-build-a-perfect-game-ai/ 人工智能(Artificial Intelligence)在游戏中使用已经 ...
- jmeter 建立一个网络服务的测试计划
如何创建一个 测试计划 测试一个网络服务. 你会 创建5个用户发送请求到一页. 同时,你会告诉用户运行测试两次. 的总数 请求用户请求(5)x(1)x(重复2次)= 10 HTTP请求. 来 建立测试 ...
- Android在如何建立一个WebServer
今天老板交待任务最终完成了,感觉收获颇多,所以写一个关于它的记录,首先,看一下.老板的需求 需求: 希望移动端的用户标识(IMEI)和HTML页面的用户标识(Cookie)连接起来,当中HTML页面可 ...
- [渣译文] 使用 MVC 5 的 EF6 Code First 入门 系列:建立一个EF数据模型
英文渣水平,大伙凑合着看吧…… 这是微软官方教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译,这里是第一篇: ...
- C# Dictionary源码剖析---哈希处理冲突的方法有:开放定址法、再哈希法、链地址法、建立一个公共溢出区等
C# Dictionary源码剖析 参考:https://blog.csdn.net/exiaojiu/article/details/51252515 http://www.cnblogs.com/ ...
- 建立一个php 基础类
在些PHP文件的时候,一般首先都是要先写一下基础类: 主要包括以下几个方面: 1.服务器的链接:包括主机,用户名,密码 2.数据库的选择:要操作哪个数据库 3.字符集的设置:设置什么样的编码 4.查询 ...
- Rails 建立一个资源
在blog 应用程序中.你可以通过脚手架(scaffolded)开始建立一个资源. 这将是单一的blog 提交.请输入以下命令 $ rails generate scaffold Post name: ...
- 使用 MVC 5 的 EF6 Code First 入门 系列:建立一个EF数据模型
这是微软官方SignalR 2.0教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译,这里是第一篇:建立一个E ...
随机推荐
- vim学习笔记(11):vim 去掉<200b>
vim查看文件,发现多了<200b>字符,使用/200b搜索匹配不上:grep 200b 也匹配不上 查询后才知道:200b是:Unicode Character 'ZERO WIDTH ...
- MyBean - 单实例插件改进和VCL插件的改进
BeanFactory中添加VclOwners:TComponent属性, 在getBean创建VCL插件的时候,Tcomponent.Create(VclOwners) 这样在清理DLL时就会释 ...
- 【Java】Java复习笔记-第三部分
修饰符abstract 抽象的,定义框架不去实现,可以修饰类和方法 abstract修饰类: 会使这个类成为一个抽象类,这个类将不能生成对象实例,但可以做为对象变量声明的类型,也就是编译时类型 抽象类 ...
- Jackson 时间格式化,时间注解 @JsonFormat 用法、时差问题说明
https://www.sojson.com/blog/246.html ******************************************** Jackson 是 Spring ...
- jQuery弹性展开收缩菜单插件gooey.js
分享一款基于jQuery弹性展开收缩菜单插件gooey.js.这是一款基于gooey.js插件实现的弹性菜单特效代码.效果图如下: 在线预览 源码下载 实现的代码. html代码: <hea ...
- Android基础——使用Fragment适应不同屏幕和分辨率
最近事情很忙,一个新项目赶着出来,但是很多功能都要重新做,一直在编写代码.Debug.今天因为一个新程序要使用Fragment来做,虽然以前也使用过Fragment,不过没有仔细研究,今天顺道写篇文章 ...
- centosmini7安装GNOME
1.在命令行下输入下面的命令来安装 Gnome 包 #:$sudo yum groupinstall "GNOME Desktop" "Graphical Admini ...
- EF5.x Code First 一对多关联条件查询,Contains,Any,All
背景 通过多个部门id获取所有用户,部门和用户是多对多. 已知部门id,获取该部门包括该部门下的所有子部门的所有用户. 关系如下: public class Entity:IEntity { publ ...
- 在Linux下用make指令编译进度条程序。
首先建立一个新的文件,touch progress_bar.c 运行该vim progress_bar.c命令.写进度条的程序. 写进一个进度条程序: #include<stdio.h> ...
- android开发(33) 让 actionbar 透明2
让 actionbar 的背景 透明 我需要一个 透明的actionbar ,找到如下方法实现: 1. 首先,设置ActionBar 浮动到主界面上来. 2. 然后,设置ActionBar的背景色,透 ...