7,116 Posted Topics

Member Avatar for irock_4you

DaniWeb Member Rules: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] 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 …

Member Avatar for IceFox16
0
296
Member Avatar for gahhon

You can declare it, but you cannot initialise an array without specifying its size. (The size can be a variable, eg ask user how many, input integer, use that as size to initialise array)

Member Avatar for cwarn23
0
122
Member Avatar for plasticfood

You add two panels to your window, which appears to have the default (ie Border) layout. You don't specify where to place them so you get the default value, and they are both placed in the same place, so you only see the second one. Two better ways to do …

Member Avatar for plasticfood
0
144
Member Avatar for thebiff

In your constructor, lines 17-23 you have all the assignments the wrong way round.

Member Avatar for thebiff
0
268
Member Avatar for bibiki

Hi bibiki. What I'm not seeing here is any code to update the contents of the JTable when the database is updated. GUI methods like update or repaint won't achieve anything unless you change the data in the JTable first.

Member Avatar for bibiki
0
556
Member Avatar for getmet
Member Avatar for mattnguyen45

The constructor is defined with 4 parameters (three of which shouldn't be there) and you call it with 1 parameter so that's an error. You also need to decide whether your methods are called getXXX or findXXX

Member Avatar for JamesCherrill
0
214
Member Avatar for softswing

You're just going to have to read the source file,and write a copy to an output file, replacing line end characters when you encounter them. Provided you use buffered streams for both files there's not a lot you can do to affect the performance.

Member Avatar for softswing
0
124
Member Avatar for Ranek

Hi Ranek I see no one has replied yet. Maybe that's because. like me, they can't understand your statement of requirement? I've read it twice, and I still don't know what it is you want to do. Maybe it would help to post a short before/after example showing what was …

Member Avatar for Ranek
0
180
Member Avatar for geeerald1131

Create a class for your next page - just like the one you have already done. In the action listener for your next button hide the first page and create a new instance of the second page. If the second page needs any info from the first you can pass …

Member Avatar for JamesCherrill
0
325
Member Avatar for solomon_13000

"wrong results" doesn't help identify anything. But, it's probably easier & quicker to use indexOf to get the indices of the first ':' and '|' and substring the part between those two indexes.

Member Avatar for JamesCherrill
0
93
Member Avatar for Stjerne

Sounds like you're heading in the right direction. A class that creates the (private) array, with methods for min/max etc. A testing class with a main method that creates an instance of the number class and calls its methods to get values that it displays. I think you've got enough …

Member Avatar for JeffGrigg
0
166
Member Avatar for JamesCherrill

The sort methods for collections specifies that the parameter must be a collection of objects that implement Comparable for their own class or superclass, eg [CODE]public static <T extends Comparable<? super T>> void sort(List<T> list)[/CODE] Can anyone tell me how to define an ArrayList that will only accept such objects? …

Member Avatar for ~s.o.s~
0
187
Member Avatar for rezial

Your problem may be with the immediately preceding if statement(s). Omitting the comments you have [CODE]if (some boolean expression) }[/CODE] but the language requires that a statement or block follows the boolean expression, even if it's only a solitary ;

Member Avatar for JamesCherrill
0
200
Member Avatar for yup790

For "real" programming it's a choice of Java or C#.net The language itself isn't any big deal, once you've learned one or two you can pick up new ones very quickly. What takes the time, and where you will be making your real investment is in the libraries, ie the …

Member Avatar for JamesCherrill
0
257
Member Avatar for dancks

First major mistake is this [CODE]catch(NullPointerException e) { }[/CODE] Did you get an NPE when you ran your code? You don't know, and neither do we. Before you do anything else fix this blunder by putting an e.printStackTrace() in the catch and run it again. Either way - why are …

Member Avatar for JamesCherrill
0
200
Member Avatar for Blink383

First pass thru the loop i is 0, Data[i-1] is Data[-1] -> ArrayIndexOutOfBoundsException: -1

Member Avatar for Taywin
0
372
Member Avatar for 5minutes

