7,116 Posted Topics
Re: Line 36 - you want to know if the price is greater than the highest you have found so far (cf line 45). Then look at the initialisation of cheapBookPrice - if it starts at 0 will you ever find a cheaper one in your data? | |
Re: @godzab: Please explain exactly how you think AtomicInteger is relevant here. @47Pirates: All you need is a simple listener that updates the table. Please post your latest/best attempt for further help. | |
Re: Put the strings into an array and use the randon int (0-3) as the index to retrieve one element of the array. | |
Re: Thank you for sharing that information with us. ps: If you have a question please post an exact description of the problem, with complete copies of any exceptions or error messages, and all the relevant source code. We may be smart, but we're not mind readers! | |
Re: The languages are very similar, but the APIs are completely different. Converting the syntax (with a few specific exceptions) is no big deal, but mapping/converting the APIs would be a massive task. | |
Re: [QUOTE]Generally a bad design to include so many parameters in the constructor. Getters and setters should be invoked over extensively adding input parameters.[/QUOTE] I can't let this pass without comment. When you instantiate any class there is some number of values that must be set for subsequent uses of that … | |
Re: `total = number++;` Probably not what you intended!. This copies number to total, then adds 1 to number. You ned to add number to total. | |
Re: They have many similarities in how they are used, and a quick Google will find you lots of detailed discussion on the differences, but the shortest version is that abstract classes can contain far more than interfaces (eg actual method defininitions), but you can only `extend` one class at a … | |
Re: That's not the correct syntax for multiple parameters - every parameter must have its type (String etc) specified explicitly, eg `void add(String a, String b...` With 26 parameters you may want to consider passing an array instead? ps: Next time don't just say "I get an error". Always post the … | |
Re: When you code `System.out.println( IntegerSet.union(setA, setB));` the union method returns an instance of IntegerSet, and println then calls that object's `toString()` method to get a printable version of the object. Every object inherits a version of toString from the Object class, but it's not very useful (it just returns the … | |
Re: paint for a JFrame also paints the borders and the children of the frame. By overriding it and not calling super.paint you have supressed JFrame's painting those objects. If you want to have custom painting the best option is a new subclass of JPanel and override its paintComponent method, thus … | |
Re: Welcome. We are happy to help anyone, beginner or expert, as long as they are willing to listen and put in some effort. > might not have been initialized Means what it says. The compiler has worked out the possible routes through ypur program, and seen that one or more … | |
Re: The problem seems to be that the document is locked when the listener is called, so when you try to update the document you can't get the lock to write to it. The solution, if you want to keep it working the same way, is to use SwingUtilities.invokeLater to run … | |
Re: The real problem here is not how you are accessing static variables; it's the fact that you are mis-using static in the first place. static means that every instance of that class shares the one same value - in this case there is only one` boolean[] a`, which is shared … | |
Re: `enum Status{WIN, CONTINUE };` That's enough to define and initialise the enum, you don't need anything else. What exactly was the comment that confused you? | |
Re: Put a load of print statements into your code, printing the values of the key variables at each stage so you can see where it's going wrong. Focus on the code that parses the user's input. Once you can see exacty what values are being set and used at each … | |
Re: > How do I put (File soundFile) as the parameters in new Track()? If Track has a constructor that accepts a File as a parameter, then just create a File and pass it, ie File f = .... create the file as needed track = new Track(f); If Track does … | |
Re: Step 5 - uncheck the check box for "Export Java source files" | |
Re: In your toString method you can include \n characters to start a new line | |
Re: Yes, we can help. Just check out the DaniWeb member rules before you post - in particular ."Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules | |
Re: Use the String split method with a comma as the split character to separate the strings into a String array, then use trim() on each string to get rid of leading and/or trailing blanks as required. Or, if you're a regex black-belt you could define the separator string as <any … | |
Re: Just go back to the problem definition and work through it one step at a time. It's written so as to help you. Start with the array of booleans with index values 0-100 inclusive. (The size is defined in the problem statement, so you don't need it as a parameter.) | |
Re: Maybe some component in your window has keyboard focus and is consuming the ctrl-X (cut) keystroke? | |
Re: A small hint: conversion of char to the int value it represents: We know that char is a numeric type, and we also know that '0' to '9' are consecutive in UniCode, so once you have checked that k is a digit you can safely replace all thise if/elses with … | |
Re: That is not a compile error, its a runtime error. I simply means what it says - it cannot find that file. The file name may be wrong, or it may be in a directory other than the one where Java is looking for it. | |
Re: You are probably getting the "not initialised" because your init method is terminating abnormally (with an NPE exception). The NPE means an uninitialised variable. Your line numbers don't seem to match the error message exactly, but at a guess it's probably due to your not initialising yout JPanel variables. The … | |
Re: Put a load of print statements into your code, printing the values of the key variables at each stage so you can see where it's going wrong. | |
Re: When you have a controller and a GUI it normally goes like this: The controller is responsible for invoking the GUI, and passes itself as a parameter to the GUI constructor, so the GUI has a reference to the controller. The GUI is responsible for all listeners on the GUI … | |
Re: Mainstream languages such as Java and C# all have very similar structures and syntax - learn one and the others are no big step. General programming skills such as understanding algorithms, designing and testing code etc etc are also largely language independent. The biggest hurdle in moving from one language … | |
Re: Can you post your exact complete manifest file here? | |
Re: DIY loops and graphics are not the way to go. Swing is in charge of Java GUIs, so you have to operate within swing's design assumptions. Swing Timer is the timer used by Swing itself - you can definitely rely on it. Also its the only one that ensures you … | |
Re: You have giant arrays of 10,000 elements each, of which only the first 2 elements are populated and the remainder are null. When you loop you loop through the whole array, so you are guaranteed to hit nulls sooner or later. You need a variable that tells you how many … | |
Re: is userInput supposed to be int or String? - either way this won't work! | |
Re: That's what the code on lines 50-55 does right now. What exactly is your question? | |
Re: The code to create a GUI is always a long long list of repetitive add/set method calls - people often use a GUI design tool to generate them. It really doesn't have a structure. The only thing you can do is to put it all in a simple method, eg … | |
Re: Yes, that's exactly what it looks like. On line 6 you declare rtot,vtot,ptot,gtot,ntot,patot, but then on lines 38, 49, etc you declare new local variables with the same names. | |
Re: @gbulfon Your conrtributions are very welcome here, but please check the dates before adding to an existing thread - this one is 5 months old, so either the OP has found a solution or he doesn't care any more. | |
Re: Line 1 is the start of the definition of a method called main. (Every program needs this method - it's the one that is called first when you execute your program). Then on line 3 you start the definition of another method. You can't define one method inside another. You … | |
Re: Pushparaj ruban This question was answered a year ago. Do you think the OP is still waiting for someone to confirm it? | |
![]() | Re: I don't see anything wrong with updating x0 and x1 like you are doing - more variables won't help. But there are two logic problems as far as I can see: 1. Your loop condition will always be true, regardless of what's in the loop. So your loop will always … ![]() |
Re: @cross213: stultuske is giving you good advice, so you should make more effort to follow it rather than wasting his time. Your latest code completely fails to implement the perfectly good solution that he gave you earlier. Re-read his posts and think carefully about what he says.. | |
Re: This is very confusing because the variable names in your code look like the ones in the diagram/formulae, but are used completely differently -eg in the diagram x2,y2 is the centre of the circle, but in your code they are one of the intersection points. So my advice is 1. … | |
Re: Are you asking to run a windows executable on Max or Linux? That's not a Java problem - you need a windows emulator or native windows API implementation, so on Mac you need Parallels (or equivalent), on Linux its Wine (or equivalent). Is this a very specific application, or do … | |
Re: The client and server will probably be quite different programs, with completely different installation requirements, so I would say "keep them separate". The client will probably just be a single jar file, but the server will be a different jar, plus database etc. Either way, your installer can still ask … | |
Re: Where are you stuck - how far have you got? | |
Re: You extended JPanel, not JFrame. You can't display a JPanel except inside a top-level container eg JFrame. | |
Re: Without reading all the code, that certainly looks sensible. Just write a small test to see for yourself if it is right... all you need is a method to print the contents of the tree after you have inserted some data. | |
Re: A byte is 8 bits, nothing more. You may chose to interpret that as a number, or as a character, but that's up to you. The simple read() method for input streams places those 8 bits as the least significant 8 bits of an int variable, where you can use … | |
Re: I suspect that's the wrong language! The usual Java version is `System.out.println(...` | |
Re: The "programming model" is the design and intention behind the classes and APIs, so if you understand how the classes and methods all fit together to make an application then you have understood the programming model. "Structures" usually refers to data structures, but in an OO language these are usually … |
The End.