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 ...
随机推荐
- react-scripts的css modules
用create-react-app创建的项目基于react-scripts内建支持css modules,需要把css文件名改成filename.module.css,导入方式需要改成: import ...
- [Windows Azure] Windows Azure Virtual Network Overview
Windows Azure Virtual Network Overview 18 out of 33 rated this helpful - Rate this topic Updated: Ap ...
- 运行Virtualbox去安装系统时出错:Failed to open a session for the virtual machine,Unable to load R3 module xxxx/VBoxDD.DLL(VBoxDD)
貌似看到不少人(1,2,3),在使用Virtualbox去安装系统时,都遇到这个错误: 比如这里遇到的: 截图: 和另外这里的截图: 加文字描述: Failed to open a session f ...
- 通过kafka提供的命令来查看offset消费情况
使用kafka的bin目录下面的kafka-consumer-groups.sh命令可以查看offset消费情况,注意,如果你的offset是存在kafka集群上的,就指定kafka服务器的地址boo ...
- JAVA开发的23种设计模式之 --- 桥接模式
桥接模式 概述:将抽象部分与他的实现部分分离,这样抽象化与实现化解耦,使他们可以独立的变化.如何实现解耦的呢,就是通过提供抽象化和实现化之间的桥接结构. 应用场景 实现系统可能有多 ...
- 将String转换成InputStream
String str = "";//add your string contentInputStream inputStream = new ...
- Leetcode:【DP】Longest Palindromic Substring 解题报告
Longest Palindromic Substring -- HARD 级别 Question SolutionGiven a string S, find the longest palindr ...
- php连接oracle数据库
1.先安装一下oracle instant,把oci.dll所在的目录加入PATH环境变量里 或者直接安装oracle express php_pdo_oci 依赖于oracle 的oci.dll 2 ...
- Sublime Text 3安装与使用,安装插件,快捷键,默认配置
本文是Sublime Text 全程指引 by Lucida (http://www.cnblogs.com/figure9/p/sublime-text-complete-guide.html)的笔 ...
- 迭代器模式和组合模式(head first设计模式——8)
把迭代器模式和组合模式放在同一篇的原因是其联系比较紧密. 一.迭代器模式 1.1迭代器模式定义 迭代器模式提供一种方法顺序访问一个聚合对象中的各个元素,而不是暴露其内部的表示. 这个模式提供了一种方法 ...