Here you can find the source of makeLabelSliderPanelHorizontal(String text, JSlider slider)
Parameter | Description |
---|---|
text | a slider description |
slider | a JSlider |
public static JPanel makeLabelSliderPanelHorizontal(String text, JSlider slider)
//package com.java2s; import java.awt.Dimension; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; public class Main { public final static Dimension largeDescriptionsSize = new Dimension( 140, 24);//from www .ja va 2 s .c o m /** * Returns a JPanel object containing a slider with description. * * @param text a slider description * @param slider a JSlider * * @return a JPanel object containing a slider with description. */ public static JPanel makeLabelSliderPanelHorizontal(String text, JSlider slider) { JPanel panel = new JPanel(); JLabel label = new JLabel(text, JLabel.RIGHT); label.setMinimumSize(largeDescriptionsSize); label.setPreferredSize(largeDescriptionsSize); label.setMaximumSize(largeDescriptionsSize); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.add(label); panel.add(Box.createRigidArea(new Dimension(10, 0))); panel.add(slider); return panel; } }