Your methods need some work: You should do the calculations using the values that are passed in as parameters You should return the answer via a "return" statement. So - you don't need any of the variables you declared on lines 3-9 When you have fixed these you can write …

Member Avatar for JeffGrigg
0
171
Member Avatar for matharoo
Member Avatar for lena1990

Nobody will be able to help you without more information. Can you post your code?

Member Avatar for JamesCherrill
0
80
Member Avatar for BaldingEar

You pass the variable "payment" as the last parameter to that method, but you have never initialised(given a value to) payment before making the call. Given tha the method is supposed to calculate payment, I can't see why you need to pass it as a parameter at all.

Member Avatar for BaldingEar
0
337
Member Avatar for rarment

Your recursion must be looping indefinitely, so add some print statements to show the values of the key variables on each iteration.

Member Avatar for JamesCherrill
0
199
Member Avatar for sirlink99

[QUOTE=sirlink99;1658160]... I still don't know where the null pointer exception is.[/QUOTE] [CODE] Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at CharacterAnimation.run(CharacterAnimation.java:45)[/CODE] Now then, that wasn't so hard was it? CharacterAnimation.java: line 45 is[ICODE] draw.reDraw();[/ICODE] , so the only way to get an NPE from that is if [ICODE]draw [/ICODE]is null - ie …

Member Avatar for sirlink99
0
151
Member Avatar for gahhon

Math.pow returns a double, but you can convert that to an int in your method and return the int, if that's what you want.

Member Avatar for gahhon
0
149
Member Avatar for Dersev
Member Avatar for JamesCherrill
0
126
Member Avatar for PHkiDz

You could change your permute method to return the permuted Strings, rather than being void. Then you will be able to call it from your GUI and display the results it returns.

Member Avatar for JamesCherrill
0
236
Member Avatar for Mi_99

Your array of Shapes starts out containing 20 nulls which get replaced by Shapes when you add a new Shape. It looks like the var count contains the number of Shapes currently in the array, so that it what you need for the upper limit of your for loop - …

Member Avatar for JamesCherrill
0
203
Member Avatar for gahhon

The String method charAt(int position) returns a single char, there's no conversion needed. What didn't you understand about Stevanity's posts?

Member Avatar for stevanity
0
90
Member Avatar for NormR1

Yes, Eclipse does this - it has a number of variants on name shadowing that you can configure for warning or not.

Member Avatar for ~s.o.s~
0
182
Member Avatar for hessian26

Add an ActionListener to the "next" button. In the listener you test each radio button to see if it's checked and, if it is, take the appropriate action (eg create a new instance of the appropriate class) Now write some code...

Member Avatar for mKorbel
0
183
Member Avatar for winecoding

They are Generics - a way of specifying what kind of Objects can be used for the keys and values of the map. Read all about it here: [url]http://download.oracle.com/javase/tutorial/java/generics/index.html[/url] The for (xxx : yyy) syntax is the "enhanced for loop" yyy must be some kind of collection of xxx's, the …

Member Avatar for JamesCherrill
0
165
Member Avatar for ferretfool0x77

