7,116 Posted Topics

Member Avatar for 47pirates

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?

Member Avatar for dougWill
0
3K
Member Avatar for iEpic

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. …

Member Avatar for JamesCherrill
0
97
Member Avatar for nikolaos

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, …

Member Avatar for nikolaos
0
246
Member Avatar for pendo826

What ***exactly*** were you expecting, and how ***exactly*** does the actual output differ?

Member Avatar for Krokcy
0
188
Member Avatar for trishtren

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 …

Member Avatar for trishtren
0
177
Member Avatar for B204

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

Member Avatar for JamesCherrill
0
954
Member Avatar for delta_frost

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 …

Member Avatar for delta_frost
0
372
Member Avatar for Rhysorourky

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 …

Member Avatar for JamesCherrill
0
118
Member Avatar for karthikprs

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.

Member Avatar for JamesCherrill
0
259
Member Avatar for VernonDozier

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

Member Avatar for JamesCherrill
0
2K
Member Avatar for karthikprs

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.

Member Avatar for karthikprs
0
2K
Member Avatar for Aviras

That's really interesting, and thanks for sharing it with us all. How would you compare it (pros, cons) with java.beans.XMLDecoder?

Member Avatar for Troy III
1
396
Member Avatar for trishtren

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. …

Member Avatar for NormR1
0
464
Member Avatar for raviaaaa

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

Member Avatar for DavidKroukamp
0
567
Member Avatar for atummapala
Member Avatar for StephenHawking9

I think you have to loop. However, auto-unboxing will allow you to use Integer objects in many places where an int is required.

Member Avatar for JamesCherrill
0
171
Member Avatar for sammoto

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 …

Member Avatar for sammoto
1
415
Member Avatar for msd153

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.

Member Avatar for NormR1
0
203
Member Avatar for GlenRogers
Member Avatar for GlenRogers
0
161
Member Avatar for GlenRogers

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

Member Avatar for GlenRogers
0
241
Member Avatar for london-G
Member Avatar for stultuske
0
180
Member Avatar for GlenRogers

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.

Member Avatar for GlenRogers
0
106
Member Avatar for pooja.shinde

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 …

Member Avatar for JamesCherrill
0
612
Member Avatar for Krokcy

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)

Member Avatar for Krokcy
0
283
Member Avatar for trishtren

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!

Member Avatar for trishtren
0
182
Member Avatar for RaymondTracer

YOu can't abbreviate two tests like that. You have to spell it out ` if (HW >= 39 && HW <= 43)`

Member Avatar for RaymondTracer
0
207
Member Avatar for ubi_ct83

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

Member Avatar for JamesCherrill
0
665
Member Avatar for GlenRogers

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 …

Member Avatar for JamesCherrill
0
187
Member Avatar for GlenRogers

Read the API documentation for JTextField. The introductory section has an example of exactly that.

Member Avatar for GlenRogers
0
269
Member Avatar for raviaaaa

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 …

Member Avatar for JamesCherrill
0
365
Member Avatar for shasha56959

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 …

Member Avatar for NormR1
0
158
Member Avatar for anilchuthur
Member Avatar for anilchuthur
0
329
Member Avatar for raviaaaa

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 …

Member Avatar for JamesCherrill
0
409
Member Avatar for DanCuster

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).

Member Avatar for JamesCherrill
0
641
Member Avatar for malsmit2014
Member Avatar for GlenRogers

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.

Member Avatar for JamesCherrill
0
112
Member Avatar for hyung101

... 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

Member Avatar for poojavb
0
3K
Member Avatar for GlenRogers

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.

Member Avatar for GlenRogers
0
338
Member Avatar for zazizu

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
0
91
Member Avatar for enakta13

> 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?

Member Avatar for JamesCherrill
0
91
Member Avatar for 47pirates

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?

Member Avatar for 47pirates
0
308
Member Avatar for km2011

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 …

Member Avatar for km2011
0
193
Member Avatar for Valiantangel

Line 3 corrects the value of negative salaries to zero before you check for them on line 4

Member Avatar for JamesCherrill
0
97
Member Avatar for Valiantangel
Member Avatar for JamesCherrill
0
212
Member Avatar for Valiantangel

> 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 …

Member Avatar for JamesCherrill
0
139
Member Avatar for chudapati09

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 …

Member Avatar for JamesCherrill
0
180
Member Avatar for vilas_tadoori

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 …

Member Avatar for NormR1
0
997
Member Avatar for enakta13
Member Avatar for mKorbel
0
823
Member Avatar for sciwizeh

> 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 …

Member Avatar for JamesCherrill
0
1K
Member Avatar for kunaldinde

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 stultuske
0
98

The End.