e797. showing tick marks on a jslider component.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 20 行
TXT
20 行
The slider supports two levels of tick marks, major and minor. Typically, the minor tick-mark spacing is smaller than the major tick-mark spacing. Also, the minor tick-mark spacing is a multiple of the major tick-mark spacing. However, the slider does not enforce any of these constraints.
// Create a horizontal slider that moves left-to-right
JSlider slider = new JSlider();
// Determine if currently showing ticks
boolean b = slider.getPaintTicks(); // false
// Show tick marks
slider.setPaintTicks(true);
// Set major tick marks every 25 units
int tickSpacing = 25;
slider.setMajorTickSpacing(tickSpacing);
// Set minor tick marks every 5 units
tickSpacing = 5;
slider.setMinorTickSpacing(tickSpacing);
Related Examples
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?