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. SSH登录详解

    1.什么是SSH登录 SSH是一种网络协议,用于计算机之间的加密登录. 相比传统的账户密码登录,SSH提供了一种更便捷安全的登录方式. 2.SSH登录流程 登录操作如下 ssh user@host S ...

  2. 【DIOCP3-说明书】DIOCP3的输出日志

    DIOCP3除了有详细的监控面板之外,还有详细的输出日志,当然需要打开日志编译开关! 在工程选项加入DEBUG编译指令,这样在运行中就可以看到DIOCP3的运行详细日志 日志输出在EXE相同目录的LO ...

  3. FFmpeg Basics学习笔记(1)ffmpeg基础

    1 FFmpeg的由来 FFmpeg缩写中,FF指的是Fast Forward,mpeg是 Moving Pictures Experts Group的缩写.官网:ffmpeg.org 编译好的可执行 ...

  4. c++ primer读书笔记之c++11(三)

    1 =default构造函数限定符 c++11针对构造函数提供了=default限定符,可以用于显式指定编译器自动生成特定的构造函数.析构或赋值运算函数.参考代码如下: class CtorDftTy ...

  5. 解决opencv和mfc同时使用导致memory leak

    参考资料:http://blog.csdn.net/lujin0312/article/details/42214467 最彻底的解决办法就是把用到opencv的部分做成dll,且这个dll中不出现跟 ...

  6. 【Miktex】使用教程以及数学符号整理总结

    LaTeX是当今世界上最流行和使用最为广泛的 TeX格式.它构筑在 Plain TeX的基础之上,并加进了很多的功能以使得使用者可以更为方便的利用 TeX的强大功能.使用 LaTeX基本上不需要使用者 ...

  7. idea svn 使用问题

    一开始死活提交不上 解决方式 : 勾上use command line client

  8. 正则表达式-python-无捕获分组与分支选择

    无捕获分组 当你要将一部分规则作为一个整体对它进行某些操作,比如指定其重复次数时,你需要将这部分规则用 (?:) 把它包围起来. 分支条件 在正则表达式中,分支条件是一个很常用的条件. 满足条件A 或 ...

  9. Unable to locate \.nuget\NuGet.exe 问题解决办法之一(转)

    问题出现的原因是项目下.nuget文件夹下NuGet.exe文件夹不存在导致的 解决办法: 1.右键编辑NuGet.targets文件 将下载NuGet.exe的配置节点DownloadNuGetEx ...

  10. CAS (11) —— CAS TicketRegistry使用Ehcache的集群方案

    CAS (11) -- CAS TicketRegistry使用Ehcache的集群方案 摘要 CAS TicketRegistry使用Ehcache的集群方案 版本 tomcat版本: tomcat ...