7,116 Posted Topics
Re: 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 … | |
Re: 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) | |
Re: 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 … | |
Re: In your constructor, lines 17-23 you have all the assignments the wrong way round. | |
Re: 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. | |
Re: You create buttons etc but you don't add them to your JFrame. | |
![]() | Re: 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 |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: "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. | |
Re: 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 … | |
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? … | |
Re: 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 ; | |
Re: 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 … | |
Re: 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 … | |
Re: First pass thru the loop i is 0, Data[i-1] is Data[-1] -> ArrayIndexOutOfBoundsException: -1 | |
Re: 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 … | |
Re: Have you tried compiling and executing your code? What was the result? | |
Re: Nobody will be able to help you without more information. Can you post your code? | |
Re: 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. | |
Re: Your recursion must be looping indefinitely, so add some print statements to show the values of the key variables on each iteration. | |
Re: [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 … | |
Re: 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. | |
Re: Do you want the user to define it with a mouse drag or some other way? | |
Re: 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. | |
Re: 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 - … | |
Re: The String method charAt(int position) returns a single char, there's no conversion needed. What didn't you understand about Stevanity's posts? | |
Re: Yes, Eclipse does this - it has a number of variants on name shadowing that you can configure for warning or not. | |
Re: 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... | |
Re: 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 … | |
Re: 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] | |
Re: You may need to setFocusable(true); on your JPanel followed by requestFocus(); | |
Re: 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. | |
Re: 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] | |
Re: 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 … | |
Re: 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? | |
Re: 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 | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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. | |
Re: 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] | |
Re: 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 … | |
Re: 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. |
The End.