3,927 Posted Topics
Re: Yes, EatDot() needs to be called before repaint() in your KeyAdapter to evaluate if a dot is eaten. Also, your collision function in EatDot() needs to check the absolute value of the coordinate differences[code]if ((Math.abs(xcoords - dot[i].x) <= 5) && ((Math.abs(ycoords - dot[i].y) <=5)) && !dot[i].isEaten()) {[/code] and lastly you … | |
Re: Erm, that method does not do anything at all and this declaration doesn't really make any sense[code]private slowMoveVertical balloon;[/code] Your slowMoveVertical() needs to move all of the drawn objects up by a certain distance. | |
Re: [QUOTE=naps;485855]I am a final year student and thinking of a project topic to do. Any suggetion?[/QUOTE] Track fish... some kind of fish... maybe gather and analyze some kind of stats on something they do... That's really all that comes to mind. | |
Re: Date is actually deprecated and should be replaced with Calendar[code] java.util.Calendar now = java.util.Calendar.getInstance(); String currentTime= java.text.SimpleDateFormat.getInstance().format(now.getTime());[/code] | |
Re: [QUOTE=masijade;477486]I didn't know about this (I must be blind or something ;-) ). But, sad, just sad.[/QUOTE] You didn't see it because it happened in a thread in the Geeks Lounge and whatever disagreements or rep slinging that happen there have no business in the technical forms. | |
Re: Because that is what you have for an increment statement [icode]i+=key.length[/icode] in your loop. | |
Re: Take a look through this regarding using a Calendar: [url]http://mindprod.com/jgloss/calendar.html[/url] ![]() | |
Re: And btnA2 is not displaying "pic"? Or are you expecting btnA1 to no longer show that pic as well? | |
Re: Parsing them into valid dates as masijade mentioned is really best, but if you have simple date strings like "12/01/2006", you could use the String split() function to put them in year-month-day form "20031201" for integer sorting[code]String date = "12/10/2006"; String[] datePieces = date.split("/"); String rebuiltDate = datePieces[2]+datePieces[0]+datePieces[1]; System.out.println(rebuiltDate);[/code] If … | |
Re: Since your method already has the number of rolls, you're all set to calc the percentage. You do have to watch out for the integer division though or you'll get 0 for every one of them[code](dCount[index]/(float)numRolls)*100f[/code] | |
Re: That's why the compiler gives you those handy messages when there are problems :) What do they say? | |
Re: Your IDE is most likely treating it's project root directory as the root context when it executes. If you are clicking on a jar in the dist folder, that is most likely the root context. Try dropping a copy of your images directory into the dist folder. If it runs … | |
Re: What are you using for logging currently? You might take a look at [url]http://java.sun.com/javase/6/docs/api/java/util/logging/package-summary.html[/url] or Log4J. | |
Re: [code]JToggleButton[][] buttons = new JToggleButton[5][5];[/code] That just declares the type and dimensions. You still have to set each element equal to a new instance of JToggleButton. | |
Re: And that is a method you are trying to declare or is it a variable you are declaring? Either way it looks to be an invalid statement. Is that the entire line of code? | |
Re: You will need to start this on your own. If you run into difficulties, post the code you are having problems with, the exact error messages, and specific questions about the problem. | |
Re: You may be able to get the 0-255 grayscale value like this[code]int grayVal = ((int) sample2[0]) & 0xff;[/code] (I haven't worked with it myself, but some reading suggests that might work for you.) | |
Re: You are correct - you're overwriting the file on each invocation of detailLine. To fix that, you could make the output file a class-level variable or pass a reference to it as a parameter. Either way, do not open or close the file in that method - just write the … | |
Re: It depends on how you need to access the data, but I would imagine the simple file would suffice. You don't mention what the data is, but basically you have the equivalent of a single table. With file-based storage you will need to write the methods yourself if you want … | |
Re: Yes, moving your console app over to a Swing component isn't just a matter of stuffing the output into a message box. Message boxes don't work like the console at all. You will need to work with frames/panels and either arrays of components or custom 2D painting with mouse listeners. … | |
Re: Well, for one thing, don't set all of those constraint properties in the constructor. How are you going to read and make sense of that parameter string as you try to make adjustments? Set the constraint properties individually. You can use a single GridBagContstraint object and vary the properties only … | |
Re: [quote=Aprilia;465253]Hi all, i'm new so not sure if this is the right place or not. [/quote] No, it's not. Look somewhere else to learn how to program cheats and exploits. I won't say good luck - I hope you fail miserably. | |
Re: This site has source for several games in Java. Perhaps something there will help get you started. [url]http://www.codebeach.com/index.asp?tabID=1&categoryID=4&subcategoryID=11[/url] | |
Re: The question still makes no sense. You can't generically pass a primitive as a parameter, so you would need separate signature for each anyway, which alleviates the ambiguity. | |
Re: Perhaps your SalaryGenerator should take the current salary as a parameter and add a random amount to it, a randomRaise() perhaps. | |
Re: Just keep two int counters. Why do anything more complicated? There will never be more than two players in the game. If there were more than two, you could keep their scores in an array, a HashMap, or most any collection. | |
Re: It sounds like you mostly understand how compareTo(Object o) works. Your job is to compare the specific properties of the objects in your if() statements such that you return the proper int value. If you need to compare on some property value, say object.cost() for example, you write the if() … | |
Re: You are merely scanning all the words and incrementing the position, but you don't do anything when you get to the position where the insertion is to take place. The for loop is just printing the last word found by the scanner "number of words" times. You are also returning … ![]() | |
Re: "A Christmas Story" [url]http://en.wikipedia.org/wiki/A_Christmas_Story_%281983_film%29[/url] "Bad Santa" was pretty good as well. | |
Re: [QUOTE=shipar;481569]:-( is this a forum only for experts? [/QUOTE] No, not at all. You asked an incredibly general question and jwenting gave you a general answer. If you need specific answers you need to ask more specific questions. | |
Re: Other: "Heavy Metal" [url]http://en.wikipedia.org/wiki/Heavy_Metal_%28film%29[/url] The listed choices were pretty lame :P | |
Re: Scanner has a hasNextInt() method that will tell you if the input can be read as an int (also has method to test for float if needed). If that returns false you can just consume the input and re-try. | |
Re: Don't forget about your friend the mod operator as well:[code=java] for (int i=0; i < 5; i++) { for (int k=0; k < 5; k++) { System.out.print((i+k)%5 + 1); } System.out.println(""); }[/code] :) | |
Re: A counter of the incorrect entries would be easier. What if you decided to allow for three incorrect entries instead of two? Another try block with identical code would be needed. In most all cases, duplicate code blocks should suggest to you that something could be arranged more efficiently. | |
Re: Just an unrelated side suggestion: Always go ahead and use braces with your for() and if() blocks, even if they execute a single statement. Yes, it is unnecessary, but you will save yourself a lot of debugging headaches when one day you add another statement to block and can't figure … | |
Re: You will first need to work up something on it for yourself. If you run into problems, then post that code and specific questions about it. | |
Re: > Are you aware that, before the telephone, "hello" was a Norse war cry and sort of a mild swear word? Can't seem to find any mention of this elsewhere. Are you making things up again? :) | |
Re: [QUOTE=ithelp;474202]I agree with you. Why the scientists are not trying to solve the basic problem of food , like getting it from air , then we would not require money at all.[/QUOTE] I'm not sure you are getting enough air yourself.... | |
Re: >Apparently American blacks are now feeling insulted by the word "black", irrespective of when it's used. Actually, it seems to me that "Black" is becoming accepted usage again after years of "African American" being the only term acceptable to the PC wonks. :icon_rolleyes: | |
Re: You might want to go through the Space Invaders 2D game tutorial on this site: [url]http://www.cokeandcode.com/[/url] | |
Re: [QUOTE=Black Box;480345]By giving your arrays to that method, you give them a local copy of the arrays. This means that what ever you do inside that method, happens to the copy. In orde to get the result back into your initial arrays, you need to let your methods return the … | |
Re: "Cannot find symbol" means you are using a class, method, or variable that hasn't been defined. In this case, you are calling "hprintln()", which doesn't exist in that file. | |
Re: A 2D array doesn't have a method called empty(), which is what you are trying to call here[icode]a.empty(row,column)[/icode]. You don't show your empty() method, but if it already operates on an instance level array variable, just call[icode]emtpy(row,column)[/icode]. If you need that method to work against different arrays when called, you … | |
Re: Try these: # [url]http://www.rob.cs.tu-bs.de/content/04-teaching/06-interactive/Hough.html[/url] - Java Applet + Source for learning the Hough transformation in slope-intercept form # [url]http://www.rob.cs.tu-bs.de/content/04-teaching/06-interactive/HNF.html[/url] - Java Applet + Source for learning the Hough-Transformation in normal form | |
Re: Please use code tags around your code to preserve formatting, and.... what is the question? | |
Re: [QUOTE=outdatedtech;474076]That's what I see this time of year. [/QUOTE]So what. Christ has been co-opted for pushing things onto people since inception. Nothing new to see here really. [QUOTE=outdatedtech;474076]That and the Walton kids getting richer.[/QUOTE]And it makes you angry that they are making a lot of money? Well, so are a … | |
Re: Think of using the stack as a place to put something to be processed later by your algorithm as opposed to recursion being used to process it right now. From your starting position, examine whatever you need to check. If it meets the criteria, push it onto the stack instead … | |
Re: [quote=moppi;455018]I AM MOPPI PC TECHNICIAN AND HERE TO SHARE SOME OF THE PROBLEMS I FACE IN THIS AS FAR AS LAPTOPS ARE CONCERN.i HAVE A COMPAQ ARMADA M700 LAPTOP WITH ME WHICH ONLY THE BATTERY, POWER KEEP ON BLINKING BUT NOT SWITCHING ALSO, THE NUMLOCK INDICATORS AND ARE ON AS … | |
The End.