Rajesh Radh

Ranch Hand
+ Follow
since Mar 18, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rajesh Radh

Hi,
I am using ensureIndexIsVisible as follows in a constructor. But this does not seems to work. But when I use ensureIndexIsVisible after setVisible(true) in main method, then it works! Why is it like this. In my application, I cannot use JFrame. I have only the liberty to use a JPanel. Therefore I need this method working at place (1). could you please let me know what else I need to do to get this method working at place (1)

thanks,
Rajesh
23 years ago
Hi,
I am using ensureIndexIsVisible as follows in a constructor. But this does not seems to work. But when I use ensureIndexIsVisible after setVisible(true) in main method, then it works! Why is it like this. In my application, I cannot use JFrame. I have only the liberty to use a JPanel. Therefore I need this method working at place (1). could you please let me know what else I need to do to get this method working at place (1)

thanks,
Rajesh


[This message has been edited by Rajesh Radh (edited June 21, 2001).]
[This message has been edited by Rajesh Radh (edited June 21, 2001).]
23 years ago
thanks for your reply.
My understanding is that JList uses Viewport view of JScrollPane for its scrolling purpose. I did not understand your quote "try changing JScrollPane to JViewport...". JViewport has only one constructor?
As per Java API,
"JList doesn't support scrolling directly. To create a scrolling list you make the JList the viewport view of a JScrollPane, e.g.
JScrollPane scrollPane = new JScrollPane(dataList);
// Or in two steps:
JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().setView(dataList);"
By several trail and error, I found out that ensureIndexIsvisible(int index) works only when invoked from within a listener method! In order to get the result I had to put this method in windowOpened() method that is attached to a JFrame that holds my MonthRoll component. But the component I am developing is not supposed to be attached to a JFrame but only to a JPanel. Therefore I need to figure out how can I make ensureIndexIsVisible() working outside of a listener method!


[This message has been edited by Rajesh Radh (edited May 28, 2001).]
23 years ago
I am trying to display the desired month using ensureIndexIsVisible() method from a JList. But my JList always displays the value at index 0. Could you please let me know how could I use ensureIndexIsVisble(int) method working for me?

23 years ago
Thank you Sanjay.
But I was trying to find out a different thing for a specific purpose. I Have a JList that is attached to a JScrollPane. The JScrollPane uses an inner class called ScrollBar(subclass of JScrollBar) to handle its scrolling needs. The associated UI with JScrollBar, which is BasicScrollBarUI uses an inner class, called ArrowButtonListener. I wanted to find out when user clicks on the JScrollPane's, which arrow button user clicks, i.e. up /down arrow associated with a scrollbar (please do not confused with keyboard up and down arrow). I know I can subclass the BasicScrollBarUI class and add functionality to get it. I wanted to find out if there is any easy way to do it?
Please any one?
Thanks,
Rajesh
23 years ago
Hi,
Is there any method that gives me the "direction" (Positive /Negative) in which the ScrollBar is moving. I looked into BasicScrollBarUI class, there are two constants POSITIVE_SCROLL and NEGATIVE_SCROLL. But I need to know from an instance of a ScrollPane class, whether user clicked POSITIVE_SCROLL or NEGATIVE_SCROLL. Please help me.
Let me explain what I am trying to do. I have defined an array of length 12. This array contains values {"Jan", "Feb"� , "Dec"}. When my scroll-point is at "Dec", a POSITIVE_SCROLL must display "Jan" (I am trying for circular scrolling!). Similarly, When my scroll-point is at "Jan", a NEGATIVE_SCROLL must display "Dec". Does anyone know if there is a class that does this already?

Thanks,
23 years ago
Congrats to All!
Rajesh
Rita,
Did you hear from Roseanne Zhang on study groups?
Does Roseanne use JavaRanch's thread to communicate among members of the study group or some other ways? Thread's can run into pages easily and tracking information becomes a headache . Do you have any other idea for better communication among group members?
I could not start "learning XML" yet. I am "required" to learn Rational Rose for my project within a short period . But that's life!
I have allocated 3 hours per day for XML from tomorrow. Otherwise I will be keep on postponing it.
Thanks,
Rajesh
[This message has been edited by Rajesh Radh (edited March 29, 2001).]

