This example demonstrates how to display labels (numerical values) at the major ticks (see e797 显示JSlider的标记).

    // Create a horizontal slider that moves left-to-right
JSlider slider = new JSlider(); // Set major tick marks every 25 units
int tickSpacing = 25;
slider.setMajorTickSpacing(tickSpacing); // Determine if currently painting labels
boolean b = slider.getPaintLabels(); // false // Paint labels at the major ticks - 0, 25, 50, 75, and 100
slider.setPaintLabels(true);

The slider allows you to use an arbitrary label at any particular major tick mark. This example configures a slider that shows an icon at the minimum and maximum positions. The component is only used to render the label and so it can be used at more than one position. Unfortunately, it also means that if the component is interactive (e.g., a button), it will not respond to mouse and keyboard gestures.

    // Retrieve current table
java.util.Dictionary table = slider.getLabelTable(); // Create icon
ImageIcon icon = new ImageIcon("icon.gif");
JLabel label = new JLabel(icon); // Set at desired positions
table.put(new Integer(slider.getMinimum()), label);
table.put(new Integer(slider.getMaximum()), label); // Force the slider to use the new labels
slider.setLabelTable(table);
Related Examples

最新文章

  1. selenium自动化基础知识
  2. angular学习笔记(二十八-附2)-$http,$resource中的promise对象
  3. linux回退到上次访问目录
  4. java-访问权限
  5. SQL 数据类型,增删改查语句
  6. 转摘:常用ubuntu 关机,重启,注销命令
  7. JQ模仿select
  8. CentOS7安装完毕,重新开机启动后显示: Initial setup of CentOS Linux 7 (core)
  9. PHP连接数据库、创建数据库、创建表的三种方式
  10. vue路由跳转时判断用户是否登录功能
  11. Maven学习(四)-- Maven的核心概念
  12. 树状数组 || JZOI 1024. @szefany 的树
  13. Win2008 IIS7.5安装配置PHP7.3.2步骤,及500错误解决
  14. 黄聪:Windows2012-IIS8安装SSL证书
  15. python 十大web框架排名总结
  16. spring cloud/spring boot同时支持http和https访问
  17. Atitit 列表表格按照字段排序数据解决方案
  18. tile38 roaming-geofences 试用
  19. UVA 12436 - Rip Van Winkle's Code(线段树)
  20. Hive 打开调试模式

热门文章

  1. (原创)用c++11打造好用的variant
  2. (原创)C++11改进我们的程序之简化我们的程序(三)
  3. C#之Console
  4. 【delphi】多线程同步之Semaphore
  5. Android.mk高级写法
  6. 组策略分发Adobe Reader 11教程
  7. 详解Android开发中Activity的四种launchMode
  8. combbox选中新添加的数据
  9. C#学习笔记(21)——C#获取文件夹下的所有文件的文件名
  10. Mysql注入绕过姿势