e798. 显示JSlider的标记标签
显示 标签 标记
2023-09-14 09:11:59 时间
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 |
相关文章
- 只用乐高积木做一个计算机系统!能显示滚动文本和扫描雷达图,作者还给它写了程序
- 显示隐藏高德地图点标注的文本标签「建议收藏」
- 【目标检测】YOLOv5:标签中文显示/自定义颜色
- Linux last命令:显示用户或终端的登录情况
- 怎么判断摄像头开没开_qt获取控制台输出并显示
- wordpress tags标签改造id显示加后缀html显示
- 【CSS】标签显示模式 ② ( 行内元素 | 行内块元素 )
- 【CSS】标签显示模式 ④ ( 标签显示模式示例 | 设置行内元素宽高 | 设置鼠标经过样式 | 设置文字水平居中 | 设置文字垂直居中 | 文本行高与盒子高度关系 )
- MySQL BLOB字段如何使用与显示(mysqlblob显示)
- 更新:已解除 | 微信疑似封杀必应搜索 内置浏览器加载必应显示被多人投诉
- 代码显示:苹果 iOS 15 系统将支持面部识别验证身份证
- Firefox 91.0.1发布:修复常规浏览窗口显示隐私窗口标签页的问题
- 数组显示菜单效果
- jQuery的显示和隐藏方法与css隐藏的样式对比
- jquery隐藏标签和显示标签的实例
- jquery通过visible来判断标签是否显示或隐藏
- jquery隐藏与显示tr标签示例代码
- js使用html()或text()方法获取设置p标签的显示的值