title: Java: Using Constructor for JSlider
body: <p>I am trying to build a panel in Java. The panel should have (among other things) a slider/JSlider. </p>
  
  <p>Below is the class file for my JSlider. I would like to use the constructor to set the options for the slider.</p>
  
  <p>I tried used a string hOrV (horizontal or vertical) to set the slider to JSlider.HORIZONTAL. This does not seem to work (the argument accepts an int, not a string).</p>
  
  <p>In fact, no part of the constuctor seems to work when I call it in the other class.</p>
  
  <p>None of the arguments seem to be passing to the constructor, can anyone help? Thanks ahead!</p>
  
  <pre><code>import javax.swing.*;
  import javax.swing.event.*;
  
  public class ScrollBar extends JSlider
  {
  
  private JSlider slider;
  
  public ScrollBar(String hOrV, int min, int max, int start)
  {
  
  //slider = new JSlider(JSlider.HORIZONTAL, min, max, start); //didn't work
  slider = new JSlider(hOrV, min, max, start);
  
  add(slider);
  
  }
  
  
  //This is the call in my other class file
  slider = new ScrollBar("JSlider.HORIZONTAL", 0, 50, 10);
  
  //I have also tried:
  slider = new ScrollBar(0, 50, 10); // with public ScrollBar(int min, int max, int start) as my constructor
  slider = new ScrollBar(0, 0, 50, 10); //with public ScrollBar(int hOrV, int min, int max, int start) as my constructor
  </code></pre>