7,116 Posted Topics

Member Avatar for help_please

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 …

Member Avatar for JamesCherrill
0
599
Member Avatar for Helen Toma
Member Avatar for JamesCherrill
0
6K
Member Avatar for UNDER-18 FG

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 …

Member Avatar for JamesCherrill
0
292
Member Avatar for subhraakasuny

Your src directory must be in the classpath for the compiler to find com and its subdirectories

Member Avatar for subhraakasuny
0
411
Member Avatar for Violet_82

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.

Member Avatar for Violet_82
0
2K
Member Avatar for mcbentz

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.

Member Avatar for Taywin
0
330
Member Avatar for forjustincase

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)

Member Avatar for JamesCherrill
0
979
Member Avatar for ganges

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 …

Member Avatar for jalpesh_007
0
167
Member Avatar for corby

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.

Member Avatar for corby
0
232
Member Avatar for Alex_

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

Member Avatar for JamesCherrill
0
316
Member Avatar for london-G
Member Avatar for london-G
0
94
Member Avatar for Sumal

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 …

Member Avatar for JamesCherrill
0
214
Member Avatar for bibiki

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 - …

Member Avatar for JamesCherrill
0
160
Member Avatar for shredder2794

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)

Member Avatar for shredder2794
0
1K
Member Avatar for tingwong

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 …

Member Avatar for tingwong
0
168
Member Avatar for forjustincase

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.

Member Avatar for JamesCherrill
0
322
Member Avatar for akosivivas

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

Member Avatar for radhakrishna.p
0
189
Member Avatar for CoilFyzx

You could convert them to Strings (eg in hex) then there's no problem with properties files.

Member Avatar for CoilFyzx
0
254
Member Avatar for subramanya.vl

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)

Member Avatar for subramanya.vl
0
1K
Member Avatar for Violet_82

"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).

Member Avatar for Violet_82
0
168
Member Avatar for rami sohaill

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 …

Member Avatar for JamesCherrill
0
353
Member Avatar for a7x813

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 …

Member Avatar for subramanya.vl
0
1K
Member Avatar for AlexThugNastyTyricebiggumsBello

"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.

Member Avatar for NormR1
0
248
Member Avatar for Maria Jalal

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.

Member Avatar for JamesCherrill
0
133
Member Avatar for SHINICHI

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.

Member Avatar for jalpesh_007
0
134
Member Avatar for _eclipse

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.

Member Avatar for _eclipse
0
167
Member Avatar for oldezwe

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 …

Member Avatar for JamesCherrill
0
326
Member Avatar for Synapomorphy

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.

Member Avatar for JamesCherrill
0
105
Member Avatar for hilalihakim

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) …

Member Avatar for JamesCherrill
0
630
Member Avatar for mdonald_101

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) …

Member Avatar for jalpesh_007
0
88
Member Avatar for Kronolynx

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

Member Avatar for NormR1
0
216
Member Avatar for jprog1000

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.

Member Avatar for javaprog200
0
350
Member Avatar for KRUX17
Member Avatar for jalpesh_007
0
229
Member Avatar for junweixiong

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.

Member Avatar for junweixiong
0
4K
Member Avatar for Benderx

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.

Member Avatar for JamesCherrill
0
360
Member Avatar for ciobanu.alexandru.cristian

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 …

Member Avatar for ciobanu.alexandru.cristian
0
210
Member Avatar for Viped

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

Member Avatar for NormR1
0
408
Member Avatar for thompsonSensibl

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. …

Member Avatar for thompsonSensibl
0
243
Member Avatar for william.bishop.7169

It will not be executed becuase it cannot be compiled. `counter -` is not valid Java

Member Avatar for rohit.deshmukh2009
0
128
Member Avatar for germainelol1

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 …

Member Avatar for JamesCherrill
0
503
Member Avatar for Skeldave

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. …

Member Avatar for Skeldave
0
1K
Member Avatar for jamesperkins0

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.

Member Avatar for jamesperkins0
0
207
Member Avatar for bhutchison

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.

Member Avatar for JamesCherrill
0
99
Member Avatar for doomsday1216

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 …

Member Avatar for JamesCherrill
0
230
Member Avatar for kedxu

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 …

Member Avatar for ~s.o.s~
0
372
Member Avatar for KRUX17

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

Member Avatar for KRUX17
0
127
Member Avatar for KeesA
Member Avatar for KeesA

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.

Member Avatar for KeesA
0
216
Member Avatar for riahc3

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

Member Avatar for riahc3
0
461
Member Avatar for sobias

> 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 …

Member Avatar for sobias
1
231

The End.