Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Justin Porter

Ranch Hand
+ Follow
since Nov 20, 2004
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 Justin Porter

Thanks for pointing that out. It would have to have been addressed later and I would have probably forgotten about having to compare strings with the equals method. It still doesn't fix my problem though. I have a println statement in my code that will let me know if my equals method has been run or not, and so far I've not been able to get that message printing yet. Thanks for the help so far, still looking for answers though!
15 years ago
Still I cannot get it to work... here is my updated code:

And in my Pair class

Anything helps!
15 years ago
Ok thanks, I'll try it out. Definitely makes sense though, guess I should have checked parameters! :-)
15 years ago
Hey,
I have a bit of a complicated situation here. I am using the Arraylist class to store an array of objects of class Pair. The Pair class is a class I have defined in another .java file and works fine. It has a method called "equals()":

Now what I am trying to do is implement an "indexOf()" method in my main .java file to where it will search the arraylist and find the "Pair" that has the same name as the one I am searching for. Name is a Sring variable defined in the constructor of the Pair class. Maybe there isn't an easy way to do this, but if there is, I'd like to know how. Here is what I was trying:

table is my Arraylist. I found out from the API that the indexOf method of the arraylist calls the "equals()" method to figure out if it found the right object or not. So that's why I wrote my own equals method. But that equals method is not getting called (I found that out from testing). So how can I make the indexOf() method call my equals() method? Any help would be appreciated!
15 years ago
One other thing... roughly 10% of all integers are primes, correct?
15 years ago
I'm working with a number (count) roughly 320 bits in length, and a number (big) roughly 640 bits in length. I have both of the numbers in BigInteger form.

Now is it faster to check if 'count' is probably prime (maybe with a lower certainty parameter than 100), and then if it is, see if it is a factor of 'big', or would it just be faster to check if it is a factor of 'big' for each of them? Any comments would be appreciated, thanks!
15 years ago
Lol, don't worry about it! I'm just happy I finally got it working! Thanks for taking the time to help!
15 years ago
Hey,
Once again, thanks for the help! I finally got rid of all the compiler errors! I have one problem though - it's not drawing the pixels! I think it is because I need to call a method (update()?) to actually "paint" it on. I was going to put that call in my init() method, but it wouldn't let me call it without a Graphics object parameter. Since I can't instantiate a Graphics object, how am I supposed to call the update() method?
15 years ago
Alright, let me see if I'm doing this right. Here is the code for the updated method (I didn't change any of the other code)


It is still giving me the same errors though, except the getX() and getY() errors are no longer there. But all of the Graphics related ones are... help! :-)
15 years ago
Hey thanks so much for taking the time to help me out. I still have a few questions relating directly to compile errors. Anyway, here is my code:

- It says it can't resolve symbol for super.paintComponent()
- It says it can't resolve symbol for Graphics.setForeground() and Graphics.setBackground()
- It says it can't resolve symbol for each of list.get(i).getX() (and getY) Specifically it says the getX() or getY() parts.

Any help would be greatly appreciated! Thanks!
15 years ago
Still don't have an answer on this one...
15 years ago
For testing purposes, I was just attempting to draw 100 random pixels, so here is my code for that.

Then I have a JavaGraphUser that actually uses the class.
15 years ago
Hey, I need some ideas on how to start this. I want an applet that will allow me to write a function in the code (probably just cycle through it in a "for" loop) and output the results onto a graph, similar to that of a graphing calculator. All I need to do is plot the points as pixels, it doesn't need to be any more complicated than that.
Where I am stuck on this is on how to actually plot each pixel on the applet interface. I've done just regular java programming before this, I haven't worked on an applet yet, so mentioning basics and how things work is essential. Thanks ahead of time for any help you can give!
15 years ago
Sorry no one answered in the beginners forum so I thought it might belong in the intermediate forum...
15 years ago
What is the easiest way to draw pixels on an applet? All I want to do is have a white background and be able to draw single black pixels on it using specific x,y coordinates. Any help would be appreciated, thanks!
15 years ago