• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JavaFX ListView SelectedIndexChanged AIOOB

    Simply test for a -1 selected index before trying to use it!
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Differences between the following declarations

    (Edit) deleted text of post that was based on an incorrect reading of sepp2k's post. My mistake. He is right.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in C++ vs Java for system programming

    For OS internals, drivers etc C++ definitely. Java is for applications - it deliberately isolates you from all the low-level OS stuff.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Basic webservice

    Helpful info, but maybe a bit late? (Question was asked 2 years ago!)
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Yes no checker

    Your methods need to return a boolean (true or false) not a String if you want to call and use them like you do in lines 14 and 16. The …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in File Folder Traversing and Size Calc

    It really pains me to see people struggling with Pre-7 Java code when Java 7 includes far better alternatives. This is one of those cases, where the NIO classes in …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in File Folder Traversing and Size Calc

    Yes aFile could be either, but if on the first pass of the loop aFile is not a directory then the call to recursiveTravesrsal (line 6 above) is made using …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in File Folder Traversing and Size Calc

    for (File afile : files) { if (afile.isDirectory()) { this.childFolder = new Folder(afile); parentFolder.add(childFolder); } recursiveTraversal(afile, this.childFolder); } If the first n Files are files (not directories) the variable childFolder …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How do I sort an array but maintain the original index?

    I don't know of any simple solution. You may have to create a tiny class with the data value and its original index as its two instance variables. Then you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Exception in thread "main" java.util.NoSuchElementException: No line found

    Scanners are the source of a lot of DaniWeb threads - they were intended to be simple, but too often don't work like you expect. I suggest that since you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Exception in thread "main" java.util.NoSuchElementException: No line found

    "an annoying error something with Scanner method" It would be a lot more helpful if you gave us the exact complete error message, including the all-important line number(s) (edit: this …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Create txt file with a user input as its name, inside specific locations.

    OK! Thanks for sharing the solution with us. Please mark this "solved" for our knowledge base. J
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Create txt file with a user input as its name, inside specific locations.

    "It doesn't work" tells us nothing. Did you get an exception? Was the file created but with the wrong location and/or name? Etc? The exception on line 22 (catch) contains …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Some enum wrangling

    Questions: Why have a whole HashMap implemetation just to find enum values from their "f" String. Since enums usually have a small number of values you could simply search `Foo.values()` …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in how to call enum string in field, resort array

    For the benefit of anyone looking for enum-related help here... ParPau's last code may meet the requirements of his exercise, but it doesn't use enums. To get an enum value …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Homework: Pyramid

    WARNING: To anyone copying code for a homework assignments: Your teacher can probably spot solutions copied from the web. If so you will get 0 marks, and may be penalised …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Expression Tree parenthesis

    The problem starts at line 33 (the first line in your code that appears in the stack trace). Looking there. and just before it, you call findMatchingRightParen on line 31. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in developement of browser or media player in JAVA

    JavaFX is part of the latest Java API library. Ity's for GUIs and multi-media support. It is intended to replace Swing for new GUI applications. It has good built-in support …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in developement of browser or media player in JAVA

    Browser is easy, especially in JavaFX, maybe too easy because it doesn't leave a lot of places for you to show your skills. Media player may be better (also in …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Expression Tree parenthesis

    The exception message tells you which line it happened on. Post that info.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in i need help in code

    mustafaaaltup: Your question is too vague. Please be more specific. How far have you got with this? What, exactly, is stopping you now?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How JVM manage the memory and processing?

    No, but from the way it was asked I thought a simple explanation of what a JVM is would ne a good place to start :)
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Multiplication quiz

    All that code for the random numbers (lines 16-21) looks seriously over the top and thus error-prone. (It's already broken; it returns numbers 0-11. Even after you fix that it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How JVM manage the memory and processing?

    This is a good introduction: http://www.makeuseof.com/tag/java-virtual-machine-work-makeuseof-explains/
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in how many time the method is called

    YOu can use the jvisualvm profiler that comes as standard with the JDK - you'll find it in your JDK bin folder. It's really easy.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Minecraft Modding Help

    We are just volunteers here, so nobody will be in a position to give you extended one-on-one training. But if you have specific questions or errors we will be happy …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need Help with my code not compiling

    Excellent! Please mark this "solved" for our knowledge base. You should start a new thread if you run into any new problems. cheers J
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need Help with my code not compiling

    The only way to compare equality between objects of a class is to use the class's `equals` method - the very one that you are writing now! But if you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need Help with my code not compiling

    I just meant that the English specification "t1 in degrees Celcius" is easily implemented in your program by `t1.getCels()`
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need Help with my code not compiling

    So your definition of "equal" is sonething like: Temperatures t1 and t2 are "equal" if and only if t1 in degrees Celcius == t2 in degrees Celcius, within the precision …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need Help with my code not compiling

    (tempNum)==(testObj) tempNum is a double primitive testObj is an object of class Temperature they are so different in kind that using == makes no sense - its like asking "is …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need Help with my code not compiling

    OK. got it 5(tempNum-32)/9 isn't a valid expression. You must specify the multiplication explicitly. It's just not one of the compiler's best error messages ;) (ps no point having doubles …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need Help with my code not compiling

    That looks OK - maybe the parens are already out of step before that code? Also, I don't know what the data type for tempUnit is, but it's unusual to …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Simulating control table of Dynamixel Pro

    Looking at that table the most obvious approach is to create a simple class that represents one row, with instance variables for each column. The whole table is then just …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in playlist

    See this thread http://www.daniweb.com/software-development/java/threads/475808/how-to-play-mp3-files-in-java-using-eclipse - especially the very last post
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to resize Jbutton according to size of picture

    A JButton with an ImageIcon will automatically set its own preferred size to fit the icon. The problem comes when you use a layout manager that re-sizes the buttons to …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Applet Error

    Please mark this "solved" if it's working now. Thanks J
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Applet Error

    Sorry, I haven't used awt for 15 years, and I have forgotten whatever I did know. I guess you will just have to search through the API doc. But there …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Applet Error

    That's really sad. I would worry that if the course materials have not been updated this century then they will also miss the massive language updates of version 1.5 etc. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in java error

    ^ excellent advice. You can, and should, test code as early and as often as possible. Waiting until all the code is "finished" makes it really hard to tell where …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Applet Error

    The awt GUI classes were superceeded in 1998 by Swing. Yes, 1998 - more that 15 years ago. You are seriously wasting your time learning or using it. Update your …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Abstract class

    "it still doesn't compile" tells us nothing. Post the complete exact error messages!
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in java error

    Exactly what errors? - post the *complete* text of all your error message, don't expect people to guess. [edit] Thank you. You should expect some answers now.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in LDAP: error code 52: DSID-0C090E17 Error initializing SSL/TLS, data 0, v1db

    Is that a hex 52 or a decimal 52? LDAP error 52 (hex) is the totally unhelpful "Local error occurred", but if that's 52 decimal (34 hex) it's the self-explanatory …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JLabel image won't show up

    new ImageIcon(...) is famous for not throwing any exceptions when it fails to find the file; it's just null. JLabel is happy to accept null for its image icon, so …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to hannahaddad in Fibonacci program in Java

    at line 21 you misspelled the fib4() (lowercase f) method. and fib4(i), i is long but it should be integer. I hope this help
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Abstract class

    It's nothing to do with imports - the classes are defined in your source file. @hannahaddad told you what to do a day ago. Until you follow that advice you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in playing backround music in a java program

    Wazan: Do not hijack old forum threads by posting a new question as a reply to an old one http://www.daniweb.com/community/rules Start your own new thread if you have a question.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Fibonacci program in Java

    What exactly is the error message the *compiler* (not the runtime) gives for that line? Is line 21 the System.out.println ? It's absolutely pointless to try to execute a program …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in confuse

    Have a look at http://docs.oracle.com/javase/tutorial/getStarted/application/index.html#MAIN

The End.