Forum: Java 5 Days Ago |
| Replies: 3 Views: 177 It is most likely a focus issue. Read the tutorial on writing key listeners: http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html
If you need to respond to specific keys being... |
Forum: Java 7 Days Ago |
| Replies: 2 Views: 150 That error message should contain a little more information at the end. They are appending the string description on that line.
If you want more info than that, add an "e2.printStackTrace()" in... |
Forum: Java 7 Days Ago |
| Replies: 8 Views: 187 Because a version of the xerces parser ships with the JDK and is used as the default DocumentBuilderFactory if you haven't registered a different one.
It's not using the libraries that you... |
Forum: Java 7 Days Ago |
| Replies: 8 Views: 187 Did you not have a "xerces.jar" file as well? From the online docs it looks like you should, but perhaps "xercesImpl.jar" has replaced that.
Edit: I just pulled down the latest binaries and... |
Forum: Java 7 Days Ago |
| Replies: 8 Views: 187 You need to add the jar files for those libraries to your project properties. In the Project Propteries window, select Libraries and add those jars in the Compile section. |
Forum: Java 7 Days Ago |
| Replies: 16 Views: 489 Netbeans does allow you to work in GridBagLayout (or several others) from the designer if you set it yourself. It defaults to GroupLayout though, which is hideous to read. |
Forum: Java 8 Days Ago |
| Replies: 7 Views: 300 If there isn't any behavior of Thread that you need to alter by subclassing, why would you extend Thread? That's what they are saying here. If you can't point to an advantage in your code to extend... |
Forum: Java 8 Days Ago |
| Replies: 2 Views: 172 Here you have declared the type and size of the arrayMovingPlatform[] platforms;
platforms = new MovingPlatform[1];but you must still create an instance of each elementplatforms[0] = new... |
Forum: Java 14 Days Ago |
| Replies: 8 Views: 359 Here's a small example that may be of some help. I've commented the relevant sections
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import... |
Forum: Java 14 Days Ago |
| Replies: 8 Views: 359 The problem is that all of that code is executing on (and holding up) the event queue, which is also responsible for repainting. You need to split that code off into a separate thread that calls for... |
Forum: Java 14 Days Ago |
| Replies: 5 Views: 299 The code fragment that you posted would only result in a single instance of the panel and should behave exactly as you want it to. The part I don't follow is that you say the panel is a class member... |
Forum: Java 14 Days Ago |
| Replies: 20 Views: 521 Well, since it's difficult to see over your shoulder, perhaps you should post the current version of the code. |
Forum: Java 14 Days Ago |
| Replies: 20 Views: 521 Did you change the =="n" to equals("n") as Sciwizeh mentioned? |
Forum: Java 22 Days Ago |
| Replies: 14 Views: 615 You have to cast the Object to Integer if you want to assign it to the array.keys_Array[i] = (Integer)unsorted.get(random.nextInt(100));Using generics to type your collections would avoid that. |
Forum: Java 22 Days Ago |
| Replies: 14 Views: 615 for(int i=0;i<100;i++){
keys_Array[i] = unsorted.get( random.nextInt(100) );
}Note that get() is used if 'unsorted' is an arraylist and not an array. |
Forum: Java 22 Days Ago |
| Replies: 14 Views: 615 You can also use Random.nextInt(int) (http://java.sun.com/javase/6/docs/api/java/util/Random.html#nextInt(int)) for the random int.
Keep in mind that the suggestions tendered so far will allow the... |
Forum: Java 23 Days Ago |
| Replies: 16 Views: 779 I see that you have solved this part already, but I thought I would add a couple of examples of different designs you can use for that.
This one uses a small listener class that takes the list you... |
Forum: Java 28 Days Ago |
| Replies: 2 Views: 196 Well, you can but it's rather unwieldyArrayList playerinfo = new ArrayList(Arrays.asList(new Object[]{"blah","blah"}));It would be much cleaner to just make a small static method to build and return... |
Forum: Java 29 Days Ago |
| Replies: 6 Views: 394 Sounds like you just need to tweak your coordinate math a little. If you got a solid triangle you are on the right track.
Edit: Oops, cross posted with santiagozky. I would agree that you should... |
Forum: Java 29 Days Ago |
| Replies: 6 Views: 394 Just a note: it's preferable to override paintComponent() in most cases instead of paint(), since paint() is also responsible to painting children and the border.... |
Forum: Java 29 Days Ago |
| Replies: 6 Views: 587 That's because you moved the code into the anonymous listener. If you aren't going to define that method on your class then remove the "implements ActionListener" from your class declaration. |
Forum: Java 29 Days Ago |
| Replies: 10 Views: 473 In your Netbeans installation directory, go to "etc/netbeans.conf". There you will find an entry for "netbeans_jdkhome". |
Forum: Java 29 Days Ago |
| Replies: 6 Views: 587 Well, looking at that brace on line 64, your code to add the listener is not in a method at all. So you've left out some other code in your post or that piece above won't even compile. |
Forum: Java 34 Days Ago |
| Replies: 8 Views: 338 The literal value of a float in your code would be "6.0f", but printed output does not show that "f" unless you put it there explicitly.
Your output is perfectly fine. |
Forum: Java 34 Days Ago |
| Replies: 8 Views: 338 Are you expecting it to print the "f"? Doubles and floats don't look any different as output. |
Forum: Java 34 Days Ago |
| Replies: 2 Views: 240 Maybe you want to reverse line 23? |
Forum: Java 34 Days Ago |
| Replies: 2 Views: 222 That isn't Java code. Perhaps you meant to post this in another forum? |
Forum: Java 34 Days Ago |
| Replies: 18 Views: 565 (Yes, the HTML page source is just marked up text) |
Forum: Java 34 Days Ago |
| Replies: 18 Views: 565 Give it a quick try and you'd have a definitive answer. :) |
Forum: Java 34 Days Ago |
| Replies: 18 Views: 565 You can start with Reading Text From A URL (http://www.exampledepot.com/egs/java.net/ReadFromURL.html) and Regular Expressions (http://java.sun.com/docs/books/tutorial/essential/regex/). |
Forum: Java Nov 4th, 2009 |
| Replies: 18 Views: 484 I think you are correct that the behavior did stem from some blocking, but this can still be simplified a great deal to work without a separate listening thread.
Here's a re-wired version of the... |
Forum: Java Nov 4th, 2009 |
| Replies: 5 Views: 236 The problem is that all of your code, including the thread.sleep() calls, are executing on the AWT event queue thread, which is the same thread that handles the repaint calls to update the display.... |
Forum: Java Nov 3rd, 2009 |
| Replies: 6 Views: 700 It all comes down to the details of "changing the look". Some things are trivial, others are quite complicated. You asked a very general question.
If you just want to set the frame to be... |
Forum: Java Nov 3rd, 2009 |
| Replies: 6 Views: 700 You can customize all kinds of things about how the UI appears. A lot is possible with the methods provided by the Swing components, but if that isn't sufficient it's possible to use the the... |
Forum: Java Nov 3rd, 2009 |
| Replies: 3 Views: 203 You could define a method like private void enableLength(boolean enable){
txtLength.setEnabled( enable );
lblLength.setEnabled( enable );
}so your if() code becomesif (optBox.isSelected() ){... |
Forum: Java Nov 3rd, 2009 |
| Replies: 2 Views: 208 |
Forum: Java Nov 2nd, 2009 |
| Replies: 2 Views: 277 Just like any anonymous implemenationreturn new Enumeration() {
public boolean hasMoreElements() {
throw new UnsupportedOperationException("Not supported yet.");
... |
Forum: Java Oct 30th, 2009 |
| Replies: 7 Views: 337 Here is a "bare bones" mockup of how such an event model can be implemented. I've retained your names so it might be a little clearer
import java.util.ArrayList;
import java.util.List;
public... |
Forum: Java Oct 30th, 2009 |
| Replies: 7 Views: 337 That is exactly the point of the models I mentioned above. You need to implement a way that your main frame can register itself as a listener for the selection change.
With the small model I... |
Forum: Java Oct 30th, 2009 |
| Replies: 7 Views: 337 I'm struggling a bit to understand the exact behavior you are aiming for, but if you're just saying that the "main frame" needs to take some action when the selection array changes, you can make a... |