Question

How can we make the following picture in Java Swing? I have used JSlider for a slider, but any idea how to draw an LCD Number displaying the value of the slider?

enter image description here

Was it helpful?

Solution

Make a JPanel and add a JLabel to it. You may need to specify the font of the JLabel, and override the paintComponent(Graphics g) method of the JPanel to get it to look like you want.

The value of the JLabel is the value is the JSlider. You may need to force a repaint of the JLabel if the JSlider is moved (use an ActionListener on the JSlider for this).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top