Domanda

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

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top