7,116 Posted Topics

Member Avatar for harsimran05

Because your dates are in a known fixed format, it's easy to use the SimpleDateFormat class to convert the String to a Date, and vice-versa. Java Dates are essentially millisecs since some arbitrary zero point, so you can do arithmetic on them. For more interesting date manipulation convert to a …

Member Avatar for JeoSaurus
0
97
Member Avatar for gedas

You can simplify this to two cases as follows: [CODE]NB: keep track of how much space is remaining on the current line at all time split input into array of words print the first word for every remaining word: if it fits print " " + the word else print …

Member Avatar for Zaad
0
227
Member Avatar for hackit

Pointers are only useful if you are working with memory locations. Java memory management is completely automatic, there's no context in which you need to manipulate the address of anything. However All Java variables of type Object or array are what Java calls "reference" variables. They contain a reference to …

Member Avatar for hag++
0
120
Member Avatar for SasseMan

Animation in Swing isn't hard to set up. Use a javax.swing.timer to run a method every (eg) 50mSec. In that method update the sizes/positions etc of your animated objects, and call repaint() for the JPanel (or whatever) that contains your animation to trigger a screen update. Override the paintComponent method …

Member Avatar for SasseMan
0
118
Member Avatar for plasticfood

Aviras is right. The OP's code includes setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); so this looks like Swing, in which case it's already double-buffered unless you have explicitly turned off double buffering. It's almost always a mistake to override paint, you should override paintComponent instead. Overriding update(Graphics g) is futile, as update is never called …

Member Avatar for NormR1
0
303
Member Avatar for behemothdave

