Results 1 to 7 of 7
  1. #1
    peterhabe is offline Member
    Join Date
    Jul 2010
    Posts
    43
    Rep Power
    0

    Default Problems with values that come from the JSlider

    I convert the value on the JSlider to a string using String.valueOf(JSlider.getValue()); but when i run the program with a a starting value other than 0 i get this error:
    Exception in thread "main" java.lang.IllegalArgumentException: invalid range properties
    at javax.swing.DefaultBoundedRangeModel.<init>(Unknow n Source)
    at javax.swing.JSlider.<init>(Unknown Source)♦

    Also I am also setting the value on the JSlider to a float but that isn't working properly eather, even if I convert the value of the JSlider to a string then a float.

    But this works fine: System.out.println(height.getValue());

    Can anyone help me?
    Last edited by peterhabe; 07-23-2010 at 03:03 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    What line in your source program causes this error? You left off the part of the error message showing the line number and class where the call was made.
    What are the values of the args in that statement?

  3. #3
    peterhabe is offline Member
    Join Date
    Jul 2010
    Posts
    43
    Rep Power
    0

    Default

    I've finally the solved the problem. Silly mistake which i've been trying to solve for like a week. Thanks for the reply anyway.

  4. #4
    nishchal6 is offline Member
    Join Date
    Aug 2012
    Posts
    8
    Rep Power
    0

    Default Re: Problems with values that come from the JSlider

    Hey That problem has already been solved by the following code:-

    try
    {
    cc=ClientCount.returncount();
    }catch(Exception e)
    {
    cc=0;
    }

    ts = new JScrollBar(JScrollBar.HORIZONTAL,cc , 1, 0, cc+1);
    ts.setUnitIncrement(cc-1);
    ts.setBlockIncrement(1);
    GridBagConstraints gbc_scrollBar = new GridBagConstraints();
    gbc_scrollBar.fill = GridBagConstraints.BOTH;
    gbc_scrollBar.gridwidth = gbc_scrollBar.REMAINDER;
    gbc_scrollBar.insets = new Insets(0, 0, 0, 0);
    gbc_scrollBar.gridx = 0;
    gbc_scrollBar.gridy = 5;
    contentPane.add(ts, gbc_scrollBar);
    ts.addAdjustmentListener(this);
    cc declared globally.

    Now can you tell me how to change the parameter values of JScrollBar dynamically as these values are already set and when the program is run the bar is not visible.
    Thanks

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Problems with values that come from the JSlider

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    nishchal6 is offline Member
    Join Date
    Aug 2012
    Posts
    8
    Rep Power
    0

    Default Re: Problems with values that come from the JSlider

    Thanks for the rules!

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. How to update JTextArea with JSlider Values
    By theen3my in forum AWT / Swing
    Replies: 7
    Last Post: 10-04-2009, 08:48 AM
  2. Jslider changeListner
    By Basit56 in forum Java Applets
    Replies: 1
    Last Post: 09-14-2009, 04:04 PM
  3. Replies: 5
    Last Post: 07-28-2009, 10:22 PM
  4. How can we zoom a map using JSlider
    By barney in forum AWT / Swing
    Replies: 5
    Last Post: 02-23-2009, 01:48 PM
  5. jmf & JSlider
    By nathanr_kamal in forum AWT / Swing
    Replies: 6
    Last Post: 06-28-2008, 07:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •