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