سؤال

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

هل كانت مفيدة؟

المحلول

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).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top