You would normally use a template something like this: [CODE]String fileName = ""; while (fileName.equals("")) { try { // get the file name - if successful fileName will not be "" } catch(...) { // do error message fileName = ""; // force it round the loop again } }[/CODE]

Member Avatar for skoiloth
0
240
Member Avatar for gunjannigam

You may need to setFocusable(true); on your JPanel followed by requestFocus();

Member Avatar for gunjannigam
0
8K
Member Avatar for coco24

Simple way: create the object as a JLabel with an ImageIcon. Put it in a JFrame. In response to keyboard input use the JLabel's setLocation method to move it.

Member Avatar for JamesCherrill
0
82
Member Avatar for sohiabmaroof

This is very confusing. You create a model called [ICODE]defaultTableModel [/ICODE]and have lots of code that works with this model, but the model that's actually in the JTable (at least until line 51) is the completely different one whose definition begins [CODE](new javax.swing.table.DefaultTableModel( new Object [][] { {"asdf",[/CODE]

Member Avatar for sohiabmaroof
0
2K
Member Avatar for java.util

After that input you call the method at line 30 which will drop thru to the while at line 47. Which is a very interesting loop while (tallPosisjon <= famousFinalFour.length()) neither tallPosisjon nor famousFinalFour seems to change inside the loop, which means if it executes right thru once it will …

Member Avatar for javaAddict
0
1K
Member Avatar for Majestics

Do you have any kind of specification for what the library will do? And what are you allowed to use to get at hardware events like mouse button clicked?

Member Avatar for Majestics
0
116
Member Avatar for Majestics

I recently posted a little sample for moving a Swing component with a mouse here [url]http://www.daniweb.com/software-development/java/threads/375002[/url] it drags a JLabel in a JFrame, but the original version used to drag an undecorated window around the screen. You should be able to use it with almost zero changes. J

Member Avatar for Kyberium
1
277
Member Avatar for nickh2o

That's a good start. Now you need to work out how many of each note/coin. Move away from your computer, sit down with pencil & paper, and work through the 3 sample runs solving them by hand. Think about exactly what you have to do (in complete detail) to get …

Member Avatar for nickh2o
0
6K
Member Avatar for SasseMan

You have to do the same thing - subclass them with a custom paintComponent. BTW, if you're on Java 7, take a look at the new shaped/translucent window support.

Member Avatar for mKorbel
0
5K
Member Avatar for bibiki

GridBagLayout is the daddy of them all, but has a steep learning curve and gets quite verbose (thanks to all the options). However, I think it's the ultimate tool in the Swing expert's toolbox, so it's worth the effort. Having said that, it's often easier just to nest JPanels with …

Member Avatar for bibiki
0
108
Member Avatar for Dmiller071

1. If you have an empty catch block and an E is thrown execution leaves the statement where the E was thrown, drops through the catch block, and goes on to whatever is after that. So if there is a loop it all depends on whether the catch is inside …

Member Avatar for Taywin
0
191
Member Avatar for Gandrew

1. Post your code in code tags so we can read it 2 [CODE]if (line != null) try { Thread.currentThread().sleep(1000); } catch ( Exception e ) { } str = str+ "\n" + line; [/CODE] If line is null you don't sleep, but you still print it

Member Avatar for JamesCherrill
0
202
Member Avatar for de.ICeman

args is declared in your code, but it is inialised at run time with copies of the arguments that were entered on the command line. If there were no arguments it's initialised to an array of length zero (not null, just an empty array). So an attempt to reference the …

Member Avatar for de.ICeman
0
223
Member Avatar for crazybeaner

Congrats on completing your assignment. If you are interested, there's a better way to approach this because any time you see 10 almost-identical variables and 10 almost-identical blocks of code you should be thinking about using an array and a loop. So instead of g1, g2, g3 etc you would …

Member Avatar for mitchiexlolz
0
1K
Member Avatar for SUBZERO-08

Use myButton.setMnemonic(KeyEvent...) to define a keystroke that is equivalent to clicking the button [url]http://download.oracle.com/javase/tutorial/uiswing/components/button.html[/url] for more info

Member Avatar for JamesCherrill
0
163
Member Avatar for CoolPrizes

1. Forget about some crummy buggy thing you found on the net. 2. You are nearly there. On line 35 you work out how many 20's, but then you need to subtract that from the balance remaining.

Member Avatar for CoolPrizes
1
7K
Member Avatar for SasseMan

Have you upgraded to Java 7 yet? If so, JLayer may be what you're looking for... [url]http://download.oracle.com/javase/tutorial/uiswing/misc/jlayer.html[/url]

Member Avatar for mKorbel
0
952
Member Avatar for murkycrimson

The error message also tells you the exact line where the error occurred. That would be very useful to know. But in the meantime you create an array numbers with exactly one element (length 1), then make lots of uses of it which seem to imply that it's longer than …

Member Avatar for JamesCherrill
0
250
Member Avatar for Jessurider

I personally have no idea, but I Googled [I]java steganography[/I] and got 612,000 hits. Looks like lots of info and code out there if you just look for it.

Member Avatar for Taywin
0
272

The End.