7,116 Posted Topics

Member Avatar for rotten69

i <= nums.length is the problem array is length 3, so valid indexes are 0,1,2, Your code executes with indexes 0,1,2,3

Member Avatar for stultuske
0
154
Member Avatar for ibthevivin

You can simplify this program massively in an OO way by creating a class for the bills/coins. Each instance has a value and a name. You have an array of those representing all the various bills and coins you can use. Then most of your repeated code comes down to …

Member Avatar for JamesCherrill
0
142
Member Avatar for pro_learner

I think that question needs to be clarified. Does the existing java file handle data from mysql that you now want to use in your GUI?

Member Avatar for pro_learner
0
149
Member Avatar for oldezwe

The following line (line 63) is an absolute no-no when debugging [CODE]catch(Exception e1){}[/CODE] if any problem of any kind happens in the preceding 22 lines you have just told Java to carry on as if nothing happened, and don't tell you anything. Replace it with [CODE]catch(Exception e1){ e1.printStackTrace();}[/CODE] and you'll …

Member Avatar for JamesCherrill
0
2K
Member Avatar for asif49

The first Google link for "UML class diagram" is the Wikipedia article, which half way down answers your question. That's about two paragraphs after it answers your other post about ArrayLists. You should be embarrassed.

Member Avatar for JamesCherrill
0
97
Member Avatar for sirlink99

It seems like your collision code starts running in its thread before you have created/added any players (Vector players is empty)? ArrayIndexOutOfBoundsException: 1 >= 0 ... at Game.collision(Game.java:176) line 176: players.elementAt(1)

Member Avatar for sirlink99
0
172
Member Avatar for asif49

Yes, absolutely. And they can be very useful too. Those things are called "Types", and the whole topic is called "Generics" Here's the tutorial: [url]http://docs.oracle.com/javase/tutorial/java/generics/index.html[/url]

Member Avatar for stultuske
0
97
Member Avatar for lgbagabuyo
Member Avatar for Adami

