son dunckley

Greenhorn
+ Follow
since Jul 27, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by son dunckley

Thanks for the response. I have tried using the for loop only but it then displays the whole array.

What I am trying to do is, if the nums array contained [15,17,16,25,22]
and the user was looking for [16]. I would like to search the array and then stop at 16 and add all those previous numbers to the vector, so it would contain:

15,17,16

including the one they were looking for.

Does that make more sense?

Its just I need to be able to inform the user the best search root if they didn't take it.

Thanks
18 years ago
Hi

I am having a bit of trouble with a do while loop. I either can't get it to stop, or it doesn't do exactly as I need it to.

I am using a array called nums to insert random numbers into a binary search tree. Once the tree has been created I need to create a method to search the nums array looking for the node I have asked the user to find in the tree. Once it finds it I need it to output the nodes in that order into a vector.

Sometimes I ask for a node which is not in the tree - this is represented by the outCome. 0 if it is in the tree and 1 if it is not.

I'm attempting to do the first part, if the node is in the tree and have tried creating the following method. Currently it just loops. Can someone tell me how to tell it to stop?

Also, could you help me with telling it to only add nodes until it reaches the node they are searching for, represented by searchValue.




hope someone can help me with this, its driving me and the program loopy
18 years ago
Hi Stuart

I finally got it to display. It was the setbounds for the scrollpane which needed altering and now once I add enough text to warrant a scrollbar it appears. Fantastic , thanks for your help
18 years ago
Hi Stuart

Thanks very much for your reply. I adjusted that line but it then meant the instructionpanel didn't display at all. So I added it back and then added a new line to add the slider.

Still not showing though. Can you enlighten me a bit more?

new code is:



cheers
18 years ago
Hi

I have a JTextpane where i will be adding instructions. I know this will not be large enough, but there is no further space on my interface, so I need to add either a scrollbar or scrollpane.

I have tried a few attempts at this but cannot get either to appear. Can anyone help me with this?

Should I be using a scrollbar or scrollpane for a textpanel?

I just need it so the user can scroll down the text which isn't visible.



I did read somewhere that the scrollbars will appear when the preferred size of the panel is greater than the size of the pane, but couldn't set this up.

Is it that I should use a JTextArea instead of a JTextPane?

Any pointers would be appreciated
18 years ago
Hi

On my interface I have a help button and I was hoping to add a popup window with some hints inside it, whenever a user clicks on the help button.

Is this the way most people would deal with a help button?

Also, could anyone point me in the right direction for this? where can i get started with this as I have been unable to find specific examples to do this.

I just want to have a new window and add some text to it, and for the user to be able to close the window when they're ready to continue with the game.

Hope someone can point me in the right direction with this as the books and sites I have visited haven't been very clear(at least to me anyway!).

Thanks very much
18 years ago
Hi Michael

That looks like an excellent idea - exactly what I was hoping to be able to do but didn't know how.
18 years ago
Thanks very much for the replies. I will look into those and see if I can get it working - will be back if I can't !

The difference for the buttons is a tree is generated as soon as the applet is started, when they 'start search' button is selected - the tree is displayed. Once it is on display the button changes to 'New Search' - I then need to be able to call the methods for generating a new tree and then displaying it so the second call to the button does a little bit more. Hope that my question makes a bit more sense now - sorry i didn't explain it properly the first time round.

Cheers
[ August 06, 2005: Message edited by: son dunckley ]
18 years ago
Hi

I have created a button 'Start Search' and when you click on it, a Binary Search Tree is displayed.

However, I would also like this button to then change to 'New Search' - I have done this by just changing its label text when the button is clicked.

Now I want to set it up so that if 'New Search' button is clicked it generates a new tree but I don't know how to tell the actionPerformed method that this button is being clicked a second time(or as the New search button) so now do a different set of instructions.

Am I approaching this wrong? Should I actually create a brand new button once the 'new search' button is clicked and place it in the same area, then I can call the 'new search' button.

Hope someone can help me with where to go with this.

Thanks
18 years ago
Thanks very much for your response Richard - appreciate it

I don't know why I thought I needed a for loop either to print one line - having a funny moment(well several hours really!) :roll:
18 years ago
Hi

I am sure this is really simple but I cannot work it out, although I have been searching the internet and books on Java

I have the following array and I want to be able to select a random element from it each time the method is called:



I just cannot think of a for loop to do this, so that it does not always pick the same position on the array.

Hope someone can help me with this

Thanks
18 years ago
oh OK - Thank you

Will have a go at this and if I still cannot see the problem, will post the smaller code here.

Cheers
18 years ago
Hi

Thanks for the response but I'm not sure what you are saying I should do?

I have a program running, which is made up of three classes - hence not wanting to attach 'ALL' my code. I just wondered if there was anyway I could zip up my full program and attach to the forum?

Or if anyone could point me in the direction of where I might look for this problem?

Thanks
18 years ago
HI

I have a really strange problem and I don't know where to look in my code for it so hopefully someone out there can help me

I have a GUI with some buttons on it - all of which have the text as bold.

Its an odd problem which I haven't quite managed to track down to a certain action as yet but here goes:

The buttons all appear bold when the applet is first run up. however, sometimes if you hover the mouse over a button they start unbolding themselves. To get them to go bold again I click on one button and once it has actioned something the buttons start to bold again...?

I am completely lost as to go about sorting this problem. Does anyone have any ideas what I have or haven't set to make this happen?

I initially created this GUI in netbeans and then moved it into Eclipse to change it to an applet(as netbeans only created a frame).

Hope someone can help.

Thanks in advance

below is an extract of my code, as I have quite a bit for the GUI so didn't want to post more than is needed. Is there anyway I can attach my code to a post as this would make it easier for you to see what I mean? or I can e-mail it to anyone willing to help with this



[ July 30, 2005: Message edited by: son dunckley ]
18 years ago
Hi

I have managed to get an array to generate random numbers between 0 and 99. However, I would also like the array to contain negative numbers as well but cannot work out how to do this?

Anyone able to offer advise on this please?

My code is:

18 years ago