7,116 Posted Topics
Re: 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 | |
Re: 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 … | |
Re: 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? | |
Re: 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 … | |
Re: 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. | |
Re: 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) | |
Re: 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] | |
Re: You use a variable for the switch, but you need the constants for the cases, as in [CODE]switch (dir) { case Direction.RIGHT: ...[/CODE] | |
Re: [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 … | |
Re: 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 … | |
Re: 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] | |
Re: "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. | |
Re: 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. | |
Re: @pesalakalyan read the DaniWeb Member Rules [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: [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. … | |
Re: 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 | |
Re: 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 … | |
Re: 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. ![]() | |
Re: 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. | |
Re: 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. | |
Re: 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 … | |
Re: 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 : | |
Re: 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 … | |
Re: [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 … | |
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 doing your homework for you. DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting … | |
Re: [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) | |
Re: What happened to your Company class? That's where you should have the lists of Employees and Jobs. | |
Re: [QUOTE]I wonder whether I did my convertToLatin correct or not?[/QUOTE] Well, did you test it? What was the result? | |
Re: Why the lengthy switch rather than something like result = "023456789ABCDEF".charAt(remainder) + result; | |
Re: [QUOTE]cannot find symbol symbol : variable getSelectedItem[/QUOTE] It's a method call, needs a () | |
Re: 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 … | |
Re: "Recompile with -Xlint:deprecation for details" You have been told this repeatedly. Why not do it? | |
Re: [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 = … | |
Re: 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 … | |
![]() | Re: 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. ![]() |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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. | |
Re: 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 … | |
![]() | Re: [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 … |
Re: Why not use a javax.swing.Timer to run your method(s) every 10,000 mSec? | |
Re: There's Runtime.getRuntime().traceMethodCalls(true); ... but if you can get that to work please please tell me how! | |
Re: [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. | |
Re: 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 … |
The End.