7,116 Posted Topics

Member Avatar for Gen.Asura

Welcome to DaniWeb, and thanks for the sample code. Presumably you noticed that the OP "figured it out and submitted his homework" 10 months ago, so it's a bit late to help him! For future reference, if you are publishing code here, please do not link to an external site …

Member Avatar for JamesCherrill
0
175
Member Avatar for kupogu

DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules

Member Avatar for JamesCherrill
-1
55
Member Avatar for nsharif

Are you talking about the "model" for your game, or the "view" that displays it on the screen? "show" suggests a GUI solution, but linked list is something you would use in a amodel and has no GUI characteristics whatever. Maybe you can expand/clarify the requirements some more?

Member Avatar for nsharif
0
110
Member Avatar for mikewyatt

The trick is to get the list box's ListModel (the ListModel maintains all the data that the list displays). That will give you an instance of DefaultListModel which has methods to clear the model, add elements to it etc.

Member Avatar for mikewyatt
0
211
Member Avatar for techxaidz

Because all your check boxes are in individual variables you will have to code a load of "if" tests to test each box to see if its checked and increment a count as required. It's an easy idea, but very tedious to code. If you put all your check boxes …

Member Avatar for stultuske
0
334
Member Avatar for joshuamichael0808

Trying to get the Graphics and change it outside a paintComponent is always going to be dodgy. You don't know what else is doing anything to that Graphics (not to mention the double-buffering that swing does for you). Plus, it looks like you are getting the graphics for some component …

Member Avatar for JamesCherrill
0
185
Member Avatar for rahul.ch

Did you try casting a String to an Integer? I thought not! No, you can't cast String to Integer. You may also notice that the final print (line 18) prints "false". The real reason for no error is that there's no place where that error will be checked for. The …

Member Avatar for rahul.ch
0
302
Member Avatar for Ashenvale

You could try calling *requestFocus* for window B to bring it to the front. Details are in the API doc as always.

Member Avatar for Ashenvale
0
79
Member Avatar for coding101

Are you sure you want to use UDP? An mp3 file would probably occupy many UDP packets. There's no guarantee that a packet will be delivered, nor any way to know you've missed one. Multiple packets may arrive in a different order than that in which they were sent, depending …

Member Avatar for JamesCherrill
0
111
Member Avatar for dantheman4

I don't see any ambiguity in Q1 The two || cases don't fit the "if and only if" requirement because there are arrays for which they will evaluate true even when all the numbers are not be in ascending order (just two ascending will be sufficient). Case d is just …

Member Avatar for JamesCherrill
-1
159
Member Avatar for rubai

You need to create a Java Project first, then add classes to that. If you're not experienced in Java I strongly advise you NOT to try to learn Eclipse at the same time - you are super-imposing two very large learning curves. Just use a programmer's editor (eg notepad+) and …

Member Avatar for rubai
0
140
Member Avatar for prem2

@methakon Your contributions to DaniWeb are very welcome, but please check the dates before responding to an old thread. @prem2 had his answer 2 years ago, so your answer is (1) not needed and (2) 2 years too late. Your first "helpful" link is for C#, not Java.

Member Avatar for JamesCherrill
0
2K
Member Avatar for Hemanth.Satkuri

Is [this](http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html) the kind of thing you mean?

Member Avatar for NormR1
0
252
Member Avatar for sapure

