Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How can I solve a Java problem?
I made a graphical game in Java and every time I run it and wish to move in game I need to click the mouse first. Otherwise, nothing works. How can I solve this problem. I believe it's something to do with "setFocus" but I'm not sure. I can't post the code as there is too much of it.
3 Answers
- David MLv 59 years agoFavorite Answer
Not setFocus, but more likely toFront();
Call that within your main frame and it should give it focus:
i.e.
myFrame.toFront();
myFrame.repaint();
- ?Lv 44 years ago
in case you're given ok and n, you may create a boolean array of length n+a million with all default values set to faux. then you particularly might examine each and all the numbers in the record, and each and each you may replace the array at that corresponding index to real. finally, you pass by way of the array and print out the relax fake index. in case you at the instant are not given ok and n, you probably can locate it through dealing with the record as quickly as and looking out the min and max (those for sure cant be the lacking huge style by using fact then you particularly might have 2 possibilities!) so occasion: 19 13 17 12 sixteen 15 18 stages from 12-19, so i create an array of length 8 (index 0-7). each little thing is fake. I initiate interpreting in values: I examine in 19, which corresponds to 19-12 = 7, so i alter the cost at index 7 to real I examine in 13, i alter index a million to real I examine 17, index 5 = real I examine 12, index 0 = real I examine sixteen, index 4 = real ... Going by way of the array, we detect index 2 continues to be fake, so the lacking huge style is two + 12 = 14. playstation this type is extra desirable than the single listed above by using fact its performance is O(n) and the above is a minimum of O(nlogn) by using style.