7,116 Posted Topics
Re: Are you sure about the database update? Maybe your update button is updating the database, but there's no code to update the JTable at that point, so you don't see that it's updated? Then when you do anything that causes a repaint of the JTable you see the new data? | |
Re: You can open the file. In a loop read each line into a String. Use *indexOf* to find the `<a href="/user/` text. If it's there use *indexOf* again to find the end of the user name. Use *substring* to extract the part of the string that contains the user name. … | |
Re: Have a look at this http://stackoverflow.com/questions/5853879/java-swing-obtain-image-of-jframe basically you just create your own buffered image object, then call the JFrame's standard paint method passing your image buffer and hey presto the frame (and its contents) gets painted into your buffer. ps: you don't need to do that for the whole JFrame, … | |
Re: What ***exactly*** were you expecting, and how ***exactly*** does the actual output differ? | |
Re: You seem to assume that Integer.toBinaryString gives a string of the right length, but that's not true, Eg Integer.toBinaryString(69) returns a 7 char string, but the spec requires it to be 10 (that's why inserting 3 zeros helps). You need to pad each and every Integer.toBinaryString to the right length … | |
Re: You write a loop that reads the file in smaller pieces and writes each piece to the output file. See this thread (read right to the end for the correct solution) http://www.daniweb.com/software-development/java/threads/426232/incorrect-uploading-of-file | |
Re: Before going any further I would catch and printStackTrace any Exceptions, rather than throwing them up and hoping for the best. You are writing your output streams with the assumption that every read returns a full buffer. This is a bad assumption, especially when reading a socket stream. Also it … | |
Re: Welcome to the DaniWeb Java forum! OK, rule number 1. Don't just say "it gets errors". Always post the full text of any error messages, including the line numbers. If there are no error messages but the behaviour is wrong, explain exactly what you expected vs what actually happened. That … | |
Re: You can surround the code where that exception is thrown with a try { ...} catch, and catch the org.postgresql.util.PSQLException. In your catch block you can check the exact text of the Exception, and issue error messages or whatever. | |
Re: DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules | |
Re: Use SimpleDateFormat to parse the user input into a Date object. You can then subtract that from today's date to see if the difference is >= 21 years. | |
Re: That's really interesting, and thanks for sharing it with us all. How would you compare it (pros, cons) with java.beans.XMLDecoder? | |
Re: Norm - I had a look at the reference material the OP referred to earlier, and this is what I *think* it means: The data is coded as one continuous bit stream (ignoring byte boundaries) with values compressed by omitting (some) leading zeros. The test data consts of 4 numbers. … | |
Re: It's very dangerous to be on 1.4 - you are missing many years of essential security fixes (not to mention language enhancements). Your computer is at risk. You really should update to 1.7 immediately | |
Re: You did put in a valid user name and password (lines 12,13) I assume? | |
Re: I think you have to loop. However, auto-unboxing will allow you to use Integer objects in many places where an int is required. | |
![]() | Re: Length of an array is `.length` - not a method call so no (). Non static members have a different value for every instance of the class, so its not valid to reference them without knowing which instance you are referring to. In a static method there is no particular … ![]() |
Re: That may not be such a good idea. Most of the errors that can be caught (missing > or <, mis-spelled keywords, unmatched start/end delimiters etc) will make it impossible to parse the remainder of the file anyway. All you will get is a load of spurious messages. | |
Re: System time when Repair object was created, in millisecs? | |
Re: new ImageIcon doesn't throw an exception if it can't find the image file, so it's a good idea to try just printing image to see if it's got credible width./height etc | |
Re: Is this a Java question? You may be in the wrong forum. Try the databases forum | |
Re: Is the map too big to be read into memory (tens, even hundreds, of MegaBytes is OK)? If so you probably should be using a proper database to hold the data and do an SQL query. If you can just read it into memory then your existing code will do. | |
Re: That last ref is very useful - but note that it uses the pre-release methods in AWTUtilities. These methods were "moved" into the mainstream classes with Java 7 (version 1.7), so if yu want to do shaped windows you should be sure to upgrade to 1.7 and stick to released … | |
Re: You can use the GraphicsEnvironment class to get a list of all the GraphicsDevice objects that Java knows about, so your HDMI TV may appear in that, and may possibly appear/disappear when turned on/off? (I've never tried this) | |
Re: Can you write a "place-holder" value, eg 0, where the size needs to go, then you can overwrite that with the final value later (using a random access file). ps One byte doesn't allow for a very big file! | |
Re: YOu can't abbreviate two tests like that. You have to spell it out ` if (HW >= 39 && HW <= 43)` | |
Re: DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules This thread is a year old. Please start your own thread for your question | |
Re: That looks OK. writeObject writes the Map and its contents in a binary format that only readObject understands. If you want a readable version that can be used to write and read such Objects, take a look at XMLEncoder/XMLDecoder. If you ust want a fully human-readable version then use ordinary … | |
Re: Read the API documentation for JTextField. The introductory section has an example of exactly that. | |
Re: I'm not sure how you are using the word "previous" here, but if that's the opposite of "next" in the Iterator then... If you have your dtos in a List (rather than just a Collection) then that implies a sequence for the members, and you can get a ListIterator rather … | |
Re: As far as I can see... Your 2d array looks like `int[][] rel = new int[3][3];` then for each relation (i, j) you set the corresponding element to 1 `rel[i][j] = 1;` The size of the array depends on the number of elements in the set, and you have to … | |
Re: What exactly is the problem. Please post the full text of any error messages. | |
Re: Java 1.4 was replaced in Sept 2004. Java 5 includes mnay language enhancements, particularly to Maps and Collections. We are now on Java 7. You computer is also critically at risk because you are missing many years of security patches and fixes. To store multiple values for one key, use … | |
Re: Line 110 you declare a new local variable player1 that "hides" the one you declared on line 31. Don't declare a new variable, use the existing one (ditto for player 2). | |
| |
Re: Assuming the keys are Strings you can just loop through the `keySet()` testing each string with its `startsWith` method to select those keys that start with the desired string. | |
Re: ... or maybe not. @poojavb: if you post a lot of code like this please annotate it fully so that the learners here can understand it and learn from it. It may also be useful to post some sample input/output to confirm how well it works | |
Re: Start with a Customer class with fields for name, street etc rather than an unstructured set. Then create Repair class that has fields for Customer, device, notes (etc) You will find that the application will then be pretty easy to structure using those two main components. | |
Re: 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 | |
Re: > myArray[i] = (char)(myLongNum % 8); > it doesn't solve the problem also Are you sure - it works on my Java compiler! Whayt exactly is the error you get with this version? | |
Re: That almost looks like the pseudo-code for the solution... user provide value of A only then search using A==value1 if user provide A and B then search using A==value1 && B==value2. Where *exactly* arer you getting stuck? | |
Re: Although you can look at the iterative definition and convert it to an explicit formula, this gives a solution, no matter how efficient, that hides rather than exposes the original definition. For that reason I would go with the second approach - two arrays, x and a. Array a must … | |
Re: Line 3 corrects the value of negative salaries to zero before you check for them on line 4 | |
Re: We're not mind readers. What exactly is the complete error message? | |
Re: > so its used mainly in arrays? No, not just arrays. Anything that can iterate - including Sets, Lists etc > ArrayList<String> myStrings = ... etc > for ( String tempString : myStrings ) // works just like for arrays etc > System.out.println(tempString); in fact it's more useful with Collection … | |
![]() | Re: Although in this case your code is simpler with <this> as the listener, as a general practice it doesn't work so well. As you add more and more controls (menus, buttons, toolbars...) and maybe mouse or keyboard listeners your class gets cluttered with more and more methods whose purpose is … |
Re: Look at the pattern - all the rows are the same except on the 2nd row the 5 is replaced by a * on the next row the 4s and 5 are replace by an * on the next row the 3,4,5 are replaced... etc You can use an if … | |
Re: http://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html | |
Re: > But as I understand it the method used is decided at compile time, No, instance methods are bound at runtime based on the actual class of the object upon which the call is being made. (The method **is** determined at compile time for *static* methods). So you can simply … | |
Re: 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 |
The End.