Forum: Java 5 Days Ago |
| Replies: 2 Views: 145 From what I remember SwingWorker is used when you have a long running task that you need to run. The reason you'd use SwingWorker is to run your long running task in the SwingWorker thread so that... |
Forum: Java 13 Days Ago |
| Replies: 5 Views: 259 Interesting. Guess that's it then. |
Forum: Java 13 Days Ago |
| Replies: 5 Views: 319 Yeah you've been taught wrong. You have to learn objective c among other tools. This (from my class) is a good reference material:
http://cs491f09.wordpress.com/category/lectures/
But if you... |
Forum: Java 13 Days Ago |
| Replies: 5 Views: 259 If you're only adding .1 or .25 etc, but the result shows up as something which isn't a multiple of .1 or .25, then y was clearly not equal to a multiple of .1 or .25 to begin with. In other words... |
Forum: Java 18 Days Ago |
| Replies: 6 Views: 344 Why is there so much code in your remove method? All you need to do is search linearly through your array looking for an item with the name that matches the String you're searching for. That should... |
Forum: Java 18 Days Ago |
| Replies: 3 Views: 256 You could also (more correctly) fix it by using error checking. try... catch. Exception handling. Look them up. The poster above me, his solution won't work if a user goes back and edits something... |
Forum: Java 18 Days Ago |
| Replies: 16 Views: 690 For what it's worth I agree with Masijade (about learning to code GUIs by hand first, then moving on to builders if you want to). Doing so was very helpful to me and it made it a lot easier to use... |
Forum: Java 20 Days Ago |
| Replies: 5 Views: 402 For specific components see here: http://java.sun.com/docs/books/tutorial/uiswing/components/index.html
(for example, if you want to use a button in your app, look there to see how, or if you want... |
Forum: Java 21 Days Ago |
| Replies: 2 Views: 258 Are you trying to manually do a character by character search to match words? That is a mistake. Technically it could work but the amount of effort would be enormous and fruitless. I see that your... |
Forum: Java 28 Days Ago |
| Replies: 5 Views: 344 No, I don't think there are non-trivial ways to do it with a standard grading system, other than the obvious ways which have been listed in this thread already. I don't understand the system you... |
Forum: Java Nov 16th, 2009 |
| Replies: 7 Views: 499 Your LoadStudents method doesn't make sense to me. You said while(s.hasNextLine()) but you never read anything in, so I'd think that would be an infinite loop. Additionally, you kept adding a new... |
Forum: Java Nov 16th, 2009 |
| Replies: 2 Views: 238 There is no reason you'd ever pass "this" as an argument. "this" just refers to the Object of the classtype that you are currently in. So if your class name is Car, and you say "this." anywhere... |
Forum: Java Nov 12th, 2009 |
| Replies: 1 Views: 366 I haven't worked with Applets, but I think they work the same way as Swing basically? (Edit: confirmed - one whole point of JApplet is that it works with Swing). Use a JPanel or whatever the standard... |
Forum: Java Nov 8th, 2009 |
| Replies: 8 Views: 280 Cool. Mark the thread as solved please. |
Forum: Java Nov 8th, 2009 |
| Replies: 8 Views: 280 Did you add the helpMenu to your JPanel? You didn't provide enough code to see what's going on. The method you posted looks fine but I'm not sure if you ever added the helpMenu (that was returned) to... |
Forum: Java Nov 8th, 2009 |
| Replies: 8 Views: 280 if e.isSelected makes no sense because you already know which item is selected, and you already know that it's selected because otherwise the actionPerformed method wouldn't have been called. And if... |
Forum: Java Nov 8th, 2009 |
| Replies: 8 Views: 280 What is subpanel? Up till line 9 your code seems ok to me, after that I have no idea what you are trying to do. |
Forum: Java Nov 5th, 2009 |
| Replies: 8 Views: 354 Then do System.out.println("f") afterwards. lol. |
Forum: Java Nov 5th, 2009 |
| Replies: 8 Views: 354 You're probably storing it in a double variable. For example
double result = 0.0;
result = average(x,y);
Now result is a double which is a larger type than float. |
Forum: Java Nov 5th, 2009 |
| Replies: 8 Views: 354 return (float)((x+y)/2.0);
OR
return ((float)(x+y))/2.0; |
Forum: Java Nov 4th, 2009 |
| Replies: 18 Views: 544 That is actually good logic - but it assumes that the MouseListener wouldn't get re-added due to the method calls being blocked/having to wait for receive, so it probably runs into the same problem... |
Forum: Java Nov 4th, 2009 |
| Replies: 18 Views: 544 Well, thank god that somebody else stepped up, because I was getting quite frustrated and it isn't even my program. Haha. Although after a quick look I don't see why your version is any different... |
Forum: Java Nov 4th, 2009 |
| Replies: 18 Views: 544 My example was pretty long, but try to grasp the concept and I think you'll be able to complete your program. Again, the basic idea I'm proposing is that you multi-thread your application so that the... |
Forum: Java Nov 4th, 2009 |
| Replies: 18 Views: 544 Sorry, took too long and couldn't edit my last post. Update:
Ok, so this seems to be the issue: since read() blocks while it waits for input, when the client's receive() method is executed, all... |
Forum: Java Nov 4th, 2009 |
| Replies: 18 Views: 544 The error either has to do with memory consistency, or the fact that the InputStream class's read() method blocks while it waits for input (and the read() method gets called multiple times when you... |
Forum: Java Nov 4th, 2009 |
| Replies: 18 Views: 544 Actually you are correct, I did not test my modifications thoroughly enough. The problem seems to reside in the server class though, not the client class. I'll take a look again. |
Forum: Java Nov 4th, 2009 |
| Replies: 18 Views: 544 I found the problem. Your code is way more complex than it needs to be. Essentially all you *need* in the client is the "clientTurnFlag", the send method, and the receive method. Initially in your... |
Forum: Java Nov 3rd, 2009 |
| Replies: 17 Views: 1,463 I'm sure I can help you fix your binarySearch method (it looks like everything else in your program is correct). However, your instructions specifically state: "The method should use sequential... |
Forum: Java Nov 3rd, 2009 |
| Replies: 5 Views: 251 You could use a Timer to help you draw your lines at specific intervals. You could also use Thread.sleep(), as you mentioned - if that isn't working there must be something wrong in your... |
Forum: Java Nov 3rd, 2009 |
| Replies: 18 Views: 544 With the modification I made earlier, your program seems like it works. . so if you take the code I posted earlier and update the code on your machine with it, your program should run correctly. |
Forum: Java Nov 3rd, 2009 |
| Replies: 18 Views: 544 I looked through your code, and I don't see a reason why you should be continuously adding and removing the mouse listener. If there is no reason to do so, don't do it. (I.e. it adds nothing to your... |
Forum: Java Nov 3rd, 2009 |
| Replies: 18 Views: 544 I would say that this is a logical error. It might work if done properly, but in my opinion, the proper way to do this would be to keep both client and server aware of whose turn it is at all times.... |
Forum: Java Nov 3rd, 2009 |
| Replies: 1 Views: 251 Let me make sure I get what you said: I'm assuming that according to what you said, for the two files above, a third file would be produced:
data3: 1 3 5 7 11 25 32 36 45 56 78 78 90 99
So your... |
Forum: Java Nov 3rd, 2009 |
| Replies: 17 Views: 1,463 If you ask a more specific question, or tell me exactly what isn't working, I'll help you out. After 12 straight hours of coding an iphone project that uses the google maps API, kinda tired though.
... |
Forum: Java Nov 2nd, 2009 |
| Replies: 2 Views: 214 It seems like you have three Strings, firstName, middleName, and lastName. If that is the case, use
String initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);
instead of... |
Forum: Java Nov 2nd, 2009 |
| Replies: 7 Views: 11,987 Oh man! Can I buy all of them??? |
Forum: Java Nov 2nd, 2009 |
| Replies: 17 Views: 1,463 You're using filename as if it was a method, but it is not a method. It is a variable of type String. And also, since filename was declared in the main method, you cannot use it in any other method.... |
Forum: Java Oct 31st, 2009 |
| Replies: 21 Views: 720 You could also make a small class:
public class TrackWord{
String word;
int lineNumber;
int wordNumber;
} |
Forum: Java Oct 30th, 2009 |
| Replies: 17 Views: 1,463 That would be nice, but if you read his code and his errors, he clearly is having problems with passing the correct arguments into his current methods. Creating more methods at this point will only... |
Forum: Java Oct 30th, 2009 |
| Replies: 17 Views: 1,463 You also have the error message:
[ The method sequentialSearch(Scanner, String) is undefined for the type AccountNumber ]
That's because your method header is defined as "public static int... |