Here you can find the source of createLabelField(String preText, String postText, JSlider s)
public static JPanel createLabelField(String preText, String postText, JSlider s)
//package com.java2s; //License from project: LGPL import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; public class Main { public static JPanel createLabelField(String preText, String postText, JSlider s) { JPanel p = new JPanel(); JSpinner spin = new JSpinner(new SpinnerNumberModel(s.getValue(), s.getMinimum(), s.getMaximum(), 1)); spin.addChangeListener(ce -> { s.setValue((Integer) spin.getValue()); });/* www .j a va 2 s. c om*/ p.add(new JLabel(preText)); p.add(spin); p.add(new JLabel(postText)); return p; } }