Results 1 to 14 of 14
- 08-13-2012, 04:41 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 8
- Rep Power
- 0
Help with IllegalArgumentException: invalid range properties
Can anyone please help me, I am getting this error
Exception in thread "main" java.lang.IllegalArgumentException: invalid range properties
at javax.swing.DefaultBoundedRangeModel.<init>(Defaul tBoundedRangeModel.java:102)
at javax.swing.JScrollBar.<init>(JScrollBar.java:158)
at gui.MainWindow.<init>(MainWindow.java:333)
at communication.Provider.main(Provider.java:41)
and the error is in the first line of the following code--->
ts = new JScrollBar(JScrollBar.HORIZONTAL, ClientCount.returncount(), 1, 0, ClientCount.returncount());
ts.setUnitIncrement(ClientCount.returncount()-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);
I want to set the minimum position of the scroll bar as 0 and maximum value is ClientCount.returncount() which I get from this function.
and I implemented the Adjustmentevent as this:-
public void adjustmentValueChanged(AdjustmentEvent e) {
// TODO Auto-generated method stub
this.ax = e.getValue();
this.link();
repaint();
}
The current value which I am getting from e.getvalue() is of type Integer and I am putting this in variable ax.
So, do I have to convert this value or anything else.
- 08-13-2012, 04:59 PM #2
Re: Problems with values that come from the JSlider
what are the values of the range you are trying to set at line 333?Exception in thread "main" java.lang.IllegalArgumentException: invalid range properties
at javax.swing.DefaultBoundedRangeModel.<init>(Defaul tBoundedRangeModel.java:102)
at javax.swing.JScrollBar.<init>(JScrollBar.java:158)
at gui.MainWindow.<init>(MainWindow.java:333)
Use a println statement to print them out.If you don't understand my response, don't ignore it, ask a question.
- 08-13-2012, 05:17 PM #3
Member
- Join Date
- Aug 2012
- Posts
- 8
- Rep Power
- 0
Re: Problems with values that come from the JSlider
In the line 333, I am setting the unitIncrement of the scrollbar. For eg:- If the value of returncount() function is 50(which I am setting as the maximum value of the scrollbar), then the no. of increments of scrollbar should be 50-1 i.e. 49 and The value of the scrollbar, I am setting as this max value itself because I want the slider to be at the right position always.
I want to map these time values of the slider with the values of Hashmaps(which are storing the positions, headings and statuses of the robots), in such a way that if the slider is moved towards left(initially placed at rightmost point), then the robots should go backwards in their history of positions, like reverse paths.
- 08-13-2012, 05:26 PM #4
Re: Problems with values that come from the JSlider
In the stack trace: Line 333 looks like the constructor for JScrollBar: JScrollBar.<init> The <init> indicates a constructor.In the line 333, I am setting the unitIncrement of the scrollbar
What are the values passed in the JScrollBar constructor when the exception is thrown?If you don't understand my response, don't ignore it, ask a question.
- 08-13-2012, 05:52 PM #5
Member
- Join Date
- Aug 2012
- Posts
- 8
- Rep Power
- 0
Re: Problems with values that come from the JSlider
ts = new JScrollBar(JScrollBar.HORIZONTAL, ClientCount.returncount(), 1, 0, ClientCount.returncount());
ts.setUnitIncrement(ClientCount.returncount()-1);
ts.setBlockIncrement(1);
- 08-13-2012, 06:06 PM #6
Re: Problems with values that come from the JSlider
You've posted the code but have not shown what the values are when the program executes.
What are the numeric values that are used in the constructor? Add a println to print out the values returned by the methods called in the constructor.If you don't understand my response, don't ignore it, ask a question.
- 08-13-2012, 06:25 PM #7
Member
- Join Date
- Aug 2012
- Posts
- 8
- Rep Power
- 0
Re: Problems with values that come from the JSlider
I have checked through debugging that the value of count which is given by the function returncount() is 0.
Basically, the idea is that there is a function known as handleStateMessage() which handles the StateMessage if it is a part of Robot Message and updates the GUI and It also sets the current state received to the DataRobot.
I have implemented counter on this method. If this method is called say 50 times then the maximum value of scrollbar is 50 and the the no. of scrolls will be 49.
and also based on this counter value, I am setting the keys also in the Hashmap(50 keys again if this message is called 50 times).
- 08-13-2012, 06:33 PM #8
Re: Problems with values that come from the JSlider
0 is not a valid value. You make sure the value is not zero.value of count which is given by the function returncount() is 0.
This code executes without throwing an exception:
Java Code:new JScrollBar(JScrollBar.HORIZONTAL, 0, 1, 0, 1); //<<<<<<<< OK
Last edited by Norm; 08-13-2012 at 06:41 PM.
If you don't understand my response, don't ignore it, ask a question.
- 08-13-2012, 06:47 PM #9
Member
- Join Date
- Aug 2012
- Posts
- 8
- Rep Power
- 0
Re: Problems with values that come from the JSlider
Ya, I have checked it again, the value of count is =0.
I think the program terminates before this method handleStateMessage() is called, thats why the value is 0.
I have declared this variable(count) globally.
- 08-13-2012, 06:53 PM #10
Re: Problems with values that come from the JSlider
You'll have to check the program's logic to see why the value is 0.
If you don't understand my response, don't ignore it, ask a question.
- 08-13-2012, 06:58 PM #11
Member
- Join Date
- Aug 2012
- Posts
- 8
- Rep Power
- 0
Re: Problems with values that come from the JSlider
So what exactly u think the problem is?
U mean to say that the value of count should not be zero and if the method is called then this value will not be zero.
- 08-13-2012, 07:20 PM #12
Re: Problems with values that come from the JSlider
You will need to post the code if you want anyone to look at it and see why the value is 0 when the method is called.
The code that gives the variable a value needs to be executed BEFORE the value is used to create a JScrollBar.If you don't understand my response, don't ignore it, ask a question.
- 08-13-2012, 07:51 PM #13
Re: Help with IllegalArgumentException: invalid range properties
Above posts removed from Problems with values that come from the JSlider
nishchal6, next time you have a question, start a new thread. Don't bump a two year old thread and don't hijack another poster's thread.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 08-13-2012, 07:53 PM #14
Re: Help with IllegalArgumentException: invalid range properties
Quite apart from anything else, you shouldn't be running Swing code on the main thread.
Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Servlet, Glassfish JMS java.lang.IllegalArgumentException: MQ:Queue:Invalid Queue Nam
By akasozi in forum Java ServletReplies: 0Last Post: 05-27-2011, 08:46 AM -
IllegalArgumentException: adding a window to a container
By aborgeld in forum Advanced JavaReplies: 3Last Post: 03-24-2011, 06:18 AM -
JPA java.lang.IllegalArgumentException
By johnwcv in forum Advanced JavaReplies: 0Last Post: 03-17-2011, 10:17 PM -
Getting an IllegalArgumentException when using the replace() function
By Gorgro in forum AWT / SwingReplies: 1Last Post: 11-20-2010, 11:28 PM -
proper use of IllegalArgumentException
By vendetta in forum New To JavaReplies: 1Last Post: 01-16-2010, 07:43 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks