Example usage for javax.swing JSlider setOpaque

List of usage examples for javax.swing JSlider setOpaque

Introduction

In this page you can find the example usage for javax.swing JSlider setOpaque.

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:test.uk.co.modularaudio.util.swing.lwtc.TestShowLWTCSliderComparison.java

public void go(final int orientation) throws Exception {

    final JSlider testSwingJSlider = new JSlider(orientation);
    testSwingJSlider.setOpaque(false);

    final BoundedRangeModel defaultSwingSliderModel = testSwingJSlider.getModel();
    log.debug("Default swing slider model is " + defaultSwingSliderModel.toString());

    final JFrame f = new JFrame();

    f.getContentPane().setBackground(Color.decode("#3a5555"));

    final MigLayoutStringHelper msg = new MigLayoutStringHelper();
    //      msg.addLayoutConstraint( "debug" );
    msg.addLayoutConstraint("fill");
    msg.addLayoutConstraint("insets 0");
    msg.addLayoutConstraint("gap 0");
    if (orientation == SwingConstants.VERTICAL) {
        msg.addColumnConstraint("[][grow][grow][]");
        msg.addRowConstraint("[][grow][]");
    } else {/*from w ww . j a  va  2 s. co  m*/
        msg.addColumnConstraint("[][grow][]");
        msg.addRowConstraint("[][grow][grow][]");
    }
    f.setLayout(msg.createMigLayout());

    f.add(new JLabel("o"), "center");
    f.add(new JLabel("o"), "center");
    if (orientation == SwingConstants.VERTICAL) {
        f.add(new JLabel("o"), "center");
    }
    f.add(new JLabel("o"), "center,wrap");

    f.add(new JLabel("o"), "center");
    if (orientation == SwingConstants.VERTICAL) {
        f.add(verticalKnobContainer, "center, grow");
        f.add(testSwingJSlider, "center, grow");
    } else {
        f.add(horizontalKnobContainer, "center, grow");
    }
    f.add(new JLabel("o"), "center,wrap");

    if (orientation == SwingConstants.HORIZONTAL) {
        f.add(new JLabel("o"), "center");
        f.add(testSwingJSlider, "center, grow");
        f.add(new JLabel("o"), "center, wrap");
    }

    f.add(new JLabel("o"), "center");
    if (orientation == SwingConstants.VERTICAL) {
        f.add(new JLabel("o"), "center");
    }
    f.add(new JLabel("o"), "center");
    f.add(new JLabel("o"), "center");

    f.pack();

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            f.setVisible(true);
        }
    });
}