(Norm: am I going bonkers here? Why no NPE's?) [CODE]TVShow[] myShowArray = new TVShow[TV_MAX]; .. for(d = 0; d < TV_MAX; ++d) .. myShowArray[d].setShowName(tvInput);[/CODE] This shouldn't work. Have you been ignoring null pointer error messages? Line 1 creates an array of TVShow pointers, initially all null Line 3 tries to …

Member Avatar for behemothdave
0
248
Member Avatar for hackit

That seems like strange advice. Java was designed to be multi-platform, which is great, but the downside is that it doesn't tie strongly into the system of any one environment. You'll find that all kinds of system calls that you would use in C* are not available in Java unless …

Member Avatar for hackit
0
115
Member Avatar for asdftrew

[CODE]public static void Calculate(int [] Years, double [] Population, int Size, double CurrentPercent, double LargestPercent, int LargeYear1, int LargeYear2)throws IOException { ... CurrentPercent= (((Population[counter+1])/(Population[counter]))-1)*100; ... LargestPercent=CurrentPercent; LargeYear1= Years[counter]; LargeYear2= Years[counter+1]; [/CODE] This code isn't going to work because Java parameters are passed as a copy - ie when you call …

Member Avatar for JamesCherrill
0
143
Member Avatar for hackit
Re: help

To control the loop like that you just need an ordinary local variable within the method (which cannot, by definition, be static). If you need a single value that is shared between all instances of the class and all methods of the class then declare it static, but [I]outside [/I]any …

Member Avatar for hackit
0
183
Member Avatar for hackit

Sorry purijatin but that's not right, although it is a common mistake. All calls in Java are calls by value. There is no such thing as a call by reference in Java. @hackit: I have no idea what kind of problem you have in mind, but all calls in Java …

Member Avatar for JamesCherrill
0
190
Member Avatar for Whilliam

AFAIK there's no sensible way to merge cells. The only work-around is to use a custom cell renderer and work out what to display in each of the individual cells so it looks like they are combined into one. - not easy or elegant, but possible. Setting background color for …

Member Avatar for JamesCherrill
1
99
Member Avatar for Zippyvinman

Hint: [CODE]if(numstreet == 1)street = "Port Washington Boulevard"; else if(numstreet == 2) street = "Main Street"; etc[/CODE] You should use an array of Strings for this: [CODE]String[] streets = {"Port Washington Boulevard", "Main Street" ... street = streets[numstreet-1]; // first element is number 0[/CODE] Simple way to save the number …

Member Avatar for JamesCherrill
0
134
Member Avatar for chiiqui

^ yes. int[] a is also documented in the official tutorials [QUOTE]You can also place the square brackets after the array's name: float anArrayOfFloats[]; // this form is discouraged However, convention discourages this form; the brackets identify the array type and should appear with the type designation. [/QUOTE] [url]http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html[/url] ps …

Member Avatar for JamesCherrill
0
188
Member Avatar for kiswah03

1. By overriding paint(Graphics g) you have taken responsibility for painting the whole applet - including the combo box. Normal solution is to call super.paint(g) as the first line of your paint so everything "normal" gets painted, then go on to draw your shapes. 2. the triangle is offset because …

Member Avatar for JamesCherrill
0
143
Member Avatar for chiiqui

[QUOTE=chiiqui;1642087]you cannot shuffle double numbers[/QUOTE] Would you like to justify that somewhat surprising statement?

Member Avatar for JamesCherrill
0
922
Member Avatar for thebigbroski

... or, since this is 2011, you can use the enhanced for loop from Java 1.5 A common solution to this problem is to make a copy of the original list and iterate thru that while updating the original. [CODE]ArrayList<Mouse> master = ..... ArrayList<Mouse> copy = new ArrayList<Mouse>(master); // copies …

Member Avatar for JamesCherrill
0
123
Member Avatar for vishalbhavsar

You can read/write a RandomAccessFile using your own code to convert your objects to/from bytes of data. You can use Java ObjectOutputStream / ObjectInputStream to write/read simple or complex objects (including arrays & collections) with a single statement. You can use XMLEncoder /XMLDecoder to encode/decode simple or complex objects (including …

Member Avatar for JamesCherrill
0
178
Member Avatar for chiiqui

This is a duplicate of the OP's post [url]http://www.daniweb.com/software-development/java/threads/381276[/url] where it has already been answered.

Member Avatar for JamesCherrill
0
180
Member Avatar for harsimran05

I don't understand your request. Perhaps an example would help? If the text is "1-2year" what EXACTLY would you get when you "extract only numeric data"?

Member Avatar for JamesCherrill
0
76
Member Avatar for chiiqui

Here's a little pseudocode template that shows the general approach. It will loop asking for input and diagnosing exceptions and failed validation tests until good input is received [CODE]boolean inputIsOK = false; while (! inputIsOK) { prompt user try { get input if (input < 0 && input >= size) …

Member Avatar for chiiqui
0
3K
Member Avatar for harsimran05

[CODE]ResultSet rs=ps.executeQuery(); ps.setString(1,tp);[/CODE] Maybe you would do better with these two lines the other way round?

Member Avatar for JamesCherrill
0
83
Member Avatar for pro_learner

I guess you can call it whatever you like, although you would have a lot more success finding stuff if you used the same words as everyone else. Anyway, Googling [I] java move file [/I] gives this as the first hit: [url]http://www.java-forums.org/new-java/440-how-move-file-another-directory.html[/url] and this as the third [url]http://download.oracle.com/javase/tutorial/essential/io/move.html[/url] the second …

Member Avatar for JamesCherrill
0
538
Member Avatar for slasherpunk

Because on line 7 you have a new Thread(...), so there you create a Thread instance, just like you can create a String or any other kind of Object.

Member Avatar for JamesCherrill
0
172
Member Avatar for glamourhits

Have you run your program? In what exact way does its output differ from the output you expect? The calculations for deductions seem to be present and sensible (lines 51-62)

Member Avatar for glamourhits
-1
162
Member Avatar for Rivka Schwartz

One of the joys of Java is that there isn't often a need to do that. Maybe X is found to be insufficient in some way, and needs to be enhanced with a second parameter. Java polymorphism means you can keep the old version, and add the new version alongside …

Member Avatar for Rivka Schwartz
-1
173
Member Avatar for gispe

The "null error" (presumably null pointer error) also tells you the exact line number where it happened. Would you like to tell us, or do we have to guess?

Member Avatar for Ezzaral
0
165
Member Avatar for Duki

ArrayLists are serialisable, so if you put all your Shelves into an ArrayList<Shelf> object you can write that to XML as a single object, and read it back with a single read. How simple is that?

Member Avatar for JamesCherrill
0
221
Member Avatar for Mylo92

Is this a Java question? Java chars and Strings are 16 bit Unicode with support for all those langauges and more, but LONGVARCHAR is nothing to do with Java

Member Avatar for JamesCherrill
0
90
Member Avatar for mozy1691

In every one of your catch blocks you need to print the information about the exception - this shows exactly what went wrong and where (line number). By not printing this info you do not know anything except that an exception was thrown. To print the details add the following …

Member Avatar for NormR1
0
229
Member Avatar for reemhatim
Member Avatar for JamesCherrill
0
54
Member Avatar for taga1989

Start with this: [url]http://www.daniweb.com/software-development/java/threads/99132[/url]

Member Avatar for muthu@tent
0
153
Member Avatar for Matth963

ca1.get(Calendar.MONTH + 1) Calendar.MONTH is an int constant signifying "month", so MONTH+1 is another int constant signifying (I don't know what), so it get's the wrong field. You need (ca1.get(Calendar.MONTH) + 1)

Member Avatar for Matth963
0
261
Member Avatar for jiraiya

I don't [I]think [/I]you can use getResource... for things outside the jar/classpath (hopefully someone will correct me if I'm wrong...). However, this little snippet from deep in my old code box will give you a File reference to the jar that the class in which you execute this code came …

Member Avatar for JamesCherrill
0
15K
Member Avatar for sha11e

java,exe takes the name of your [I]class[/I], not the name of your class [I]file[/I]... so that should be simply [B]java main[/B]

Member Avatar for JamesCherrill
0
366
Member Avatar for traxzer

cannot find symbol symbol : variable JOPtionPane Java is case-sensitive JOPtionPane != JOptionPane getKontonummer() is not a method of that class, it's in class Konto

Member Avatar for JamesCherrill
0
2K
Member Avatar for sathya88

That's not what message digest does. Google [I]java messagedigest tutorial[/I] to find out more. Google [I]java encryption decryption[/I] to find lots of tutorials and sample code (Now, that wasn't hard was it? Next time maybe try Google first?)

Member Avatar for JamesCherrill
0
115
Member Avatar for winecoding

Scanner is useful when you know what kind of data to expect before you read it. From your description it sounds like you should use a BufferedReader, read one complete line at a time, then parse it for delimiters etc yourself.

Member Avatar for JamesCherrill
0
250
Member Avatar for janice91
Member Avatar for JamesCherrill
0
125
Member Avatar for chiiqui

I had a quick look at that code and nothing appears to inefficient. There's certainly nothing wrong with the multiple || in the if. I would just tidy up the formatting, and a few comments to explain what each part of the code is supposed to achieve, then get on …

Member Avatar for chiiqui
0
138
Member Avatar for esdel

If you have no programs written in Java then you don't need Java. If you have any programs written in Java (of which there are many) then you need a Java Runtime Environment, and it's best to have one with the latest security fixes.

Member Avatar for jwenting
0
200
Member Avatar for dahan

[url]http://www.java.com/en/download/whatis_java.jsp[/url] [url]http://en.wikipedia.org/wiki/Java_%28programming_language%29[/url]

Member Avatar for peter_budo
-1
116
Member Avatar for Jessurider

You could use the transform(AffineTransform at) method on your Path2D star1, with an AffineTransform obtained from AffineTransform.getRotateInstance(double theta, double anchorx, double anchory) to rotate it by any desired angle AffineTransformations look very scary, and often they are, but in essence they take a shape and change it by stretching, skewing, …

Member Avatar for Ezzaral
1
156
Member Avatar for k34b

[url]http://download.oracle.com/javase/tutorial/java/javaOO/objectcreation.html[/url]

Member Avatar for k34b
0
50
Member Avatar for Bowsan22

[CODE]print "0-59: " loop through the grades array if grades[i] >0 and <=59 print "*" print a newline[/CODE] You can repeat this for each line of the histogram or you can get smart and work out how to (a) do it inside another loop or (b) put that code in …

Member Avatar for hag++
0
253
Member Avatar for Nathan_11
Member Avatar for JamesCherrill
-1
120
Member Avatar for lena1990

You can use any language you want for any text you display to the user. You just need to check that the font you are using has all the necessary characters. French accented characters should be OK on any American or European operating system version.

Member Avatar for JamesCherrill
0
71
Member Avatar for sha11e

s1.toCharArray() is simpler. In Java a String is an object with many useful methods, and a char is a 16 bit numeric primitive which can be used to hold a single unicode value. A char array is just an array of 16 bit numbers, and it's whatever size you declare …

Member Avatar for JamesCherrill
0
3K
Member Avatar for chikkisherry

Create a BufferedImage object, get its Graphics2D [url]http://download.oracle.com/javase/tutorial/2d/images/drawonimage.html[/url] use your existing paintComponent method to draw the panel on that Graphics2D save your BufferedImage to a file [url]http://download.oracle.com/javase/tutorial/2d/images/saveimage.html[/url]

Member Avatar for JamesCherrill
0
973
Member Avatar for harsimran05

Lines 55/57 are a very bad idea. If an exception is thrown you have chosen to ignore it completely. Unless you are expecting the exception and know that it's OK, you should always start out by printing all the info related to the exception: [CODE]catch (Exception ex) { ex.printStackTrace(); }[/CODE]

Member Avatar for JamesCherrill
0
163
Member Avatar for sirlink99

It would rather destroy the point of the policy file if you could change it from anything you download! Signing the applet is the normal solution.

Member Avatar for mKorbel
0
517

The End.