Java JSlider makeLabelSliderPanelHorizontal(String text, JSlider slider)

Here you can find the source of makeLabelSliderPanelHorizontal(String text, JSlider slider)

Description

Returns a JPanel object containing a slider with description.

License

Open Source License

Parameter

Parameter Description
text a slider description
slider a JSlider

Return

a JPanel object containing a slider with description.

Declaration

public static JPanel makeLabelSliderPanelHorizontal(String text,
        JSlider slider) 

Method Source Code

//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;
    }
}

Related

  1. buildIntegerFieldWithSlider(final JSlider matchingSlider)
  2. createJSlider(final BoundedRangeModel model)
  3. createLabelField(String preText, String postText, JSlider s)
  4. createSliderPanel(final JSlider slider, String label, int width)
  5. fixWinSliderUI(JSlider s)
  6. reapplyFontSize(JSlider slider)
  7. setMinMaxSliderLabels(JSlider slider, String[] labels)
  8. setSliderLabels(JSlider slider, int[] values, String[] labels)
  9. setSliderPercent(JSlider s, double percent)