does that mean a static method can access non-static local variables??
Hima,
1) The static/non-static modifiers does not applies to local variables.
2) local variables scope is local, and does not exist after the method is executed. (With the introduction of inner classes, this is not completely true. Because final local variables used by local inner classes can exists even after method completes its execution!)
Best wishes!
Rajesh
1) Do arithmatic operators have same level of precedence? */%
Let me reformat your question. Do arithmetic operators *, /, and % have same level of precedence? Yes. But they are evaluated from left-to-right.
2) I doubt a is not an Anonymous class beacause it doesnot have a name. Can interfaces be instantiated? If no then howcome in this example?
Variable a is a local variable that has a value, which is reference to an instance of an inner class. The class of this object is anonymous. Interface cannot be instantiated. As you see here, this anonymous class extends Object class and implements Runnable interface.
I hope I cleared your doubts.
Rajesh

[This message has been edited by Rajesh Radh (edited March 28, 2001).]
Preeti,
"so i need not select any of them in case of a ques appear on keywords.are u sure???"
I did not understand your question well. I would not chose true/false/null as keywords in the real exam. Because, Sun knows better than us that they are not technically keywords.
Rajesh.

Originally posted by preeti dengri:
hi rajesh,
so i need not select any of them in case of a ques appear on keywords.are u sure???
thank you


Preeti,
The local variable declaration statement may or may not have initialization statement. If a local variable decalration does not have an initialzation, then compiler must prove that, according to the rules of definite assignment, every reference to this variable is preceded by an assignment to it.
In the example given by you, when "else part" was commented out, the compiler knew that assignment to local variable takes place only when condition was true, (i.e for n> 0). in all other cases, assignment was not taking place. This is not sufficient in case of local variables.
On the other hand, when else part was not commented out, compiler knows that whether or not condition is true or false, assignment takes place always.
If you want to go further and experiment, I would ask you to see what happens when following code is executed.
... //rest of your code
String tm;
if (true)
tm = "positive";
System.out.println(msg+tm);
... //restof your code
Do you think that this will compile? Sure it will! Because we used "true" (which is a literal constant that has a value = true always) as the conditional expression and compiler knows that assignment will take place always in this case.
I hope I cleared your doubts. If you have any further questions, please feel free to post them here.
Thanks,
Rajesh
[This message has been edited by Rajesh Radh (edited March 28, 2001).]
[This message has been edited by Rajesh Radh (edited April 04, 2001).]
In Java language, true and false are not (technically) keywords. They are called boolean literals. null is also not a keyword but a special literal called null literal.
But const and goto are keywords. They are not used in Java but reserved by Java. This helps a Java compiler to produce better error messages if these C/C++ keywords incorrectly appear in Java program.
I hope this helps.
Rajesh

[This message has been edited by Rajesh Radh (edited March 28, 2001).]
[This message has been edited by Rajesh Radh (edited April 04, 2001).]
Hema,
Thanks for the info. I will see that I am posting only XML related queries in this Thread. Thanks for bringing this to my attention.
Rajesh
Hi All!
I took a dayoff from javaranch. I was going through Java Swing by Robert Eckstein (O'Reilly). My confidence is boosting up. I can do it from Monday!
Ajith, like Rita said, you are a treasure. There is no doubt! but I have decided not to go thru the questions that you posted at least for this week! That might distract me from what I am doing now, "Learning Swing". (Because as I said earlier, I need to start working on swing from next Monday ). I will start XML from next week. No doubt!
But I have a question. Though, the book "Java Swing by Robert Eckstein" is a good one, it was published in 1998. The author himself states that some of the terminologies and class names might be different from what is being used now. Because he wrote this when Swing was evolving and Sun was keep on changing the names then. My job is going to API docs for further checking. Do you know any latest books by O'Reilly or any other good book? I got time (10 days) to return and get a new one from B&N.
Thank you All for helping me.
Rajesh