Why is the scale and numbers not shown in JSlider? Only the slider is displayed. In the program, the slider should display both. Here is the code:

public class Test extends JFrame { Test(){ JToolBar tb = new JToolBar("Панель ирструментов", JToolBar.HORIZONTAL); add(tb, BorderLayout.NORTH); JSlider sl = new JSlider(JSlider.HORIZONTAL, 0, 20, 6); sl.setPaintTicks(true); sl.setPaintLabels(true); sl.setPaintTrack(true); tb.add(sl); this.setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } 

I repeat, the slider is displayed, but the scale and numbers for some reason are not.

    1 answer 1

    The question was solved by adding

     sl.setMinorTickSpacing(2); sl.setMajorTickSpacing(6);