You use a variable for the switch, but you need the constants for the cases, as in [CODE]switch (dir) { case Direction.RIGHT: ...[/CODE]

Member Avatar for Adami
0
404
Member Avatar for Sweetblac2000

[CODE]JPanel tictactoe[] = new JPanel[9];[/CODE] creates an array with 9 empty (null) slots for JPanels ... [CODE]for(int i = 0; i < 9; i++) { tictactoe[i].setBorder( ...[/CODE] tries to reference the JPanel in tictactoe[i] but that array element is still null. You need to initialise (populate) every element of the …

Member Avatar for JamesCherrill
0
95
Member Avatar for asif49

We did cover this before. Your Company/Employer class should contain a list of all the Employees ans well as a list of all the Jobs. Use the list of Employees to print Employees, and the list of Jobs to print Jobs. When you assign a Job to an Employee add …

Member Avatar for JamesCherrill
0
204
Member Avatar for vaironl

This is normally done by using a JScrollPane (which has the scroll bar(s) and handles all the sizing and scrolling activity). Just create your JPanel and place it in a JScrollPane. Here's the tutorial: [url]http://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html[/url]

Member Avatar for vaironl
0
122
Member Avatar for lena1990

"database is centrilized or distrubuited" is just about where the data is stored. It doesn't matter where it is accessed from. So in your case it's stored in one location, so it's centralised. ps. This is the Java forum. You question would be better in the database forum.

Member Avatar for StephNicolaou
0
73
Member Avatar for dineshswamy

line 142 reads: if(ft.id==ip[i].t.id) so print every one of those values (including intermediates like [B]ip[i].t[/B]) immediately before that line to see which is (are) null.

Member Avatar for JamesCherrill
0
250
Member Avatar for pesalakalyan

@pesalakalyan read the DaniWeb Member Rules [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url]

Member Avatar for JamesCherrill
0
128
Member Avatar for Syrne

The ListIterator interface exists specifically to solve this problem (illegal modification of the List while it is being iterated over with a normal Iterator). Use theList.getListIterator() to get the list iterator and use that to loop thru the ArrayList - you'll be able to remove the appropriate element without generating …

Member Avatar for JamesCherrill
0
198
Member Avatar for DragoDraco

In terms of Java language, Java requires that when you construct a new instance the constructors for the class [I]and all its superclasses[/I] get run, superclasses first. To achieve that either 1. You start your constructor with a call to a superclass constructor or 2. The compiler inserts one for …

Member Avatar for JamesCherrill
0
126
Member Avatar for techgeek420

Whenever you update the vote data, call repaint(); on your PollDisplayPanel. This will result in Swing calling your paintComponent, where you will re-draw the pie chart using the latest values.

Member Avatar for EddieHappens
0
7K
Member Avatar for Daigan

[QUOTE]So what I understand from this is that the method writeFile() is saving the file with the name entered by the user and the method readFile() reads the file. Right?[/QUOTE] Right. [QUOTE]But when I input myfile2 as the filename and new for reading the file it works and invokes ouput. …

Member Avatar for Daigan
0
147
Member Avatar for sirlink99

This is just a guess, but anyway... depending on your keyboard layout, there probably isn't a key that has ! as its primary meaning. For example, on my UK keyboard I have to: press VK_Shift, press VK_1, release VK_1, release VK_Shift

Member Avatar for JamesCherrill
0
712
Member Avatar for Prisms

If you know how to read a file then: create a data structure in your program to hold the data you will read. eg You could have an arraylist of instances of a Student class that has name etc and a hashtable of courses/grades. Read the file into the data …

Member Avatar for Prisms
0
188
Member Avatar for rayden150

You seem to be using methods like writeInt, writeDouble on a RandomAccessFile. These methods write the data in its internal binary format, so you would expect to see garbage if you try to view those bytes as text.

Member Avatar for hfx642
0
223
Member Avatar for David321

With the code you posted it looks like you lost a } when you commented out all that code from line 40 in logo. It now looks like you have all your GUI creation code inside the paintComponent method, so every time it repaints it creates new stuff.

Member Avatar for JamesCherrill
0
202
Member Avatar for Unsated

Instead of all those text-style menus in dialogs, you could pop up a small window or dialog with buttons for each of the functions - that would be a more Windows-like approach. You could also decorate that window with a bank logo in the background.

Member Avatar for JamesCherrill
0
168
Member Avatar for oldezwe

The correct way to do this is with a Swing Timer, designed and optimised for exactly this kind of task: [CODE]when the button is clicked disable the button create and start a new javax.swing.Timer with a delay equal to how long you want the button disabled for, and an actionPerformed …

Member Avatar for JamesCherrill
0
239
Member Avatar for persianprez

Have a look at the [I]split [/I]method for Strings. You can use it to split your string into an array of 2 substrings by splitting at the :

Member Avatar for JamesCherrill
0
125
Member Avatar for Joey_Brown

I'd be very interested to hear how you did the "snapshot", but yes, there's no way around displaying the incremental stages of the "flipping" graphics in a loop. (But not a loop as such - that's going to mess up Swing's event thread - use a javax.swing.Timer to control the …

Member Avatar for hiddepolen
0
111
Member Avatar for umsungun

[QUOTE=umsungun;1707257]Thank you so much it is working, can i know about the how to write the code ?[/QUOTE] @zeroliken: This is why you should never just post a solution to someone else's homework. You have successfully given the OP an opportunity to cheat, but taught him nothing. Next time please …

Member Avatar for zeroliken
0
94
Member Avatar for ilovejava

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 doing your homework for you. DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting …

Member Avatar for ilovejava
0
231
Member Avatar for sleepybug

[CODE]catch (Exception e) { System.err.println("Unknown Exception");[/CODE] That's kinda dumb. The Exception knows exactly what went wrong, and in which statement, but you don't print that info. Add the following to EVERY catch in your entire system [CODE]e.printStackTrace();[/CODE] Then run it again and post the resulting error message(s)

Member Avatar for JamesCherrill
0
1K
Member Avatar for asif49

What happened to your Company class? That's where you should have the lists of Employees and Jobs.

Member Avatar for JamesCherrill
0
301
Member Avatar for nickliutw

[QUOTE]I wonder whether I did my convertToLatin correct or not?[/QUOTE] Well, did you test it? What was the result?

Member Avatar for nickliutw
0
181
Member Avatar for dayau89

Why the lengthy switch rather than something like result = "023456789ABCDEF".charAt(remainder) + result;

Member Avatar for doomsday1216
0
289
Member Avatar for BDan

[QUOTE]cannot find symbol symbol : variable getSelectedItem[/QUOTE] It's a method call, needs a ()

Member Avatar for BDan
0
430
Member Avatar for daneuchar

You have an arraylist of Objects, that happen to be Integers, which you try to use to create an array of Strings. You can't store Integers in an array of Strings. Here's what the API doc says: [QUOTE]public class ArrayStoreException extends RuntimeException Thrown to indicate that an attempt has been …

Member Avatar for daneuchar
0
1K
Member Avatar for hannah shrn j

"Recompile with -Xlint:deprecation for details" You have been told this repeatedly. Why not do it?

Member Avatar for JamesCherrill
0
272
Member Avatar for NeoSyn

[QUOTE=corliss;1704613]Firstly here is the code to randomly choose the next winning number Please use the [CODE]import java.util.Random;[/CODE] [CODE]public int WinnigNumber(){ /*used to set the range for the numbers that we will be * generating for the winning numbers */ int START = 1; int END = 13; Random randomGenerator = …

Member Avatar for NeoSyn
0
280
Member Avatar for coolsport04

So is this what you mean? 1. Write a method to sort the letters of a word and return the sorted word 2. Read a file of real words 3. For each real word call sort, then add the sorted word as key and the real word as value to …

Member Avatar for thines01
0
281
Member Avatar for buchanan23

Round the results of your calculations to 2 decimal places (cents) as you perform them, or just hold and calculate all monetary amounts in integer cents. Loans are not normally calculated in fractions of a cent.

Member Avatar for buchanan23
0
250
Member Avatar for bops

I've had to do this kind of thing more than once or twice, and I've never found a better way than that (apart from minor code tweaks). I put all that code into a small generic utility class WindowDragger, so the code for the main window just has to call …

Member Avatar for JamesCherrill
0
2K
Member Avatar for maverick420
Member Avatar for asif49

Simple rule of thumb: Make all your variables private. More complex real-world version of this rule: Make all your variables private. If, later on, you discover that other classes need some kind of access to something, create a public method. In this particular case Scanner is a part of your …

Member Avatar for asif49
0
119
Member Avatar for regogo

That's not how these forums work. Ask for help after you've done some work yourself. Two minutes with Google will give you all the information you could possibly want on bubble sorts in Java.

Member Avatar for JamesCherrill
0
121
Member Avatar for sandman64

reverser.toString(); This line creates a String and returns it, but you do nothing with the returned value. It doesn't change reverser in any way.

Member Avatar for JamesCherrill
0
199
Member Avatar for wannas

You could try setting a timeout before the receive ( setSoTimeout(2000) ) and see if your code continues as expected after the timeout elapses (catches a java.net.SocketTimeoutException) - this would confirm that your code is OK but you are not receiving any UDP packets on your port (maybe a firewall …

Member Avatar for NormR1
0
201
Member Avatar for begueradj

[QUOTE=begueradj;1704751]why have we to use lot of small panels on the original one ? can we just use g.fillRect() for drawing the rectangles with different colors ?[/QUOTE] Just for displaying the maze there's probably little difference between the two approaches. If you want to interact with it in any way …

Member Avatar for JamesCherrill
0
430
Member Avatar for aanders5
Member Avatar for Ezzaral
0
188
Member Avatar for Deincross

There's Runtime.getRuntime().traceMethodCalls(true); ... but if you can get that to work please please tell me how!

Member Avatar for Deincross
0
389
Member Avatar for jhamill

[QUOTE]I'm having some trouble with the logic though[/QUOTE] Do you really expect someone to read all that undocumented code, guess exactly what it is supposed to do, then work out in what way it's doing the wrong thing? You need to explain exactly what problem you want us to solve.

Member Avatar for JamesCherrill
0
138
Member Avatar for logicmonster

You're getting into a tangle with inner classes and whether they are static or not. Rather than get into all that obscure theory, I would not make them inner classes at all. You can keep them all in the same package if you need to group them together for access …

Member Avatar for logicmonster
0
262

The End.