Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"

Sam Pereira

+ Follow
since Jun 05, 2014
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sam Pereira

Not sure if it would work Thanks for the help
4 years ago
I am learning applets and this is what was asked to do.So have to include a applet
4 years ago
I have a site which is run on localhost.

Although the applet connects to a access database when it is not inside the web page it doesn't get connected to the database while on localhost.I read the answer in webpage
and with the link
I tried to change the policy tool.Since I don't know much about policy tool I am finding it difficult to follow the instructions.
First of all I have java in `Program Files` and `Program Files(*86)`.

C:\Program Files\Java\jdk1.7.0_45\jre\lib\security

I changed the java.policy by adding

But the problem is, as mentioned in the article though I went to `C:\Program Files\Java\jre7\lib` it doesn't have a `security ` folder.

So I then tried program files (*86).In it I went to `C:\Program Files (x86)\Java\jre7\lib\security` and changed the policy tool as

I don't know whether to include that code or this

In program files (*86) I don't have the path mentioned in the article

`J:\Program Files\java\jdk1.8.0_25\ \jre\lib\security` as there's no jdk file in it.

Can't this policytool be done by in cmd->policytool->add policy entry->add permission->all permission->save as->jdk1.7.0_51\jre\lib\security\java.policy

Even this doesn't work.Can someone please tell me how I can set the policytool
4 years ago
I want to have a simple web page with fields for userName and password.Once a user enters the correct userName and password and press logIn button then it should display an applet.
Here's my code.

Right now it gives an error as and it doesn't open up a applet even when correct username and password has been entered.

Can someone please tell me how to correct this?
4 years ago
I am using gridBagConstraints.HORIZONTAL
4 years ago
I want to create 3 JTextFields in a row with all being of equal size.But my first Text field gets so wide than the other two.After adding each component at a time and seeing what causes the problem I realized that if I type a long text for the JLabel that's when this problem occurs.If I reduce the length of the text in the JLabel JTextFields get into the sizes I want.Here's my code

How can I stop the JTextFields changing size when I change the JLabel label1's text length
4 years ago
Thank you.The function
worked the trick.But from main method I have to call h3(). not h()
4 years ago
after evaluating (h(n-h(i)-1)+h(n-2)) I get a value right.For that I want to add 3.
What my code does it every time the function is recursively called in order to evaluate (h(n-h(i)-1)+h(n-2)) each time a 3 is added.So if the function is recursively called 4 times 3 is added 4 times where as I only want just one 3 added to the answer produced by (h(n-h(i)-1)+h(n-2))
4 years ago

The problem is say if I initially want to evaluate h(4).Then (h(n-h(i)-1)+h(n-2))would give 0.Then for that answer I want to add 3.But what happens is every time the function is recursively called a 3 is added giving me 12(function is called 4 times recursively.At each call 3 is added).How can I stop this and make the function so that after evaluating it adds 3 to the result of yielding 3 as the final result before returning.
4 years ago
I don't understand how it becomes Recurse RightMax: 1, 1 .Because prior to this it was Recurse LeftMax: 0, 0 .That is low=0,high=0.Then if rightmax is called since it is rightmax=max(a,mid+1,high) and thus it should be max(1,0).right? How does it become Recurse RightMax: 1, 1 .If I can understand this this part I think I am fine.So can you please explain this part
5 years ago
I understand up to the point "The processor will be back to max(a,0,1) where it will compare leftmax and rightmax and returns the greater value to its aboce level function i.e. max(a,0,2)..
".But shouldn't the compared value be returned to max(a,0,1).Because that's the level waiting for a value.I did use print statements before posting to understand what's happening.But couldn't understand that after returning the value 23 that what happens is the processor goes back to the the max (a,0,1) where it calls max(a,1,1) to calculate rightmax.
5 years ago
Can someone please explain how the recursion works.I tried to figure out writing down low,mid,high at each recursive call.But I seem to be making a mistake somehow.Can some one please show me the steps.Also I don't understand where the values are returned to in

Here's the code:

firstly leftmax=max(a,0,4)
Then what is the next line executed?Is it rightmax=max(a,5,8).
After this is it leftmax=max(a,5,6)

I tried to understand what these recursion calls by writing them down.But I somehow make a mistake.If someone can show me step by stepwhat happens here it would be greatly helpful
5 years ago