7,116 Posted Topics
Re: Painting: see http://docs.oracle.com/javase/tutorial/uiswing/painting/ Timing: start a javax.swing.Timer, and return. Every time the timer fires you can update whatever needs updating and return. Inbetween the timer firings Swing will be free to update the screen. | |
Re: The info you need is in the Oracle tutorials [here](http://docs.oracle.com/javase/tutorial/essential/io/charstreams.html) | |
Re: MVC! Separate the GUI from the game logic as much as possible. Store everything in the game logic, and provide accessors for any user interface (console, GUI, HTML etc) to enter moves and keep them selves up to date. | |
Re: Within the limits set by the individual components' min/max sizes, GridBagLayout distributes the available space according to the x/y weights - the higher the weight the more of the available space goes to that component. If you set all the weights equal then, within the min/max constraints, the window should … | |
![]() | Re: You can't just print an array by saying System.out.println(myArray); all you get is a coded output like [[Ljava.lang.String;@73a175] that says it's an array of Strings at a particular address (etc) Either print the elements one at a time in a loop, or use a method from the Arrays class to … ![]() |
Re: You have been posting here long enough to know that you should give the complete details of any error messages, and explain what symptoms you are seeing. ps CHECK YOUR SPELLING (AGAIN) | |
Re: That's a stupid amount of test data for code that isn't working yet. Start with one two or three elements. Add some print statements to your code to see which loops/class are being executed with which values. | |
Re: The symbol it can't find is "showMessageDiloge" (see line 4 of the error!) It's because you spelled it wrong. See the API doc for JOptionPane for the correct spelling | |
Re: What you are asking for is a lot simpler than the code you already have, so why are you finding it difficult? (You did write that code from scratch, didn't you?) Maybe if you explain exactly why you are stuck then we will know how best to help you. | |
Re: The loops are confusing this. Try a simpler example int i = 1; System.out.println(i++); System.out.println(i); int j = 1 System.out.println(++j); System.out.println(j); | |
Re: There's two parts to this: Easy: When doing the DFS and you find a path, instead of stopping just add the path to an ArrayList and keep going. The DFS algorithm should ensure every path is visited exactly once. More interesting: exactly how do you define and instantiate a single … | |
Re: Just because Soduku is displayed in a 2D grid that doesn't mean you have to store it internally like that. And there are very good reasons why you shoudn't. You have 81 cells. You want to look at groups of cells like {1,2,3,4,5,6,7,8,9} - a "horizontal row", or {1,10,19...} - … | |
Re: length is like an instance variable that arrays have. It contains the length (size) of the array. In this case it's telling you how many command line arguments there are | |
Re: Code posting does work - start your message, click the code button you should see a new window in which you can post your code. If that's not working can you post a screen shot that shows what your'e trying? Thanks | |
Re: From the small amout of info you have given I wuld say yes, that sounds like MVC. | |
Re: If you have have if (instance of A) do A's version of something... if (instance of B) do B's version of something... then that's usually a sign that A and B should be subclasses of some common superclass, with `something` as a method that is overridden in A and B | |
Re: 7 works because on lines 32-36 you print all its fields explicitly. For the others you use `System.out.println(Supplies);` This is all about the toString() method... Every Java class inherits a toString() method from the Object class, so methods like println use that to convert the object you want to print … | |
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: BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Type name: "); String name = reader.readLine(); System.out.println("Hello " + name); System.in is the InputStream associated with the console. You create a BufferedReader using that stream, then you can call its `readLine()` method to get the user's input. | |
Re: It's a bit of a cludge, but why not move b1 to some place way out of the picture? | |
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: I want a Clapton special edition black Fender Stratocaster. You get me my stratocaster and I'll do your homework for you. If that's not possible then maybe you should read the forum rules that you agreed to when you joined DaniWeb, including "Do provide evidence of having done some work … | |
Re: This is not a homework service. What do YOU think the benefits are? | |
Re: That's mergesort, not margesort. That's probably why you had trouble finding it on Google. Anyway, Google "mergesort" and you'll get a huge range of tutorials that explain it. [This one](http://www.codenlearn.com/2011/10/simple-merge-sort.html) seems very clear and not too technical, so it's a good place to start. | |
Re: ^ +1 to all those, plus they are more likely to be up-to-date | |
Re: Everything to do with Swing (eg painting the screen, running actionPerformed methods) happens on a single thread - the "Event Dispatch Thread", or "EDT", or "Swing thread". Your actionPerformed is run on the EDT, which means that once your actionPerformed method starts NOTHING else will happen in Swing - no … | |
Re: You may not want to use that code for a number of reasons including: Copying someone else's code for your homework is cheating It corrupts the data by discarding the newline delimiters It's a memory hog if the files are large (uses double the file size) It does horribly inefficient … | |
Re: You need to look more closely... there is no such thing as a null char in Java. What exactly are you seeing? | |
Re: Highly highly unlikely that you have found a new bug in System.err.println after all this time. System.err is intended for logging system error messages for the developer/administrator, not for messages to the user. If you mix it with System,out and System.in you can't guarantee the exact order in which it … | |
Re: You get the name *before* you enter the loop, so that's only executed once, at the start of the program. Your main two options are: 1. repeat lines 21/22 just before the end of the loop, so you ask for "name or stop" before starting the next pass of the … | |
Re: Is it wrong? In what way? Do you have an error message? Does it goive the wrong results? You must tell us everything you know if you want help. | |
Re: Builder_1: 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 got so far and someone will help you with any detailed questions you may have. | |
Re: If you want to fix the problem then yes, of course, you will have to change the code. Yourr methods are designed to take the old balance as a parameter and return the new balance. Right now you are ignoring the new balance that's returned. You need to asssign that … | |
Re: Not that I know of, but its easy enough to loop through your array printing the values (with commas inbetween) to a PrintStream based on the output file. | |
Re: Primitives like int, char, float, boolean are not Objects, so the language is not 100% OO. The reason was for efficiency and speed - primitives have much lower overheads than objects. | |
Re: Just have a method that re-enables the components, and call that as part of whever listener is handling the close of the other window. | |
Re: Is that XML correct? shouldn't <Account AccountNumber="1234567890"> be <Account> <AccountNumber="1234567890"> given how you are parsing it? | |
Re: That's not enough of the code to see why a variable should still be null, but for starters try printing `out` and `txtmsg` just before that line to see which is null. | |
Re: By "screen" do you mean the console window, as in System.out? If so, be aware that the console output device may be to a printer or a sequential file, in which case "clear the screen" makes no sense, and attempting to execute a "cls" as a system command will have … | |
Re: That line is OK, but you have an error on lines 11 and 18 where the capitalisation of the variable name is different. It's pointless trying to run a program if there are compiler errors. | |
Re: Exactly the same reason, exactly the same fix. If you want a \ in your Regex then you have to code two \ chars in the Java String literal, because \ is used in Java String Literals for special characters like \n (newline) | |
Re: Recursion is the answer if you want to hand-code this. The basic structure goes like (pseudo code): method searchDir(Dir d) { for each File f in d if f is an ordinary file check it against the search criteria if f is a directory call searchDir(f) NB: By now you … | |
Re: Can you explain something for me please? I thought the transition table for a DFA looks somnething like table[current state][next token] = next state so conceptually I'd expect to see something like // state n is inside a a comment, n+1 is normal parsing table[*]['{'] = n; // { takes … | |
Re: (because chars are integer numeric values you can simply use them to index into an array of counts - in which case that algorithm is as efficient as you will get.) | |
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 | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question | |
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: Where's the definition of the Node class? | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question |
The End.