7,116 Posted Topics
Re: Hello salasah Welcome to DaniWeb, and thank you for taking the time to contribute. Here are a couple of things to think about before your next post: 1. This thread is 2 years old, nobody is still waiting for the answer 2. More important: Here at DaniWeb we try to … | |
Re: Please start a new thread for your questions. This one is 11 months old. | |
Re: Commenting style: The comments on this code are really over the top. The reason for comments is to explain the code, but you should assume that the reader has a decent working knowledge of ordinary Java. Comments like public class PrimeNumber{ //Defines a class called PrimeNumber don't help. Anyone able … | |
Re: Your src directory must be in the classpath for the compiler to find com and its subdirectories | |
Re: You have a clue in how it's called - if its called using an instance then its (probably) an instance method. If it's called using a class name then its definitely static. In the end you can always look at the API documentation which shows every method's details. | |
Re: Nobody seems to have an answer for you... maybe because the question is not clear enough, and there's no code for anyone to look at? Try asking again with enough detail for people to understand exactly what you are doing and exactly what help you need; someone will help. | |
Re: Maybe you would be happier with Eclipse and WindowBuilder? That combo gives you full two-way editing/updating of code or GUI design. (It's what I use) | |
Re: Instance methods can be overidden, but static methods cannot (they can only be masked). When the virtual machine invokes an instance method, it selects the method to invoke based on the actual class of the object, which may only be known at run time. On the other hand, when the … | |
Re: tHelloWorld.java is the name of a source file, not a class. Assuming you have compiled HelloWorld, and the .class file is somewhere in your classpath, all you need to do is o change line 1 so the string just contains the class name. | |
Re: Java is perfectly OK for animation unless you want to do something very very intensive.See also http://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners | |
Re: For each element: if there is another element the same, remove it. | |
Re: OK, you have posted about 500 lines of code, including some very long and very nested logic. It's unlikely that anyone will have the time or inclination to study all that just to fix an NPE. If you want general advice about how you are structuring your code you need … | |
Re: Each of the four access modifiers specifies a different range of permitted accesses. http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html You first decide how wide the access permissions need to be, then that tells you which modifier is appropriate. (IMHO the four choices have always seemed to me to be a bit of a mess - … | |
Re: Did you look at http://www.jthink.net/jaudiotagger/ - it looks pretty good and seems to support setting artwork. (I haven't tried it myself) | |
Re: I think you can safely ignore "callback" for now, just concentrate on writing the method. Ant is an abstract class, so you will have to create one or more subclasses of Ant, each corresponding to a different type of ant. There also seems to be a String (called antType) that … | |
Re: You may be rejecting Norm's advice too quickly. Opening 15 files in WinZip or whatever and drag/drop everything into your jar is trivially easy, and shouldn't take more than a few minutes. And the package name/directory structure was designed to guarantee no name clashes. | |
Re: Nobody's going to give you the code because it's far better if you learn how to do it yourself, so... You can use the format method in the String class to format your data any way you want before putting it in the JLabel. http://javarevisited.blogspot.fr/2012/08/how-to-format-string-in-java-printf.html | |
Re: You could convert them to Strings (eg in hex) then there's no problem with properties files. | |
Re: The static block will be executed before a constructor, or any other method, can be accessed, so I believe that there should be no thread-related problems (JLS 12.4.1) | |
Re: "var" isn't Java, but anyway, in Java if you omit the "f", eg 12.5, it's assumed to be a double (same as float but twice as many bits for much greater accuracy). | |
Re: The scope of a name is only within the immediate surrounding {} brackets. Eg the Patient variable declared on line 335 has its scope from 331 to 376. As soon as you go outside that scope the variable is discarded. So although you create a patient on lines 335 onwards … | |
Re: On line 49 you always add the new number at thelast+1 position in newArray. That's doubly wrong - each value will overwrite the previous one, except that the index value is invalid anyway. You could keep a variable that tracks how many numbers you have already added so that will … | |
Re: "It says like error" tells us nothing; it's not even English. If you have a compiler or runtime error message post the complete message plus the actual code it refers to. | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: The HTML approach works, although you will have some code to wrtite to update the actual text without messing uip the HTML tags. The "ideal" solution is to use a JTextPane and set the attributes. [This link](http://www.java-tips.org/java-se-tips/javax.swing/how-to-add-colored-text-to-the-document.html) shows a nicely packaged solution - you could extend that, or just use … | |
Re: That looks like C or one of its derivatives. This is the Java forum. Please decide what language you are using and post this in the appropriate forum. | |
Re: There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: You can use the `printf` method instead of `print`. That allows you to specify formatting, eg how wide numeric fields should be. http://www.homeandlearn.co.uk/java/java_formatted_strings.html | |
Re: lines 141, 144 paint exactly the same oval, so first you paint it in red, but them immediately overpaint that with blue. I wold like to sugest a better approach, but that would probably conflict with the book you are using. | |
Re: It would probably llok like this: public void addPerson(Person p){ files.add(p); } | |
Re: You read the file into the arraylist the search (OK), then search the arraylist for the desired value, but when you do that search you use the code for file reading (nextLine) rather than an ArrayList method to eccess the next element in the arraylist. | |
Re: It's line 44 that's worng. When you init your VectorGraph instead of adding that VectorGraph to the JFrame you create a second VectorGraph (with default values of 0) and add that instead. Your correctly constructed VectorGraph never gets displayed. | |
Re: I think the change you made is going in the wrong direction. If you have 2 objects each should have its own string, and doesn't need to know about the other object's string. What will happen when you have 3 objects, a thousand objects? Will you have a thousand string … | |
Re: Probably because the keyboard focus is on another compoenet. Better to use key bindings to avoid this http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html | |
Re: This is really confused. You need to stop coding for a minute or two and think about what you are doing. You have 2 JLabels, but then you add action listeners as if they were buttons, then you try to get two Strings from them as if they were JTextFields. … | |
Re: It will not be executed becuase it cannot be compiled. `counter -` is not valid Java | |
Re: Your variables are private, so you will need to use accessor methods like getCoef() and getExpo() so you can accees those values for the other object. OR Because your variables are defined as *final* they are immutable, so there's no danger in making them public so you can access them … | |
Re: Where do lines 1,2 fit? You're obviously missing some of the code in that listing OK, nevermind, heres the problem: When you execute lines 1,2 you create new Main and call its createAndShowGUI() method, which, on line 56 creates a second instance of Main and displays that in the JFrame. … | |
Re: Did you follow Norm's last post? Maybe its time to post the current version of the code so we can see what you've done. | |
Re: It looks like Poland is the first line of your file, which is a different content from all the other lines. If so you need first to read that line (eg into a String called teamName), then use your existing loop to read the remaining lines. | |
Re: If your program only uses the console for input and output then this is a problem. The standard setup for running a jar is to use javaw.exe, which does not display a command window or console. Try running your jar from a command prompt with java.exe instead of javaw.exe That … | |
Re: Maybe your problem isn't the clip, it's this horror on line 43 while(clip.isActive()){} that's going to take 100% of the available CPU until it terminates I suspect there must be a better way to be notified when a clip is finished, but at the very least you could try something … | |
Re: Order is the class name. YOu use it to refer to static variables and methods of the class. If those are instance (non-static) methods then you need to call them with an instance of the class, eg filename | |
Re: Just set the JLabel's imageicon to null | |
Re: You will find the official Oracle Look and Feel Graphics Repository at http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-client-419417.html#7520-jlf-1.0-oth-JPR ... but there are many mnany other sources of free icons that you can use for your Java application - just Google for them. | |
Re: Rather than use an int return (hard to understand, easy to confuse) use a simple enum, eg `enum FolderAction{INSERTED_PATH, INSERTED_MSECS, .... ,ERROR;}` guaranteed safe, and self-documenting | |
Re: > My understanding is that a Node get deallocated by the garbage collecter automatecly when there is at least 1 reference is removed. is that right? correct me if I'm wrong. No, that's not right. An object can only get garbage collected when there are zero remaining references to it … |
The End.