7,116 Posted Topics
Re: Maybe a Double is sneaking into your incorrectly initialised ArrayLists - can we see the code for the inputData method? | |
Re: Hi timzter If you are looking for help here you need to provide enough information. "I get errors" doesn't help. Post the full exact text of all error messages. | |
Re: 97 is 'a', so this looks like an upper case / lower case problem. Probably best to convert the words and the user input to a consistent case before trying to match letters etc. ps chars are numeric values in Java, so rather than obscure code like this `guessme.charAt(mm)-65` you … | |
Re: Java names are case sensitive. If you look at the API documentatiuon for the String class you will find the correct versions of those method names. | |
Re: When you create the first Node the data variable is set to a reference to the array d1. You then change the values in d1 and create second node. But the first node is still pointing to d1, so when you change the values in d1 you affect the first … | |
Re: Long is an integer type. Your Strings do not represent an integer. If you put the code in a try/catch block you will probably catch a NumberFormatException Perhaps you confused `long` (integer) with `double` (floating point)? | |
Re: This tutorial is about as simple as it gets: http://www.tutorialspoint.com/java/java_overriding.htm In your code you have made everything static - that means you can only have one value for the dates, price etc and those values are shared between all the holidays. That's obviously wrong. Every instance of Holiday should have … | |
Re: If you are storing multiple copies of the complete data in Vectors etc then the way you read the file is not the real problem. From your description, with a 2Gig file, you will create a 2Gig Vector which you will use to display 2Gig of data in a JTable. … | |
Re: Any static initialisers are executed in the order in which they are declared before the class is first used. Any non-static initialisers are executed in the order in which they are declared, and before the constructor, when an instance us created. The order in which variables are declared isn't important … | |
Re: How do you declare the arraylist now? And do you mean change the way it's declared, or convert its contents from Strings to Floats? | |
Re: So which line was line 30 in your source code? - the way you posted it has screwed up the line numbers (and the lack of indentation makes it hard to read) I don't know what rowTitles is supposed to do, but simply copying the input array execpt for the … | |
Re: I guess you mean returnResult? You forgot to declare it before you used it. | |
Re: Lines 3 and 4 are useless because line 5 overwrites tempA | |
Re: You have most of the required bits there, but just not quite in the right order! Here are some suggestions: Keep an instance variable for fileName, so in your doSave method you can simply use that without the file dialog stuff on lines 17/18 If that fileName is not null … | |
Re: You need to scan the pixels in each frame by getting their ARGB values and testing for A (alpha) <255 to identily partially transparent pixels, or A==0 for fully transparent pixels. | |
Re: Line 63: overrided paintComponent, not paint JFrame's paint method also paints the buttons etc, so by overriding it you mess that up. paintComponent is the JFrame method that paints the content area of the frame before the buttons etc are painted over it, so that's the one you need to … | |
Re: You shouldn't be updating your GUI from your own thread, you should always do it from the Swing thread. Rather than have a loop, you should use javax.swing.Timer to schedule time-based activities for Swing. I would suggest 5 Timers, one per label so you can start or stop the individual … | |
![]() | Re: If you can't change the class where the button is defined, and that class doesn't make th button public, and it doesn't provide any public methods to access it, then it's not going to be easy. Maybe you can get access to the frame or window that contains the button, … ![]() |
Re: Can you see Myfile.dllfile in olewiew? I've used Jacob with iTunes and [icode]new ActiveXComponent("iTunes.Application");[/icode] works 100%. If you have iTunes maybe you could see if that works for you. Alternatively, have a look at com4j (Google it). It's not as smart as Jacob in terms of its thread handling, and … | |
Re: That depends on what the changes are. You can add or remoe components, you can make components visible or invisible, you can change the text in fields ... whatever you want. | |
Re: Use print statements to check the values of key variables (eg rowCount) - it loks like maybe rowCount is zero, giving a [0][0] array for which any index value will be out of bounds. | |
Re: Are you sure all the positions are different? Maybe print them out to confirm. | |
Re: Can you post a screenshot of your runtime params - maybe it's just a simple typo or somesuch? | |
Re: I tried to read the code in your zip file, but the lack of documenation/comments/good variable names made that very hard. What I couldn't find was where you override paintComponent for your main frame or panel. I saw all kinds of graphics objects and paint methods, but if they don't … | |
Re: You can create a Collection (eg ArrayList) of Strings containing all the words you want to ignore. Then, immediately before your `tokens.add(tokenizer.nextToken());` you can use the `contains(...)` method to see if the next token is contained in you collection of words to ignore. Only add it if it's not in … | |
Re: (As usual) the official Sun/Oracle tutorials are a very good place to start... http://docs.oracle.com/javase/tutorial/uiswing/components/table.html | |
![]() | Re: You couild try increasing the memory available to the JVM to avoid OutOfMemoryErrors... http://stackoverflow.com/questions/2294268/how-can-i-increase-the-jvm-memory ![]() |
Re: Beware! while (listPtr != null) { ... listPtr = listPtr.next; } When you get your list properly circular then this loop will never terminate, it just keeps going round and round the list forever. YOU need to terminate the loop when you get back to the start. | |
Re: catch (RuntimeException ex){ } You should never, and I do mean *never*, yes, really never never never ever do this in a new piece of code. If an error happens you will never see the error message and will never know what happened. Always start with an `ex.printStackTrace();` in the … | |
Re: > Scanner nameinput = new Scanner(System.in); > name = nameinput.toString You are trying to use the Scanner itself as a name! You're supposed to read the name using the Scanner. | |
![]() | |
Re: a and b are int variables. Their values are integers. a=b means that the integer value of b is copied into a, so they now both have the same integer value. S1 and S2 are reference variables. Their values are references to Objects of type Student. S1=S2 means that the … | |
Re: If a method can throw an Execption then you need to declare it as such, eg public void myMethod() throws Exception { ... In your test code you are missing the "try" keyword, as in try { some code } catch .... | |
Re: This arcane line of code will return a File object representing the jar file itself (or more precisely the jar from which the class for the current object was loaded) .. new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()); ... from which it's trivial to get the enclosing directory with `jarFile.getParent() `and use that to reference … | |
Re: What is the exact error message, and exactly which line does it refer to? | |
Re: Maybe it's Character vs char. The generic type is Character, but you try to put a char. Autoboxing will often deal with this kind of thing, but not always, maybe this is one of those times? Try ` put(new Character(...` | |
Re: The problem he needs help with is understanding DaniWeb rules. This is a duplicate post for us to do his homework that shows no effort. | |
Re: That looks like a very good start. Just keep adding stuff one bit at a time. Eg prompt for numger of Players and create them with theor Hands. You could consider a Game class that keeps track of whose turn it is next, who is bust etc. Hit and stand … | |
Re: I don't think you have access to the actual CPU time, but if your program has no I/O, and there's nothing else running on the machine at the same time, then for most purposes you can assume CPU time == real time. (ie, roughly, real time = CPU time + … | |
Re: Just add lots of print statements to see where that value is going missing. ps: Yopur code seems to mix reading chars vs writing ints, and Data IO streams vs ordinary IO streams. That's a formula for confusion. Stick to one type of stream (eg ordinary) and one data format … | |
Re: I think you're right. Depending on what you want it's not hard to create a JDialog with a graphic from a file as background and a few icons here and there... Maybe JavaFX would be better for really snazzy graphics? | |
Re: If you split on the comma each line will give you a two element array. The first element will be the name and second will be the price. It's a String array, so you will then need to parse the price from String to double (or whatever) - the Double … | |
Re: That's too big a question to expect anyone to write a complete explanation just for you, so let's do it in easy stages. First, get comfortable with the idea of interfaces. Read http://docs.oracle.com/javase/tutorial/java/concepts/inheritance.html followed immediately by http://docs.oracle.com/javase/tutorial/java/concepts/interface.html then try the first part of your exercise: > a Parts interface for … | |
![]() | Re: This is easily done by using panels inside panels (that's a common technique). Start with a 1 wide by 3 high grid layout conatining a label, a panel and a label. inner panel then has a 2x1 grid layout and contains a third panel with the radio buttons, and a … |
Re: That looks like a 2xN grid to me, so a GridLayout could be the simplest answer. Have a look a these: http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html | |
Re: That makes no sense. You can't put an action listener in a paint(Graophics g). What specifically do you want to achieve? | |
Re: setSelectedFile(File f) is what you seem to be looking for. | |
Re: It's saying that the class GradeBook does not have a method `determineClassAverage()` . Without all the code for GradeBook we can't say why that happens. | |
![]() | Re: Just pass the Buffer object like any other parameter public Reader(Buffer b) { ... // use b to access the Buffer's methods and variables Buffer myBuffer = new Buffer(); Reader myReader = new Reader(myBuffer); ![]() |
Re: > Write a Java interface named Searchable... You have defined a class not an interface > ... with two abstract methods: ... your methods are not abstract > Be sure your code ... runs as expected This makes no sense. You can't "run" an interface. Were there more specifications that … |
The End.