The parameter is passed directly to your main method from whatever command prompt or IDE has started your program. [This link](http://netbeanside61.blogspot.fr/2009/02/using-command-line-arguments-in.html) shows how to pass and use such a parameter in netbeans. ps This is yet another good example of why most of us advise beginners to stay with an …

Member Avatar for sapure
0
316
Member Avatar for jemz

[This](http://introcs.cs.princeton.edu/java/85application/jar/jar.html) explains how to do it

Member Avatar for jemz
0
415
Member Avatar for will.penfold.71

If you have an error message you should ALWAYS post the complete text of the message when asking for help. Th exact wording of the message tells us a lot, including the line number inthe program it refers to. In the meantime, you haven't shown any code to initialise the …

Member Avatar for jalpesh_007
0
161
Member Avatar for abdulhamid1

I don't understand your post. Can you explain in more detail what you want to know?

Member Avatar for jalpesh_007
0
56
Member Avatar for vishu.bhavsar

You can use a ComponentListener, something like: myThing.addComponentListener(new ComponentListener() { @Override public void componentShown(ComponentEvent arg0) { System.out.println(arg0); } @Override public void componentHidden(ComponentEvent arg0) { System.out.println(arg0); } @Override public void componentMoved(ComponentEvent arg0) { // not interested } @Override public void componentResized(ComponentEvent arg0) { // not interested } });

Member Avatar for JamesCherrill
0
204
Member Avatar for popeyemissy

When you detect a war (line 137) you could set a boolean to mean "previous game resulted in war". Then next time through you can check that boolean to whether to score double points (and reset the boolean)

Member Avatar for JamesCherrill
0
313
Member Avatar for summey

Exactly what help do you need? You know the drill... full text of any error messages, or a complete description of how the actual behaviour differs from the desired.

Member Avatar for NormR1
0
234
Member Avatar for Dane2259

NPE at which line? The message tells you that. Then look at that line to see which variable(s) could be null. Print it/them to confirm, then work backwards to find out why. (I'm finishing now for this evening, someone else will probably step in...)

Member Avatar for NormR1
0
201
Member Avatar for rammiesteyn

You declare cal inside the loop. A Java variable's scope is from the immediately preceeding { to the immediately following }, so cal is out of scope after you exit the loop. You could declare (and initialise) it before entering the loop

Member Avatar for rammiesteyn
0
265
Member Avatar for Rohan.India

Create a small array of operands (do you mean operators, or maybe operations?) and use a random int to select one element from the array.

Member Avatar for JamesCherrill
0
107
Member Avatar for jaydac12

You only seem to have one boolean for "borrowed" whereas you need one boolean per book. You could use another ArrayList, like for the names etc. ps: In Java the "right" way to do this is to define a class called "Book" that has instance variables for name, borrowed etcetc, …

Member Avatar for jaydac12
0
705
Member Avatar for Kathy0410

Just an abstract class Soprt, and non-abstract sub-classes Basketball etc. for the data, and a MySports class as the driver? Yes, makes complete sense to me.

Member Avatar for JamesCherrill
0
187
Member Avatar for Dizzy Noob

your array "word" contains one entry for each word in the input. word.length tells you the nunber of entries in the array you can test that value to be >= 3 in an if test if that's not enough of a hint, get as far as you can and post …

Member Avatar for Dizzy Noob
0
282
Member Avatar for crownedzero

Please mark this "solved" so people don't waste time trying to help with it, and also so the problem & solution will be part of our knowledge base J

Member Avatar for JamesCherrill
0
191
Member Avatar for plasticfood

Becuase of the way generics were implemented via erasure, creating a new object using the generic type cannot be done in the obvious way that anyone would like to do it. It's not good, but it is what it is. [This link](http://stackoverflow.com/questions/75175/create-instance-of-generic-type-in-java) has a good discussion of the various ways …

Member Avatar for plasticfood
0
218
Member Avatar for london-G

Maybe there's an error when the code is run? But how would you know since you have told Java to discard any error messages and not to bother you with them? How many times have we said this in the Java forum... Never NEVER *NEVER* do this when writing new …

Member Avatar for london-G
0
273
Member Avatar for aabbccbryanmark

> java.lang.ArrayIndexOutOfBoundsException: 10 > at Salary.Employee(Salary.java:41) This also tells you the problem is on line 41 of Salary.java

Member Avatar for stultuske
0
432
Member Avatar for floriza.cruz.5

Your question is so vague and general that there's no possible short answer. Start by studying this tutorial http://docs.oracle.com/javase/tutorial/uiswing/index.html ... then come back here with any specific questions.

Member Avatar for JamesCherrill
-1
98
Member Avatar for Lavanya1312

I'm no JUnit expert, but AFAIK it runs tests at the method level and doesn't have any facilities for testing individual loops etc inside a method. In other words, it treats the method being tested as a "black box" - it supplies data, runs the method, and checks that the …

Member Avatar for JamesCherrill
0
334
Member Avatar for riahc3

One small point: if ((some boolean expression) == true) is horribly redundant. It's sufficient, and clearer, just to say if (some boolean expression)

Member Avatar for Taywin
0
263
Member Avatar for cody.reddoor

Passing in a String for concatenation (if I understand our suggestion properly) won't work because String is immutable - you will have to create a new String but have no way to update the reference that was passed in. It would work ok with a StringBuilder. Returning a new String …

Member Avatar for Taywin
0
283
Member Avatar for gelmi

Every parameter of every public method of every Java API class is documented in the API documentation, and learning to use it is an absolutely essential skill for Java prgrammers http://docs.oracle.com/javase/7/docs/api/ for drawLine it says > public abstract void drawLine(int x1, > int y1, > int x2, > int y2) …

Member Avatar for JamesCherrill
0
292
Member Avatar for rahul pareek
Member Avatar for bustersox
Member Avatar for JamesCherrill
0
478
Member Avatar for RozenKristal

At some stage you will need to tell the ATM which customer/account it is dealing with. You could just add that as a parameter to the deposit & withdraw methods. OR if one customer is likely to do a load of transactions you could have a logon method in ATM …

Member Avatar for RozenKristal
0
155
Member Avatar for Techboy52

amitie.boo If this is a project that have to submit to your teacher then you can't just copy code from this web site. That's called cheating. We don't help peaple cheat here. If you need any help with code *that you have written yourself* please start anther thread. This thread …

Member Avatar for JamesCherrill
0
2K
Member Avatar for stlcards007

You have an error at line 49.The } on line 48 closes the paint method, so the following lines are not part of any method. EXecutable statements like those must be inside a method. Don't worry about any runtime errors yet. Runtime results will be unpredictable and meaningless until you …

Member Avatar for JamesCherrill
0
160
Member Avatar for rahul.ch

This is fully described in the Java Language Specification section 15.16 "Cast Expressions".

Member Avatar for JamesCherrill
0
200
Member Avatar for sengathir

This always happens with floating point values. There is no exact binary fraction that corresponds to decimal .025 so you get the nearest binary value, which is nearer to .024999 You can use a formatting method (eg printf) to display the result rounded to the right number of decimal places.

Member Avatar for JamesCherrill
0
107
Member Avatar for O_mini

This is a good example of why variable and method names are important. With a method called "compareValues" it's totally unknown what returning true or false will mean. Change the name to allValuesAreDifferent and the fact that the logic has true and false the wrong way round jumps straight out …

Member Avatar for Taywin
0
3K
Member Avatar for s1lkman

What *exactly* are the problems you are having (complete error messages, actual vs expected behaviour etc)?

Member Avatar for Taywin
0
119
Member Avatar for Yarra

Use the angle to split the velocity into its horizontal and vertical components. For each tick of the clock keep the h constant, but add a small downwards increment to the vertical velocity (models the acceleration due to gravity). DIsplaying the results is stanbdrad stuff - you'll find what you …

Member Avatar for Taywin
0
110
Member Avatar for caswimmer2011

Declare and initialise the integer outside the method (but inside the class). That way each invocation of the method will use the same shared ineteger.

Member Avatar for Taywin
0
148
Member Avatar for khalidshakar

When you call anything from an actionPeformed the whole of Swing (including GUI updates) will wait until your actionPerformed returns. This is because it's all done on one thread (Swing is not thread-safe). You need your actionPerformed to start a new thread for this code so it can return immediately.

Member Avatar for JamesCherrill
0
3K
Member Avatar for anglwthnati2de

Don't put it in your Date class - that's got a clearly defined and very sensible scope now, so don't confuse it. You could call a simple JOptionPane from your main method then pass the input to the Date class. If you wanted to get more elegant you could create …

Member Avatar for anglwthnati2de
0
345
Member Avatar for mcddewitt

Currency formats assume an input in dollars. To show cents you need a floating point value, not a long which is an integer type. Declare doublePayment as a double, and set it to 10.99

Member Avatar for JamesCherrill
0
173
Member Avatar for london-G

Underlined in red - presumably you are using an IDE? Which one? "Cannot fiond symbol" means you mistyped the name OR that code is outside the scope where the name is defined, probably the latter. Where are those variables defined - in another class? Inside another method?

Member Avatar for JamesCherrill
0
105

The End.