7,116 Posted Topics
Re: Maybe it's as simple as [CODE]String data = ..... String dataXML = "<MGWData>" + data + "</MGWData>";[/CODE] | |
Re: Your new Runnable is an example of an [I]anonymous inner class[/I]. | |
Re: That's because you go ahead and compute the average, even if there are no numbers. The average calculation is sum/count so if count is zero you get a divide by zero error. After the user has entered his numbers, but before you calculate the average, you can test for count … | |
Re: The error message is caused by you trying to remove something from a Vector that is empty (has no elements in it). Presumably the -1 value for removalBullet is some kind of flag, so in the first version you set that value after removing and it stops you trying to … | |
Re: When the user clicks the button, but text fields have not been completed properly, it's normal to use a JOptionPane to display an error message. After the user has closed the error message he can fix his input, and press the button again. JOptionPane documentation is in the usual API … | |
Re: The compiler error message tells you exactly what the error is and exactly which line it's on. "some error in program" is useless as a problem description. | |
Re: That's an awful lot of drawing to repeat every 20 mSec, especially since nothing changes except an x position offset. Why not create an Image and draw the car into that just once, then you can draw that Image to the panel's Graphics with a single call, which will be … | |
Re: You can create an Image, get its Graphics2D, and use drawString(...) to draw your text in the font of your choice into the Image | |
Re: What [B][I]exactly [/I][/B]is the problem you are having? | |
Re: resultValue is an int, so it doesn't have any methods - so you can't have resultValue.pop() which looks like an attempt to call a pop() method on an int that has no methods. | |
Re: [QUOTE]the program ... does not produce desired output[/QUOTE] That gives us nothing to go on. Exactly what input gives exactly what output, and how exactly does that differ from the correct output? | |
Re: Yes, you said that already in your first post. Just repeating yourself isn't helpful. What exactly is it that you are stuck on? Is it asking the user? Getting the number from the user? Putting an 'x' or 'o' in the array (that one was answered by masijade already)? Something … | |
Re: GThe error message includes the exact location where the error was found. Whay not share that info with us? It really would help. | |
Re: Line 36 is a one parameter constructor public Caesar(File file){... so it's right not to code an actual file name. The actual file name comes from lines 12 and 20 in main. isReadable is a useful call here, but there's no requirement for it to be writable, and its highly … | |
Re: 1st Q : The OP was right. a do while is always executed at least once (unless there is an Exception thrown). 2nd Q: x will be assigned values 10, 20, ... 90, 100. When it reaches 100 the condition x<100 is false and the loop exits, leaving x as … | |
Re: So let me understand this properly: You have a program that does something - exactly what is a secret, which is why you have omitted the specification, removed all the comments, and changed the variable names to something meaningless. You replaced while loop that has some unknown function with a … | |
Re: For animation or other time-based Swing code do not use a loop/sleep - you;'ll have all sorts of problems and sooner or later will block Swing's own thread so everything stops. The correct approach is to use a javax.swing.Timer. You create a Timer that fires every 1000 millisecs and calls … | |
Re: Hi stultuske and stevanity I just picked up on this thread, and there's one post I wanted to clarify... [CODE] public String classlist(){ return classlist(); }[/CODE] [QUOTE] will indeed give you errors. remove the brackets, after all, you're not trying to return the method, but the values[/QUOTE] [QUOTE]the reason for … | |
Re: Your method initGUI() is never called, so you never create the GUI. ![]() | |
Re: When you get an error always post the complete message, including the line number where the error was found. And post your code in CODE tags | |
Re: At line 50 you have retrieved an array containing the file names. JList has a setListData method that takes an array as a parameter and displays the contents of the array. So you just need to create a JList somewhere in your window and call its setListData method passing the … | |
Re: I just had a really quick look and my immediate impression is of good quality code. Variable & method names, plus relevant comments make it easy to see what's what. Lots of runtime tracing to confirm good behaviour (maybe an idea to use a simple Logging class rather than System.out … | |
![]() | Re: Do you know for sure that it's possible and/or sensible to convert it? At first sight I can't see a sensible way to do it, and I would keep the loop you've currently got. |
Re: Welcome Elijah. You'll find lots of people here willing to help you learn. Before your first real post, please take a couple of minutes to check the DaniWeb guidelines on [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] | |
Re: [QUOTE=sirlink99;1691211]no. instead of adding you want to subtract. and the n is the factorial (in your case 7, so 7 x 6 x 5 x 4 x 3 x 2 x 1). [/QUOTE] I don't understand why you have rejected the OP's solution just because it computes the answer in … | |
Re: if (event.equals("Fast")) etc event is an ActionEvent , "Fast" is a String. They can never be equal. But since each listener listens to events from just one menu item, you don't need that test anyway! | |
Re: Yes, post cleaned-up properly indented code in CODE tags, and remember that char is an integral numeric type, so you can do arithmetic with chars directly. You don't need a lot of comments, but >0 would be a good idea; explain the overall intention behind each major section of code. ![]() | |
Re: Right click project - export - runnable jar file | |
Re: Hi there. It's great that you figured it out. In the share and cooperate spirit of DaniWeb do you think you could take a few minutes to explain how you solved it? I'm sure there are lots of us out here who would like to add some sound effects to … | |
Re: [QUOTE=javaNooblet;1688530]I think I've properly fixed them, but no way of telling until I complete the other methods test them[/QUOTE] This is a very common mistake. In fact you can, and should, test methods as early and as often as possible. Waiting until all the code is "finished" makes it really … | |
Re: The [I]print [/I]method is just like [I]println[/I], except it doesn't go onto the next line afterwards.... | |
Re: First is an error in your classpath - delete the invalid directory The last one (serialVersionUID) is an annoying silly one that you can ignore, or add the following var to your class static final long serialVersionUID = 1L; All the others are warnings about generics or absence of generics … | |
Re: You can compare aobj with the possible JComponents that it could be, eg [CODE]if (aobj == myJTextField1) ... else (aobj == myJTextField2) ...[/CODE] When you know what the source is, you can cast aobj to the appropriate class, eg [CODE]if (aobj == myJTextField1) JTextField tf = (JTextField) aobj[/CODE] or maybe … | |
Re: DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] | |
Re: YOu haven't givenus much to go on... eg what kind of processing and manipulation... but one obvious option is to define a small class with fields for info1/2/3 or whatever and methods for the processing/manipulation | |
Re: [QUOTE=Cleo123;1689307]So, how would you remove a duplicated number in an array list without using "Collection.removeAll(Collection<?> c) " out of interest?[/QUOTE] while (numbers.remove(new Integer(43))); | |
Re: setUndecorated(true); (do this before making visible etc) | |
Re: The Java language specification defines the behaviour of the primitive data types - eg byte is an 8 bit value with values from -128 to 127, inclusive, but there is no specification for how these values are actually stored by the Java Virtual Machine, although you can guess. There is … | |
Re: That stopped the E being thrown, but your other problem is on line 30 where printstream is null if a E is thrown before printstream is fully initialised or the initialisation fails - you have committed a major error on lines 42/43 by "eating" the Exception without any kind of … | |
Re: Down to line 30 you compute a value for count (although I have no idea what that value is supposed to be) then from line 35 you start testing the value of grade. Nowhere before line 35 do you set any value for grade. After you fix that you still … | |
Re: [CODE]public static void getData(Scanner kbd, int height, int weight, int age) { System.out.println("Enter your height (in inches):"); height = kbd.nextInt();[/CODE] The variable "height" here is a parameter in the getData method. It's not the same thing as the other "height" that you declared earlier. It's a new separate variable. You … ![]() | |
Re: Try printing the value of selectedIndex one line before the exception - that may reveal something interesting | |
Re: I don't understand what exactly you are trying to do, and judging by the lack of responses I expect nobody else does either! Can you explain exactly what you mean by "show me 5 clock cycles"? Maybe a diagram or illustration of your desired output would help? | |
Re: You have [CODE]do { ... while(Registrant == 0);[/CODE] ie keep doing the loop as long as Registrant is 0 Can you see why that's wrong? | |
Re: If you really really can't use length, remember that the largest 5 digit positive integer is 99999, and the smallest number that's 6 or more digits is 1000000, so you can just test the numeric value. | |
Re: Maybe use an array of arrays? [ICODE]int[][] no[/ICODE] where no[0] contains the array for the first line, no[1] contains the array for the second line etc | |
Re: Here are some thoughts: Start with a collection of equally-sized Images containing the cover art. Work out how to animate a single image as it moves across the window. You'll probably have to use the transform methods on Graphics2D to change the shape of the image according to its horizontal … | |
Re: I think you need to be a lot more specific about the help you need. What have you done so far? What exactly are you stuck on? | |
Re: You haven't set any text or ImageIcon for your Label, so there's nothing to display. You have stored an icon variable, but how will the JLabel paintComponent method know about it? | |
Re: ArrayList <Quiz> questions = new ArrayList<Quiz>(); Every time you create a new Quiz, it has its own version of this ArrayList, so with n Quizes you have n ArrayLists, each with just one Quiz in it. If you make it static, then there will be just one ArrayList that all … |
The End.