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

e798. 显示JSlider的标记标签的更多相关文章

  1. e797. 显示JSlider的标记

    The slider supports two levels of tick marks, major and minor. Typically, the minor tick-mark spacin ...

  2. HTML学习-2标记标签-2

    三.表单元素 ①<form></form>表单标签,代表表单 主要属性:1.action提交到的页面.   2.method数据提交方式(get显示提交,有长度限制.post隐 ...

  3. java continue break 关键字 详解 区别 用法 标记 标签 使用 示例 联系

    本文关键词: java continue break 关键字 详解 区别  用法 标记  标签 使用 示例 联系   跳出循环 带标签的continue和break 嵌套循环  深入continue ...

  4. /.nav-tabs :是普通标签页 .nav-pills:胶囊式标签页 action ;默认的激活项,给<li>加默认显示的是哪个标签页内容 .nav是标签页的一个基类,给ul加 .nav-stacked: 垂直排列BootStrap

    <meta name="viewport" content="with=device-width, initial-scale=1, user-scalabe=no ...

  5. HTML学习-2标记标签-1

    大致可以分为以下6类学习: 1.通用标签. 2.常用标签. 3.表格标签. 4.表单元素. 5.框架. 6.其他. 一.通用标签.及属性 1.<body></body>标签,主 ...

  6. eclipse不显示Android SDK Manager标签

    新版的eclipse配置好android开发环境后没有显示在window菜单里显示Android SDK Manager,也没有在工具栏里出现android的工具图标.但可以通过android sdk ...

  7. flex学习笔记 使用函数,显示实时更新的标签

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  8. HTML入门(三)后台系统显示页面_框架标签

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. e799. 限制JSlider的数值在标记以内

    By default, the slider can take on any value from the minimum to the maximum. It is possible to conf ...

随机推荐

  1. python管道pipe

    1.什么是管道 Linux进程间通信方式的一种,管道有两端,读端和写端.创建管道,然后从父进程fork出子进程, 父进程和子进程拥有共同的读写文件描述符,可以实现子进程写文件,父进程读文件的操作. 示 ...

  2. 使用nginx搭建tomcat集群配置

    软件准备: (1)jdk-8u73-linux-x64.tar.gz (2)apache-tomcat-7.0.57.tar.gz (3)nginx-1.7.7.tar.gz 准备3台Linux机器, ...

  3. Eclipse 使用 SVN 插件后修改用户方法汇总

    http://blog.csdn.net/ShaneLooLi/article/details/50994005 ******************************************* ...

  4. 【Python】京东商品价格监控

    import requests,json,re,winsound,time class Stock(object): def __init__(self): self.province_dict={v ...

  5. kali kvm Requested operation is not valid: network 'default' is not active

    安装时候参考的:http://www.ilanni.com/?p=6101 今天安装完kvm,满是幸福的装了个xp,重启后出现了一个错误 Requested operation is not vali ...

  6. DLL封装Interface(接口)(D2007+win764位)

    相关资料: http://blog.csdn.net/liangpei2008/article/details/5394911 结果注意: 1.函数的传参方向必须一至. DLL实例代码: ZJQInt ...

  7. 2017 码云最火爆开源项目 TOP 50,你都用过哪些

    本文转自:https://share.html5.qq.com/fx/u?r=JdjvzwC 2017 年度码云热门项目排行榜 TOP 50 出炉啦!我们根据所有开源项目在码云的用户关注度.活跃度.访 ...

  8. 【Android】Android6.0读取通话记录

    需求:读取通话记录,然后列表显示,每条记录的数据包括姓名.号码.类型(来电.去电.未接,字体颜色分别为绿.蓝.红),然后长按条目弹出一个列表弹窗,显示[复制号码到拨号盘].[发短信].[打电话]. 先 ...

  9. Mongo分片集群脚本

    bash大法好啊,一键玩mongo. 我的mongo版本是:MongoDB shell version v4.0.2 这里准备为大家献上Mongo创建分片和可复制集的脚本,以及在部署的时候踩的坑. 分 ...

  10. Deepin Linux已经做得相当不错了

    很庆幸,用了MacBook Pro三四年后,还会想要用Linux做桌面,一方面说明自己还是年轻的,保持着愿意折腾的心态:另一方面,也确实发现macOS的桌面环境并不如传说中的稳定和好用. Deepin ...